PDA

View Full Version : OnPlayerStateChange


stormchaser206
13/07/2012, 05:57 PM
Hello,
This code isn't removing me from my car:
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.

marcoj
13/07/2012, 05:59 PM
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 <

Vince
13/07/2012, 06:01 PM
Ah, and again someone who can't differentiate between vehicleids and modelids. Funny.
http://wiki.sa-mp.com/wiki/GetVehicleModel

stormchaser206
13/07/2012, 06:07 PM
Ah, and again someone who can't differentiate between vehicleids and modelids. Funny.
http://wiki.sa-mp.com/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 (c) 1997-2006, ITB CompuPhase


4 Errors.

With code:
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 :)