[Tutorial] Fixing Errors (most basic)
#1

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.
Код:
error 017: undefined symbol
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
pawn Код:
public OnPlayerConnect(playerid)
{
    SenClientMessage(playerid,0xFFFFFF,"You have connected to our server! Enjoy your stay!");
    return 1;
}
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...
pawn Код:
public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid,COL_BRIGHTBLUE,"You have connected to our server! Enjoy your stay!");
    return 1;
}
simply writing this would give us the error
Код:
error 017: undefined symbol "COL_BRIGHTBLUE
why? Because we forgot to define COL_BRIGHTBLUE above. So we'll have to define it.
pawn Код:
#define COL_BRIGHTBLUE 0xFFFFFF
Here's another common error:
Код:
: error 037: invalid string (possibly non-terminated string)
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:
pawn Код:
SendClientMessage(playerid,0xFFFFFF,"You have connected to our server! Enjoy your stay!);
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:
Код:
error 035: argument type mismatch (argument [number])
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:
pawn Код:
SendClientMessage(0xFFFFFF,"You have connceted to our server! Enjoy your stay here!");
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.
Код:
warning 202: number of arguments does not match definition
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...
pawn Код:
SendClientMessage(playerid,0xFFFFFF,"You have connected to our server! Enjoy your stay!",playerid);
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:
Код:
error 001: expected token: ";", but found "[symbol]"
Errur numbah one!!!! So this error id numbah one tells you that a ";" is missing. example:
pawn Код:
SendClientMessage(playerid,0xFFFFFF,"You have connected to our server! Enjoy your stay!")
return 1;
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
Reply


Messages In This Thread
Fixing Errors (most basic) - by NaClchemistryK - 15.04.2014, 09:27
Re: Fixing Errors (most basic) - by Ada32 - 15.04.2014, 10:12
Re: Fixing Errors (most basic) - by superrobot48 - 15.04.2014, 11:46
Re: Fixing Errors (most basic) - by NaClchemistryK - 15.04.2014, 14:47
Re: Fixing Errors (most basic) - by NaClchemistryK - 21.04.2014, 17:44
Re: Fixing Errors (most basic) - by Ada32 - 21.04.2014, 18:08
Re: Fixing Errors (most basic) - by Abagail - 21.04.2014, 22:36
Re: Fixing Errors (most basic) - by NaClchemistryK - 30.04.2014, 16:11
Re: Fixing Errors (most basic) - by iZN - 30.04.2014, 16:40
Re: Fixing Errors (most basic) - by NaClchemistryK - 01.05.2014, 08:21

Forum Jump:


Users browsing this thread: 2 Guest(s)