15.04.2014, 09:27
(
Последний раз редактировалось NaClchemistryK; 01.05.2014 в 08:22.
)
Yo guys.
This is my first tutorial ever done, so please don't laugh if it is bad/useless/messy..
So I was going through the tutorials and realized that there are just a few threads that descrive how to fix errors. Since a am a rookie scripter, I will only tell you about the most frequent errors done by newbies. That's why this tutorial is specially for scripters who have started learning.
Let's start.
This is a error message that tells you that you have just written a symbol/code name that is yet undefined.
Let's suppose we did following
Oops! We just realized that we wrote "SenClientMessage" instead of "SendClientMessage", so this would give us the error saying that "SenClientMessage" is an undefined symbol. Things like these don't only occur by mistyping, they could also mean that you have forgotten to define a variable, or a colour name etc...
simply writing this would give us the error
why? Because we forgot to define COL_BRIGHTBLUE above. So we'll have to define it.
Here's another common error:
I don't know if a lot of people do this, but I do this so damn often...
Now looking at the error message, it says "possibly non-terminated string)", means that it could have been that the string wasn't completed. What could this mean? Simply that we didn't end the string. And example of this mistake:
non terminated string means, that we didn't tell the script that our message has ended. Now what does end a string in the function SendClientMessage? the ""s. Now we should've realized that we have forgotten to add a ' " ' to end the string. add it, and the error should be fixed.
Now that I think about it, this wrongly made code should give more errors, like "undefined symbol "You"", "undefined symbol "have"" etc, because the string hasn't ended, so the script will think that it is some sort of a function. But the compiler knows that the third argument of SendClientMessage is a string.
Concearning arguments:
Newbs might get this error often, since they sometimes forget the arguments of a function.
This error refers to a simple error. let's suppose we wrote this:
This would give us the error "argument type mismatch(argument 2)". This means that we haven't written the argument we should have written. This error says that there is something wrong with a certain argument, or doesn't make sense. Here are the parameters of SendClientMessage:
playerid, [colour], const message[]
Now, you should all have realized that we forgot the "playerid". Because we have to tell the script to WHOM we want to send the message.
This is also a mistake, that can be done, also concearns arguments. This says us that we haven't written the correct amount of arguments. Let's suppose we wrote something extremely stupid.... for god's sake, I'm just trying to explain, so don't laugh...
yea yea, who would write this...
Now looking at it, we wrote 4 arguments, even though the function SendClientMessage has 3 arguments. so we must remove the "playerid" at the very end, cause it's useless. a script doesn't need an extra explenation of what it needs to do. A human might forget whether he should give the cup of tea to his brother or his dad, but a script is rim by a computer, you know... but that doesn't mean it can't do mistakes... another common error:
Errur numbah one!!!! So this error id numbah one tells you that a ";" is missing. example:
This will gives us the error "expected token: ";" but found "return"" . EXTREMELY SIMPLY means that we forgot to write a ";" at the end of the function SendClientMessage(). now, when you look at the line given at the error, it will give you the error at the line of "return", because when he doesn't find that token behind SendClientMessage(), then he will look for it at the next line, and then the next, until he finds a symbol.
Well, a few last words...
This tutorial isn't completely finished, since I just realized that you have to explain a lot, so well.
Thanks a lot for reading, and I hope I helped you.
Updates
Here, you will find the updates and their post number. I won't edit the original topic, else it will get too long.
Update: April 21st 2014, post number 5
Update: April 30th 2014, post number 8
This is my first tutorial ever done, so please don't laugh if it is bad/useless/messy..
So I was going through the tutorials and realized that there are just a few threads that descrive how to fix errors. Since a am a rookie scripter, I will only tell you about the most frequent errors done by newbies. That's why this tutorial is specially for scripters who have started learning.
Let's start.
Код:
error 017: undefined symbol
Let's suppose we did following
pawn Код:
public OnPlayerConnect(playerid)
{
SenClientMessage(playerid,0xFFFFFF,"You have connected to our server! Enjoy your stay!");
return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid,COL_BRIGHTBLUE,"You have connected to our server! Enjoy your stay!");
return 1;
}
Код:
error 017: undefined symbol "COL_BRIGHTBLUE
pawn Код:
#define COL_BRIGHTBLUE 0xFFFFFF
Код:
: error 037: invalid string (possibly non-terminated string)
Now looking at the error message, it says "possibly non-terminated string)", means that it could have been that the string wasn't completed. What could this mean? Simply that we didn't end the string. And example of this mistake:
pawn Код:
SendClientMessage(playerid,0xFFFFFF,"You have connected to our server! Enjoy your stay!);
Now that I think about it, this wrongly made code should give more errors, like "undefined symbol "You"", "undefined symbol "have"" etc, because the string hasn't ended, so the script will think that it is some sort of a function. But the compiler knows that the third argument of SendClientMessage is a string.
Concearning arguments:
Код:
error 035: argument type mismatch (argument [number])
This error refers to a simple error. let's suppose we wrote this:
pawn Код:
SendClientMessage(0xFFFFFF,"You have connceted to our server! Enjoy your stay here!");
playerid, [colour], const message[]
Now, you should all have realized that we forgot the "playerid". Because we have to tell the script to WHOM we want to send the message.
Код:
warning 202: number of arguments does not match definition
pawn Код:
SendClientMessage(playerid,0xFFFFFF,"You have connected to our server! Enjoy your stay!",playerid);
Now looking at it, we wrote 4 arguments, even though the function SendClientMessage has 3 arguments. so we must remove the "playerid" at the very end, cause it's useless. a script doesn't need an extra explenation of what it needs to do. A human might forget whether he should give the cup of tea to his brother or his dad, but a script is rim by a computer, you know... but that doesn't mean it can't do mistakes... another common error:
Код:
error 001: expected token: ";", but found "[symbol]"
pawn Код:
SendClientMessage(playerid,0xFFFFFF,"You have connected to our server! Enjoy your stay!")
return 1;
Well, a few last words...
This tutorial isn't completely finished, since I just realized that you have to explain a lot, so well.
Thanks a lot for reading, and I hope I helped you.
Updates
Here, you will find the updates and their post number. I won't edit the original topic, else it will get too long.
Update: April 21st 2014, post number 5
Update: April 30th 2014, post number 8