SA-MP Forums Archive
Player cant enter a Tank or A Hydra - 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: Player cant enter a Tank or A Hydra (/showthread.php?tid=415316)



Player cant enter a Tank or A Hydra - California_ - 12.02.2013

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.


Re: Player cant enter a Tank or A Hydra - SilverKiller - 12.02.2013

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


Re: Player cant enter a Tank or A Hydra - DaRk_RaiN - 12.02.2013

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;
}



Re: Player cant enter a Tank or A Hydra - Mr.Anonymous - 12.02.2013

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.