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



OnPlayerStateChange - stormchaser206 - 13.07.2012

Hello,
This code isn't removing me from my car:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(vehicleid == 432 && IsEngineer[playerid] != 1 && IsVIP[playerid] != && IsOwner[playerid] != 1)
        {
            SendClientMessage(playerid, COLOR_RED, "ERROR: You must be an engineer or owner to drive this.");
            RemovePlayerFromVehicle(playerid);
        }

        if(vehicleid == 425 && IsPilot[playerid] != 1 && IsVIP[playerid] != 1 && IsOwner[playerid] != 1)
        {
            SendClientMessage(playerid, COLOR_RED, "ERROR: You must be a pilot or owner to pilot this.");
            RemovePlayerFromVehicle(playerid);
        }
       
        if(vehicleid == 447 && IsPilot[playerid] != 1 && IsOwner[playerid] != 1)
        {
            SendClientMessage(playerid, COLOR_RED, "ERROR: You must be a pilot or owner to pilot this.");
            RemovePlayerFromVehicle(playerid);
        }
       
        if(vehicleid == 520 && IsPilot[playerid] != 1 && IsOwner[playerid] != 1)
        {
            SendClientMessage(playerid, COLOR_RED, "ERROR: You must be a pilot or owner to pilot this.");
            RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}
When i am not pilot, owner, or engineer.
Is there any reason for this?
Thanks.


Re: OnPlayerStateChange - marcoj - 13.07.2012

Just a suggestion, not sure if it might work.
change for ie. IsEngineer[playerid] != 1 to IsEngineer[playerid] <= 1

do that at everything you use, so change the ! to a <


Re: OnPlayerStateChange - Vince - 13.07.2012

Ah, and again someone who can't differentiate between vehicleids and modelids. Funny.
https://sampwiki.blast.hk/wiki/GetVehicleModel


Re: OnPlayerStateChange - stormchaser206 - 13.07.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
Ah, and again someone who can't differentiate between vehicleids and modelids. Funny.
https://sampwiki.blast.hk/wiki/GetVehicleModel
Now, i got 4 errors:
Код:
C:\Users\Keegan\Desktop\gamemodes\MWFFA.pwn(401) : error 029: invalid expression, assumed zero
C:\Users\Keegan\Desktop\gamemodes\MWFFA.pwn(401) : warning 215: expression has no effect
C:\Users\Keegan\Desktop\gamemodes\MWFFA.pwn(401) : error 001: expected token: ";", but found ")"
C:\Users\Keegan\Desktop\gamemodes\MWFFA.pwn(401) : error 029: invalid expression, assumed zero
C:\Users\Keegan\Desktop\gamemodes\MWFFA.pwn(401) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
With code:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(GetVehicleModel(vehicleid) == 432 && IsEngineer[playerid] != 1 && IsVIP[playerid] != && IsOwner[playerid] != 1)
        {
            SendClientMessage(playerid, COLOR_RED, "ERROR: You must be an engineer or owner to drive this.");
            RemovePlayerFromVehicle(playerid);
        }

        if(GetVehicleModel(vehicleid) == 425 && IsPilot[playerid] != 1 && IsVIP[playerid] != 1 && IsOwner[playerid] != 1)
        {
            SendClientMessage(playerid, COLOR_RED, "ERROR: You must be a pilot or owner to pilot this.");
            RemovePlayerFromVehicle(playerid);
        }
       
        if(GetVehicleModel(vehicleid) == 447 && IsPilot[playerid] != 1 && IsOwner[playerid] != 1)
        {
            SendClientMessage(playerid, COLOR_RED, "ERROR: You must be a pilot or owner to pilot this.");
            RemovePlayerFromVehicle(playerid);
        }
       
        if(GetVehicleModel(vehicleid) == 520 && IsPilot[playerid] != 1 && IsOwner[playerid] != 1)
        {
            SendClientMessage(playerid, COLOR_RED, "ERROR: You must be a pilot or owner to pilot this.");
            RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}
[B]EDIT: I got it working (I forgot an extra letter). Thanks