[Tutorial] Fixing Errors (most basic)
#8

This is a update to the topic. Updated on April 30th 2014.

Yo, sorry to make a late update, was very busy making my own server.

So last time we've talked about warnings. As you know, warnings should be fixed, but can also be left like that. But leaving it alone might cause it bugs.
So we are gonna go back to the main stuff we were supposed to do in this topic: fixing ERRORSSSSSSSSSSSSS
First I am gonna correct something I did wrong at my very first post.
Код:
error 001: expected token: ";", but found "[symbol]"
This error must not be given when you only forget the ";", but it can be for any token, though in some cases it will give some other errors because it can't say whether you really must have used that certain token or not. So it has to be like this:
Код:
error 001: expected token:"[symbol]", but found "[symbol]"
Don't always trust this error, it sometimes specifies you some tokens you wouldn't put there. So it is sometimes better to check stuff yourself. Example:
pawn Код:
public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid,0xFFFFFF,"You have connected to our server! Enjoy your stay here!";
    return 1;
}
Now we should've realised that we forgot a bracket, but the compiler will give this error:
Код:
error 001: expected token: ",", but found ";"
it is saying us that he expected a comma to be there. Total bullshit, we just wanted to send him a message, and we forgot a bracket there. No need to trust the compiler in this situation.

So me having corrected that mistake, we can go on with the real stuff.
Alright, so when you do some useless shit and script something that doesn't make sense, you'll get this error:
Код:
fatal error 107: too many error messages on one line
well, this won't be the only error message shown. The compiler will show you some examples of mistakes you did on that line. Now there are trillions of examples, but I can't end it without an example.
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(IsPlayerAdmin = false)
    {
        Kick(playerid);
    }
    return 1;
}
alright, this might make a little sense for newbs, but doesn't for the compiler. You might want to check if a player is a rcon admin when he enters a vehicle. but the line expression " = false " makes NO sense.
when you want to use " = " you can only use it to give a certain variable a number.
pawn Код:
new innocentguy[MAX_PLAYERS];
new idioticDMer[MAX_PLAYERS];
public OnPlayerDeath(playerid,killerid)
{
        innocentguy[playerid] = playerid;
        idioticDMer[killerid] = killerid;
        return 1;
}
And we also tried to check whether the script IS setting the IsPlayerAdmin as false AT THE EXACT MOMENT, which makes even less sense.
If you had a little brain, you would rather use " == " to check whether it is set to false (which can't be), and also add a (playerid) behind IsPlayerAdmin if you have a little intelligence, and use
pawn Код:
if(!IsPlayerAdmin(playerid))
if you had scripting experience xD. The last one was correct, everything else was WRONGGG
Alright, so I cannot tell a lot about this error, since it can be any case where you did tons of mistakes, so let's go on.
Код:
error 076: syntax error in the expression, or invalid function call
alright, I created this error after experimenting the first thing I said there about adding the ==s, hehe
pawn Код:
if(IsPlayerAdmin == false)
This error is given when the logic isn't there, or we haven't "used" a function correctly. A quote from Wikipedia:
Quote:

The term syntax is also used to refer to the rules governing the behavior of mathematical systems, such as formal languages used in logic.
So let's look at the logic of this thing. the error says that we haven't expressed it correctly. Trying to check wether a Player is admin and at the same time checking whether it is SET to false doesn't make sense.
And we haven't used the correct functions. Lemme use another example of this error to explain the "function call" more clearly.
pawn Код:
public OnPlayerConnect(playerid)
{
    SetTimerEx("MoneyReward", 1200000,true,"i",playerid);//every 20 mins
    return 1;
}

forward MoneyReward(playerid);
public MoneyReward(playerid)
{
    GivePlayerMoney(playerid,300000);
    SendClientMessage(playerid,0xFFFFFFFF,"Thank you for playing for 20 minutes!");
}

public OnPlayerDisconnect(playerid, reason)
{
    KillTimer(MoneyReward);
    return 1;
}
This is a mistake I used to do.....
Alright, here we've set a timer, and every 20 mins it gave 300K to the player who played 20 mins. Then we tried to end that timer when he disconnected.
But we did something wrong. The first parameter of SetTimerEx is functionname[]. We just gave it our own name, but it is still a function. And we cannot kill a function. This is for example an incorrect "call" of a function. Or rather incorrect kill xDDD


So that's it again for this day, or rather week. I don't have much time to look for more errors, I have an own server ta script, sry!
So cya next time guys.
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: 1 Guest(s)