A question
#1

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?
Reply
#2

What do you mean not an anim ?
Reply
#3

He wrote Admin. Nvm.

Try a combination of OnPlayerStateChange + IsPlayerAdmin + RemovePlayerFromVehicle. It should work as a charm !
Reply
#4

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
Reply
#5

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
Reply
#6

@Threshold : Why do you use the logical comparator here ? A simple "==" should work perfectly since a player can't have two states at once.
Reply
#7

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)'.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)