SA-MP Forums Archive
Removing a player from a specific 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: Removing a player from a specific vehicle. (/showthread.php?tid=454695)



Removing a player from a specific vehicle. - rangerxxll - 30.07.2013

So I've made a job, and I'm trying to remove a player from the vehicle when he attempts to enter it without the job. It's working fine, but it happens when I try to enter ANY vehicle.

I haven't scripted for a while, and I'm a bit out of shape. Any help would be appreciated.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == pilotjobvehicle1 || pilotjobvehicle2)
    {
        if(job[playerid] == 0)
        {
            new Float:x, Float:y, Float:z;
            GetPlayerPos(playerid, x, y, z);
            SetPlayerPos(playerid, x, y, z+3);
            SendClientMessage(playerid,-1, "You must have the Pilot Job in order to fly this vehicle.");
            return 1;
        }
    }
    return 1;
}
pawn Код:
pilotjobvehicle1 = CreateVehicle(593,1912.4984,-2241.7793,13.5469,180.3823,0,3, 3000);
    pilotjobvehicle2 = CreateVehicle(593,1932.0745,-2241.7368,13.5469,187.1307, 0, 3, 3000);



Re: Removing a player from a specific vehicle. - itsCody - 30.07.2013

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == pilotjobvehicle1 || vehicleid == pilotjobvehicle2)
    {
        if(job[playerid] == 0)
        {
            new Float:x, Float:y, Float:z;
            GetPlayerPos(playerid, x, y, z);
            SetPlayerPos(playerid, x, y, z+3);
            SendClientMessage(playerid,-1, "You must have the Pilot Job in order to fly this vehicle.");
            RemovePlayerFromVehicle(playerid);
            return 1;
        }
    }
    return 1;
}
Ugh you forgot RemovePlayerFromVehicle(playerid);

I think that's correct :')


Re: Removing a player from a specific vehicle. - jamesbond007 - 30.07.2013

if(vehicleid == pilotjobvehicle1 || vehicleid ==pilotjobvehicle2)


Re: Removing a player from a specific vehicle. - Rillo - 30.07.2013

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == pilotjobvehicle1 || vehicleid == pilotjobvehicle2 && job[playerid] == 0)
    {
        ClearAnimations(playerid, 0);
        SendClientMessage(playerid,-1, "You must have the Pilot Job in order to fly this vehicle.");
    }
    return 1;
}
@itcCody - RemovePlayerFromVehicle won't work because OnPlayerEnterVehicle is called BEFORE the player enters the vehicle, not whilst he's inside it.