SA-MP Forums Archive
Error problem! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Error problem! (/showthread.php?tid=459550)



Fixed! - Giroud12 - 23.08.2013

Fixed!
Thanks to KONSTANTINOS


Re: Error problem! - efrim123 - 23.08.2013

did you make a filter script?

if yes put in the end of it
#endif


Re: Error problem! - Giroud12 - 23.08.2013

Lol,its not the solution.
I think the problem is I missing some bracket


Re: Error problem! - Konstantinos - 23.08.2013

If you could indent your code, you would be able to fix your problems easier. Take a look:
pawn Код:
if (GetPlayerMoney(playerid) <= 5000) return SendClientMessage(playerid, RED, "You don't have enough money!"); //line 314
{
    GivePlayerMoney(playerid,-5000);
    pInfo[playerid][Cookies] += 10;
    new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
    dini_IntSet(file,"Cookies :", pInfo[playerid][Cookies]);
}
if(listitem == 3)
{
    if (GetPlayerMoney(playerid) <= 10000) return SendClientMessage(playerid, RED, "You don't have enough money!");
    {
        GivePlayerMoney(playerid,-10000);
        pInfo[playerid][Cookies] += 20;
        new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
        dini_IntSet(file,"Cookies :", pInfo[playerid][Cookies]);
    }
    if(listitem == 4)
    {
        if (GetPlayerMoney(playerid) <= 25000) return SendClientMessage(playerid, RED, "You don't have enough money!");
        {
            GivePlayerMoney(playerid,-25000);
            pInfo[playerid][Cookies] += 50;
            new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
            dini_IntSet(file,"Cookies :", pInfo[playerid][Cookies]);
        }
       
        return 1;
    }
    return 0;
}
You open braces, and you continue like that without closing and checking the rest. It's like doing nested if statements, when it should be:
pawn Код:
if( something )
{
    // blabla..
}
else if( something )
{
    // blabla..
}



Re: Error problem! - Dragonsaurus - 23.08.2013

Dude you are using if statements, returning a message and opening a brace...
Why should you open a brace, you are done with that if clause...


Re: Error problem! - Giroud12 - 23.08.2013

So how to fix it?


Re: Error problem! - Dragonsaurus - 23.08.2013

Where you have if and return in the same line, remove the braces "{" and "}".
Example:
pawn Код:
if (GetPlayerMoney(playerid) <= 5000) return SendClientMessage(playerid, RED, "You don't have enough money!"); //line 314
GivePlayerMoney(playerid,-5000);
pInfo[playerid][Cookies] += 10;
new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
dini_IntSet(file,"Cookies :", pInfo[playerid][Cookies]);
You don't need braces here.