Note:
This is mainly for newbie scripters, as im guessing alot of intermediate / advanced scripters allready know about these error messages
The error messages of doom
Below is an example of an error message when trying to compile.
Code: Select all
C:\Users\Stu\Desktop\other\Stu's plugins\b_rush.sma(107) : error 035: argument type mismatch (argument 2)1) "C:\Users\Stu\Desktop\other\Stu's plugins\b_rush.sma"
This is where the source code of the plugin is saved. In my case, it is held in a folder on my desktop called "Stu's Plugins". It might be a good idea to create a folder on your desktop to keep all your plugins neat and tidy. Another good place to house plugins would be "C:/Program Files/Pawn Studio/Plugins", or "C:/Program Files/AMXMODX/Plugins"
2) "(107)"
(1/3 Main parts that you need to know)
The number within the brackets is what line the error/warning has been found. In our case, its occouring on line 107. With most good IDE's (Pawn Studio, AMXX Studio, etc.) the line numbers are printed down the left hand side to make it easier to find. If you're useing notepad or similar, there may be a keyboard shortcut E.g. Ctrl+H to goto a specific line number
3) "error 035:"
This is the error code. Im not entirely sure if there is a list of pawn error codes, so ill probably steal the 2nd post and make a list of them there. Allthough this error code is not nesseserily needed, it might be worth noting it down and how you fixed it for future reference.
4) "argument type mismatch"
(2/3 Main parts that you need to know)
In our case, an "argument type mismatch" is where the function "client_print" dosent have enough parameters.
5) "(argument 2)"
(3/3 Main parts that you need to know)
This shows precisely where the error is within the function
Break it down
So now we have broken down the error, we have a clearer view of where the error is and what is wrong
Part 1/3 shows that the error is on line 107
If we find our line 107, we find this:
Code: Select all
client_print(0, "Welcome to the server!");3/3 shows that argument 2 is incorrect
What should it be?
Lets check funcwiki and see what the client_print function should be:
Code: Select all
client_print - Sends a message to a player.
Syntax:
client_print ( index, type, const message[], ... ) Type:
Native Notes:
id is a player index from 1 to 32. If 0, the message will be sent to all players.
The type is one of three types:
print_chat - chat text
print_console - console message
print_notify - console in dev mode
print_center - center saySo we can see that client_print should have a minimum of 3 arguments. Our code has 2
So lets check where we went wrong
our "index" is set to "0"
This is fine (Will print to the server)
Our "type" is set to "Welcome to the server!"
This is not a type, because the funcwiki says that we need to use print_chat, print_console, print_notify, or print_center.
If we check number (5) of our error again, we see that the error was in "(argument 2)", so this would back up our assumption that the "type" was wrong
Fixing the error
So we can now go back to line 107 and change it to this:
Code: Select all
client_print(0, print_center, "Welcome to the server!");Now lets re-compile and see what happens...
Oh look!
Code: Select all
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team
Header size: 944 bytes
Code size: 3796 bytes
Data size: 1364 bytes
Stack/heap size: 16384 bytes; max. usage is unknown, due to recursion
Total requirements: 22488 bytes
Done.
Compilation Time: 1.10 sec