Player cant enter a Tank or A Hydra
#1

Hi i own a very popular gang war server it gets a full server daily. Now the players are very noob all they want is hydra's seasparrow's and tank's so I want somthing to block that. i Told my admins to ban every person who gets in a illegal vehicle.

Heres my code:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(vehicleid) == 520 )
{
    if(GetPlayerScore(playerid) < 1000 )
    {
        SendClientMessage(playerid,0xFF0000FF,"You cant drive this vehicle you noob");
        RemovePlayerFromVehicle( playerid );
    }
}
if(GetVehicleModel(vehicleid) == 432 )
{
    if(GetPlayerScore(playerid) < 1000 )
    {
        SendClientMessage(playerid,0xFF0000FF,"You cant drive this vehicle you noob");
        RemovePlayerFromVehicle( playerid );
    }
}
    return 1;
}
[b]But somehow It doesnt eject them. it just shows the message.

I really need help with this. Thank you.
Reply
#2

Quote:

Note: This function will not work when used in OnPlayerEnterVehicle because the player isn't in the vehicle yet at the time the callback is called. Suggested using OnPlayerStateChange instead.

Source: https://sampwiki.blast.hk/wiki/RemovePlayerFromVehicle
Reply
#3

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
    new vehicleid = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleid) == 520 && GetPlayerScore(playerid) < 1000)
    {
        SendClientMessage(playerid,0xFF0000FF,"You cant drive this vehicle you noob");
        RemovePlayerFromVehicle(playerid);
    }
    if(GetVehicleModel(vehicleid) == 432  && GetPlayerScore(playerid) < 1000 )
    {
        SendClientMessage(playerid,0xFF0000FF,"You cant drive this vehicle you noob");
        RemovePlayerFromVehicle( playerid );
    }
}
return 1;
}
Reply
#4

Use something like:

pawn Код:
if(GetVehicleModel(vehicleid) == 520 || 432 )
{
    if(GetPlayerScore(playerid) < 1000 )
    {
        SendClientMessage(playerid,0xFF0000FF,"You cant drive this vehicle you noob");
        RemovePlayerFromVehicle( playerid );
    }
}
That checks both vehicle together. Easy and short.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)