Remove player from Admin's vehicles - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Remove player from Admin's vehicles (
/showthread.php?tid=241796)
Remove player from Admin's vehicles -
will-56 - 18.03.2011
Hello all, i made a small script to remove players from Admin's vehicles but it doesn't work -_-
Can you tell me what is the problem please ?
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if (IsPlayerInVehicle(playerid, 3))
{
if (IsPlayerAdmin(playerid), = 0))
{
SendClientMessage(playerid, COLOR_RED, "This vehicle is an Admin's vehicle you can't drive it");
RemovePlayerFromVehicle(playerid);
}
}
Re: Remove player from Admin's vehicles -
GsT - 18.03.2011
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(vehicleid == 3 && !IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_RED, "This vehicle is an Admin's vehicle you can't drive it");
RemovePlayerFromVehicle(playerid);
}
return 1;
}
Re : Remove player from Admin's vehicles -
will-56 - 19.03.2011
Thanx but player isn't removed.
Is there a system to freeze player who want enter in Admin's vehicle for 5 seconds ?
Re: Remove player from Admin's vehicles -
JaTochNietDan - 19.03.2011
The problem is that OnPlayerEnterVehicle is called as soon as the person attempts to enter a vehicle. RemovePlayerFromVehicle only works when the person is in the vehicle, but in this case it is being called before the person is even in the vehicle. (Did you also know you can cancel the enter vehicle action, but the callback will still be called?)
So the alternative is to use another method to detect when the player has fully sat in the vehicle, we can do this with OnPlayerStateChange, for example:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER) // Check if the players state has changed to that of a driver
{
if(GetPlayerVehicleID(playerid) == 3 && !IsPlayerAdmin(playerid)) // Only changed the vehicleid part to the GetPlayerVehicleID function because vehicleid is not passed in OnPlayerStateChange, so we need to get it
{
SendClientMessage(playerid, COLOR_RED, "This vehicle is an Admin's vehicle you can't drive it");
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
Note: Moved to Scripting Discussion, you posted in the wrong section.
Re : Remove player from Admin's vehicles -
will-56 - 20.03.2011
Thank a lot