SA-MP Forums Archive
[ERROR] error 029: invalid expression, assumed zero - 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] error 029: invalid expression, assumed zero (/showthread.php?tid=406828)



[ERROR] error 029: invalid expression, assumed zero - GwENiko - 11.01.2013

Hey, im derping on this part of my script. I have no idea how to deal with this, i've searched for countless threads, i still don't know how to fix this.

Quote:

gamemodes\test.pwn(437) : warning 217: loose indentation
gamemodes\test.pwn(437) : error 029: invalid expression, assumed zero

pawn Код:
if(strcmp(params,pass,false) != 0)
                        {
                                SendClientMessage(playerid,0xFF4500AA,"Wrong Password!");
                        }
                        else
                        {
                            dini_IntSet(file,"Logged",1);
                            pInfo[playerid][Logged] = 1;
                            pInfo[playerid][Level] = dini_Int(file,"Level");
                            SendClientMessage(playerid,0xFF4500AA,"You have now logged in!");
                            return 1;
                        }
                }
        }
        else // Line 437  receiving the error message, and indentation warning
        {
            SendClientMessage(playerid,0xFF0000AA,"USAGE: /login <Password>");
            return 1;
        }
  }



Re: [ERROR] error 029: invalid expression, assumed zero - EAsT-OAK_510 - 11.01.2013

Post the whole code for the command.


Re: [ERROR] error 029: invalid expression, assumed zero - GwENiko - 11.01.2013

pawn Код:
CMD:login(playerid, params[])
{
    new file[256], pname[MAX_PLAYER_NAME], pass[256];
    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
    format(file, sizeof(file), "MyAdmin/Users/%s.txt", pname);
    if(!dini_Exists(file)) return SendClientMessage(playerid,0xFF0000AA,"You are not registered! Please /register");
    if(pInfo[playerid][Logged] == 1) return SendClientMessage(playerid,0xFF0000AA, "You are already logged in.");
    if(pInfo[playerid][Regged] == 0) return SendClientMessage(playerid,0xFF0000AA,"You are not registered! Please /register");
    if(sscanf(params, "ui", pass)) return SendClientMessage(playerid,0xFF0000AA,"Usage: /login <password>");
    {
            pass = dini_Get(file,"Password");
            if(dini_Exists(file))
            {
                if(strcmp(params,pass,false) != 0)
                        {
                                SendClientMessage(playerid,0xFF4500AA,"Wrong Password!");
                        }
                        else
                        {
                            dini_IntSet(file,"Logged",1);
                            pInfo[playerid][Logged] = 1;
                            pInfo[playerid][Level] = dini_Int(file,"Level");
                            SendClientMessage(playerid,0xFF4500AA,"You have now logged in!");
                            return 1;
                        }
                }
        }
        else
        {
            SendClientMessage(playerid,0xFF0000AA,"USAGE: /login <Password>");
            return 1;
        }
  }



Re: [ERROR] error 029: invalid expression, assumed zero - EAsT-OAK_510 - 11.01.2013

Have you used else if to see if that worked? And also fix up your indentation beginning at line 423.


Re: [ERROR] error 029: invalid expression, assumed zero - GwENiko - 11.01.2013

How should i use else if in this occasion?


Re: [ERROR] error 029: invalid expression, assumed zero - GwENiko - 18.01.2013

Sorry to bump, i still haven't found a way to fix it :/


Re: [ERROR] error 029: invalid expression, assumed zero - LarzI - 18.01.2013

Just remove the else-statement and the brace under "if(sscanf"
You're doing the if check, and you're returning a function. If you were to use else, you would have to put it right beneath the if(sscanf line, but you haven't.

pawn Код:
CMD:login(playerid, params[])
{
    new file[256], pname[MAX_PLAYER_NAME], pass[256];
    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
    format(file, sizeof(file), "MyAdmin/Users/%s.txt", pname);
    if(!dini_Exists(file)) return SendClientMessage(playerid,0xFF0000AA,"You are not registered! Please /register");
    if(pInfo[playerid][Logged] == 1) return SendClientMessage(playerid,0xFF0000AA, "You are already logged in.");
    if(pInfo[playerid][Regged] == 0) return SendClientMessage(playerid,0xFF0000AA,"You are not registered! Please /register");
    if(sscanf(params, "ui", pass))
        return SendClientMessage(playerid,0xFF0000AA,"Usage: /login <password>");

    pass = dini_Get(file,"Password");
    if(dini_Exists(file))
    {
        if(strcmp(params,pass,false) != 0)
            return SendClientMessage(playerid,0xFF4500AA,"Wrong Password!");

        dini_IntSet(file,"Logged",1);
        pInfo[playerid][Logged] = 1;
        pInfo[playerid][Level] = dini_Int(file,"Level");
        SendClientMessage(playerid,0xFF4500AA,"You have now logged in!");
    }
    return 1;
}



Re: [ERROR] error 029: invalid expression, assumed zero - GwENiko - 29.01.2013

It works! thank you.