A question - 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: A question (
/showthread.php?tid=524690)
A question -
ilay65 - 07.07.2014
How can I do that if a player enters a vehicle and is not an admin then it would get him out of the car?
Re: A question -
rappy93 - 08.07.2014
What do you mean not an anim ?
Re : A question -
S4t3K - 08.07.2014
He wrote Admin. Nvm.
Try a combination of
OnPlayerStateChange +
IsPlayerAdmin +
RemovePlayerFromVehicle. It should work as a charm !
Re: A question -
Threshold - 08.07.2014
Example:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate) //Called when a player changes state
{
if(newstate & PLAYER_STATE_DRIVER) //If player enters as a driver in a vehicle
{
if(!IsPlayerAdmin(playerid)) //If the player is not an admin, replace this with your admin variable.
{
RemovePlayerFromVehicle(playerid); //Remove the player from the vehicle
}
}
return 1;
}
The code above will only work if the player is not an RCON Administrator, so you will have to replace '!IsPlayerAdmin(playerid)' with your own admin variable, eg. 'PlayerInfo[playerid][AdminLevel] < 1'
Sources:
https://sampwiki.blast.hk/wiki/OnPlayerStateChange
https://sampwiki.blast.hk/wiki/RemovePlayerFromVehicle
Re: A question -
gtasarules14 - 08.07.2014
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new v = GetPlayerVehicleID(playerid);
if(v = your vehicleid)
{
if(PlayerInfo[playerid][pAdmin] > 1)
{
SendClientMessage(playerid, -1, "You are not a Admin");
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
This is my accurate bet

, and these guys wrote it better than me

lol
Re : A question -
S4t3K - 08.07.2014
@Threshold : Why do you use the logical comparator here ? A simple "==" should work perfectly since a player can't have two states at once.
Re: A question -
Threshold - 08.07.2014
Actually, this... 'logical comparator' (?) is more efficient.
'if(newstate & PLAYER_STATE_DRIVER)' does not mean 'if(newstate && newstate == PLAYER_STATE_DRIVER)'.
It's a more efficient way of doing:
'if(newstate == PLAYER_STATE_DRIVER)'.