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



Car error - ShoortyFl - 21.06.2014

trying to forbid players that are not in the faction to enter a car, and its not working.

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_PASSENGER)
    {
        new v = GetPlayerVehicleID(playerid);
        
        if(VehPD(v) && PI[playerid][Member] != 1 && PI[playerid][Leader] != 1)
        {
			SCM(playerid, GREY, "You don't have the keys");
			RemovePlayerFromVehicle(playerid);
		}
  		else if(VehNSA(v) && PI[playerid][Member] != 2 && PI[playerid][Leader] != 2)
        {
			SCM(playerid, GREY, "You don't have the keys");
			RemovePlayerFromVehicle(playerid);
		}
	}
	return 1;
}



Re: Car error - RenovanZ - 21.06.2014

Why dont use OnPlayerEnterVehicle ?
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(!ispassenger)
    {
        if(VehPD(vehicleid) && PI[playerid][Member] != 1 && PI[playerid][Leader] != 1)
        {
            SCM(playerid, GREY, "You don't have the keys");
            RemovePlayerFromVehicle(playerid);
        }
        else if(VehNSA(vehicleid) && PI[playerid][Member] != 2 && PI[playerid][Leader] != 2)
        {
            SCM(playerid, GREY, "You don't have the keys");
            RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}