SA-MP Forums Archive
[HELP] else 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: [HELP] else problem (/showthread.php?tid=496996)



[HELP] else problem - V4at - 24.02.2014

Here you can see else:

pawn Код:
else
{
   SendClientMessage(playerid,red,"You can't use this command!");
}
And on this script shows error:

Код:
error 029: invalid expression, assumed zero
How to fix that?

Code:

pawn Код:
new cartype = GetPlayerVehicleID(playerid);
  new State=GetPlayerState(playerid);
  {
    if(GetPVarInt(playerid, "Admin") >= 1)
    {
        if(State!=PLAYER_STATE_DRIVER)
        {
            TogglePlayerControllable(playerid,0); // Freeze the player
            SetTimerEx("Freeze", 2000, false, "i", playerid); // Timer for 4 seconds (not repeating timer, only called on the command)
            SetPlayerPos(playerid,-200.9151,61.5312,5.2272);
            GameTextForPlayer(playerid,"~r~Admin base!",2500,1);
            return 1;
        }
        else if(IsPlayerInVehicle(playerid, cartype) == 1)
        {
            TogglePlayerControllable(playerid,0); // Freeze the player
            SetTimerEx("Freeze", 2000, false, "i", playerid); // Timer for 4 seconds (not repeating timer, only called on the command)
            SetVehiclePos(cartype,-200.9151,61.5312,5.2272);
            SetVehicleZAngle(cartype,91);
            GameTextForPlayer(playerid,"~r~Admin Base!",2500,1);
            return 1;
        }
        else
        {
            TogglePlayerControllable(playerid,0); // Freeze the player
            SetTimerEx("Freeze", 2000, false, "i", playerid); // Timer for 4 seconds (not repeating timer, only called on the command)
            SetPlayerPos(playerid,-200.9151,61.5312,5.2272);
        }
            GameTextForPlayer(playerid,"~r~Admin Base!",2500,1);
            return 1;
        }
    }
    /*else
    {
        SendClientMessage(playerid,red,"You can't use this command!");
    }*/

    return 1;
}



Respuesta: [HELP] else problem - CuervO - 24.02.2014

Why do you open up a bracket here? It messes up with everything.

Код:
new cartype = GetPlayerVehicleID(playerid);
  new State=GetPlayerState(playerid);
  {



Re: [HELP] else problem - DexterC - 24.02.2014

pawn Код:
new cartype = GetPlayerVehicleID(playerid);
        new State=GetPlayerState(playerid);
        if(GetPVarInt(playerid, "Admin") >= 1)
        {
            if(State!=PLAYER_STATE_DRIVER)
            {
                TogglePlayerControllable(playerid,0); // Freeze the player
                SetTimerEx("Freeze", 2000, false, "i", playerid); // Timer for 4 seconds (not repeating timer, only called on the command)
                SetPlayerPos(playerid,-200.9151,61.5312,5.2272);
                GameTextForPlayer(playerid,"~r~Admin base!",2500,1);
                return 1;
            }
            else if(IsPlayerInVehicle(playerid, cartype) == 1)
            {
                TogglePlayerControllable(playerid,0); // Freeze the player
                SetTimerEx("Freeze", 2000, false, "i", playerid); // Timer for 4 seconds (not repeating timer, only called on the command)
                SetVehiclePos(cartype,-200.9151,61.5312,5.2272);
                SetVehicleZAngle(cartype,91);
                GameTextForPlayer(playerid,"~r~Admin Base!",2500,1);
                return 1;
            }
            else
            {
                TogglePlayerControllable(playerid,0); // Freeze the player
                SetTimerEx("Freeze", 2000, false, "i", playerid); // Timer for 4 seconds (not repeating timer, only called on the command)
                SetPlayerPos(playerid,-200.9151,61.5312,5.2272);
            }
            GameTextForPlayer(playerid,"~r~Admin Base!",2500,1);
        }
        else
        {
            SendClientMessage(playerid,red,"You can't use this command!");
        }



Re: [HELP] else problem - Beckett - 24.02.2014

As CuervO stated you don't need to open a bracket there it's useless.


Re: [HELP] else problem - V4at - 24.02.2014

Okay, show me a correctly code ://


Re: [HELP] else problem - DexterC - 24.02.2014

Quote:
Originally Posted by V4at
Посмотреть сообщение
Okay, show me a correctly code ://
Try the code that I posted and see if it works. As Cuerv0 stated you missed a bracket there and also another un-needed one near the bottom.


Re: [HELP] else problem - V4at - 24.02.2014

Something is wrong, if player is admin, he can't also use this command..