SA-MP Forums Archive
else thing... - 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: else thing... (/showthread.php?tid=425598)



else thing... - LeeXian99 - 26.03.2013

I was trying to merging this.
pawn Код:
CMD:antifall(playerid,params[])
{
    {
    Act[playerid] = 1;
    SendClientMessage(playerid, 0xFFFF00AA, "Antifall on bike is {00ffff}enabled!");
    }
    else
    {
    Act[playerid] = 0;
    SendClientMessage(playerid, 0xFF000000, "Antifall on bike is {00ffff}disabled!");
    }
    return 1;
}
Error code:
Код:
C:\Users\Kelvin\Desktop\Scripting\gamemodes\racerevolution.pwn(5550) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: else thing... - dusk - 26.03.2013

There has to be "if" if there's an "else"


Re: else thing... - Om3n - 26.03.2013

Код:
CMD:antifall(playerid,params[])
{
    if(Act[playerid] == 0)
    {
    Act[playerid] = 1;
    SendClientMessage(playerid, 0xFFFF00AA, "Antifall on bike is {00ffff}enabled!");
    }
    else
    {
    Act[playerid] = 0;
    SendClientMessage(playerid, 0xFF000000, "Antifall on bike is {00ffff}disabled!");
    }
    return 1;
}
like this...


Re: else thing... - LeeXian99 - 26.03.2013

Quote:
Originally Posted by Om3n
Посмотреть сообщение
Код:
CMD:antifall(playerid,params[])
{
    if(Act[playerid] == 0)
    {
    Act[playerid] = 1;
    SendClientMessage(playerid, 0xFFFF00AA, "Antifall on bike is {00ffff}enabled!");
    }
    else
    {
    Act[playerid] = 0;
    SendClientMessage(playerid, 0xFF000000, "Antifall on bike is {00ffff}disabled!");
    }
    return 1;
}
like this...
Thanks, no rep for you, jks. I will add to you later.X


Re: else thing... - Babul - 26.03.2013

or simpler:
pawn Код:
CMD:antifall(playerid,params[])
{
    Act[playerid]=1-Act[playerid];
    switch(Act[playerid])
    {
        case 0:SendClientMessage(playerid, 0xFF000000, "Antifall on bike is {00ffff}disabled!");
        case 1:SendClientMessage(playerid, 0xFFFF00AA, "Antifall on bike is {00ffff}enabled!");
    }
    return 1;
}



Re: else thing... - Djole1337 - 26.03.2013

Make it bool and you can do something like:

pawn Код:
CMD:antifall(playerid,params[])
{
    Act[playerid] = !Act[playerid];
    SendClientMessage(playerid, Act[playerid] ? ("Antifall activated") : ("Antifall deactivated"));
    return 1;
}