SA-MP Forums Archive
Enter vehicle - 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: Enter vehicle (/showthread.php?tid=560193)



Enter vehicle - nezo2001 - 27.01.2015

I want to unable players to enter the vehicle so i added
PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    if(
vehicleid == c1 || vehicleid == c2 || vehicleid == c3 || vehicleid == c4 || vehicleid == c5 || vehicleid == c6 || vehicleid == c7 || vehicleid == c8 || vehicleid == c9 || vehicleid == c10 || vehicleid == c11 || vehicleid == c12 || vehicleid == c13 || vehicleid == c14 || vehicleid == c15)
    {
    if(
PlayerInfo[playerid][pDealer] == 0)
    {
    
SendClientMessage(playeridCOLOR_RED"This car is only for drug dealers you can't drive it");
    return 
0;
    }
    }
    return 
1;

When i enter those vehicles it send to me the message but it allow me to drive the vehicle i want it to unable the player from enter the vehicle.
Please Help !


Re: Enter vehicle - ATGOggy - 27.01.2015

Try this:
PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger

    if(
vehicleid == c1 || vehicleid == c2 || vehicleid == c3 || vehicleid == c4 || vehicleid == c5 || vehicleid == c6 || vehicleid == c7 || vehicleid == c8 || vehicleid == c9 || vehicleid == c10 || vehicleid == c11 || vehicleid == c12 || vehicleid == c13 || vehicleid == c14 || vehicleid == c15
    { 
    if(
PlayerInfo[playerid][pDealer] == 0
    { 
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);
    
SetPlayerPos(playeridxyz);
    
SendClientMessage(playeridCOLOR_RED"This car is only for drug dealers. You can't drive it"); 
    return 
0
    } 
    } 
    return 
1

Returning 0 doesn't prevent him from entering. For more info, see samp wiki and the return function of each callback.


Re: Enter vehicle - Gammix - 27.01.2015

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == c1 || vehicleid == c2 || vehicleid == c3 || vehicleid == c4 || vehicleid == c5 || vehicleid == c6 || vehicleid == c7 || vehicleid == c8 || vehicleid == c9 || vehicleid == c10 || vehicleid == c11 || vehicleid == c12 || vehicleid == c13 || vehicleid == c14 || vehicleid == c15)
    {
    if(PlayerInfo[playerid][pDealer] == 0)
    {
    ClearAnimations(playerid);//clear the player anims
   
    new Float:pos[3];
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    SetPlayerPos(playerid, pos[0], pos[1], pos[2] + 3);//a slight eject
   
    SendClientMessage(playerid, COLOR_RED, "This car is only for drug dealers you can't drive it");
    return 0;
    }
    }
    return 1;
}



Re: Enter vehicle - nezo2001 - 27.01.2015

Thank u