Often seen errors
#1

Hello

I have made this topic after i got the thought that theres >way< to many people asking the same questions
over and over again. Thats why i started write this list which i hope will help people to fix their
problems themself when they know what the errors means. I personally think its easier

I have not added every single error or warning you can find in the pawn language. But i picked some
i think has been asked alot. I will try to add more errors and warnings as times goes.


Of course i would be glad if people would share their experience and that way make it easy for new
scripters to fix errors

Please note i split up each error/warning with "-------"

---------------------------------------------

warning 217: loose indentation
Now this is a well known warning. What it means is theres a line which is allined wrong or not like the
rest of the functions. Heres an example

pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  return 1;
}

Note that the return 1; is not allined the same way as the functions. This means that the return 1; is
almost alone. Even tho it is the 1 standing the right place.

Now the correct way for this to be placed is like this

pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
  SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  return 1;
}
By clicking "tab" once every time you put an opening bracket "{" it will make it more easy to see
how many brackets you need to close and it doesn't look like a big mess. So i recommend this


---------------------------------------------

error 054: unmatched closing brace ("}")

Now this text is indirectly telling you that there is 1 or more closing brackets "}" too much.
This can be fixed by trying removing 1 closing bracket then compile. Keep doing that until the
error is gone. Note that theres no warning or errors for your missing a closing bracket "}".
But you will get a big bunch of errors on lines you havn't even changed or used. By that
then is alot of errors probaly a sign on a missing closing bracket. Go look where the errors
starts and count the brackets.

---------------------------------------------

fatal error 100: cannot read from file:

Now when someone releases a script. They will probaly be asked about this errors. Note that the
file "hello_samp_forum" is not a real file, but just something i made up to create this error.
Now when you download a gamemode or a filterscript they will often use "Non-Standard include files".
"Non-Standard include files" is files which is not created by Kye or any other of the SA-MP Team.
But has been made by enthusiants who made it to make others scripting easier. A often made type
of include file is a "Streamer". But let's get back to the point. This error simply tells you the
downloaded or made yourself needs a include file, but can't find it. Now there can be 2 reasons.
1: You have the include file but it's not in the \\pawno\\includes directory.
2: You don't have the include file at all. Now some scripts have "special designed" includes.
But most uses include files which can be found by ****** it or search the name on the forum.

If you still get this error after putting the include in the includes. Make sure you don't have
more pawno directories and the include file is in the includes which is the pawno you use.

---------------------------------------------

warning 202: number of arguments does not match definition

Now im gonna show 2 line of code
pawn Код:
new pip[16];
pip = GetPlayerIp(playerid);
This code will have 2 warnings. The warning means that you forgot to add some variables
to a function. In this case it's GetPlayerIp(playerid); You see what is wrong? Player IP's can not
be saved like that but you need this function instead GetPlayerIp(playerid,pip,sizeof(pip)); And you
should have deleted "pip =" so the current code is

pawn Код:
new pip[16];
GetPlayerIp(playerid,pip,sizeof(pip));
And you should have no errors. Now what i have done is i have shown you that some things (Like player name
and player IP) Needs to be saved with such a function. But this doesn't need to be the problem your
having. My best advice would be to check this.
It's the official SA-MP wiki forum where you can find alot of useful stuff for your scripting like
the function list. By clicking the function you want to know more about you can get all variables needed
and how to use it.

---------------------------------------------

error 017: undefined symbol

This error is quiet simple. It means that if you make a line like "lol = 1;" and you forgot new lol;
This error will show up. Note that there can be several reasons why it comes.
1: You forgot to make the "new" named lol or what you call it
2: You made a typo so they are not the same
3: The "new" you have made is not global so it can't find it.


Fixing 1: Well it's easy. Add new lol;

Fixing 2: Check all the places you uses the new if they are spellt the same

Fixing 3: Put the "new" above the main() in your script or if its a filterscript above OnFilterScriptInnit


Now with this done the error can also show up if you use a function which don't exist or you mis-spellt
the variables in a function. The last thing can be that you forgot to define something like a color.
Which is defined like this "#define COLOR 0xFFFFFF" You can use define to any constant value like an ammount
of cash which makes it easy for people downloading a filterscript to define the ammount the things should cost.
Theres actualy no limit on how useful #define can be

---------------------------------------------

warning 204: symbol is assigned a value that is never used

Now this warning don't kill your script or anything. It just tells you that you defined something like

pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
But then never uses the value it's defined to. Now it is a waste since you don't need it so you can just
delete it to get rid of it telling you the warning every time you compile

---------------------------------------------

fatal error 107: too many error messages on one line


Now i wont talk too much about this error. It honestly explains itself but if your not sure.
This error will show up when theres 3 or more errors on the same line. I honestly don't see the use
of this error.

---------------------------------------------

error 001: expected token:
Now this error can be tricky as you sometimes have to think it through a time or 2.

But i made an example for you

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid,0xFFFFFF,"Now i just make some random text")
        SendClientMessage(playerid,0xFFFFFF,"notice i forgot ; on the line above");
        return 1;
    }
    return 0;
}
This error will show itself as ("error 001: expected token: ";", but found "-identifier-") why? Notice
the first SendClientMessage needs a ; . But the compiler tells me the error is on the second
SendClientMessage. This is because it finds the -identifier- on the 2nd SendClientMessage.
With that said you now know that ; means it needs a ; . And we also know we have to look on the
function above. Now as said this error is tricky so it might not always work


----------------------------------------------


Код:
Header size:      200 bytes
Code size:       588 bytes
Data size:       512 bytes
Stack/heap size:   16384 bytes; estimated max. usage=10250 cells (41000 bytes)
Total requirements:  17684 bytes

Alot of scripts will show this message when compiled. What this means is it uses WAY too many bytes
to compile. The main reason why this comes is that many people uses strings. And many of those people
put their string on the size 256. Now this is just plain waste as your probaly never gonna need more
than 128. This means you waste the double of the ever needed bytes. This will make your server slow
and make compiling take alot of time.

If you don't want a slow server check these 2 topics out (Both made by ******) "Why you should not use 256"
"Code Optimisations"

These topics will help you make faster scripts




Now i have made a list. It's not finished as i will add more errors/warnings whenever i get the feeling

Again i would be happy if pro scripters would share their experience and explain a few errors to the good
of all.


If you have further questions PM me or reply in this topic


Regards
Desert
Reply
#2

Nice topic useful for newbies.
Reply
#3

well really good tutorial for beginners.
Reply
#4

Nice.
Good job.
Reply
#5

Thanks
Reply
#6

Very nice work
Reply
#7

wow very nice that topic should be really sticked
Reply
#8

Thanks
Reply
#9

Nice summery of errors you've made there. Will be useful for a lot of people I think.
Reply
#10

Read pawn-lang.pdf, it has all the warnings explained.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)