Removing a player from a specific vehicle.
#1

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);
Reply
#2

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 :')
Reply
#3

if(vehicleid == pilotjobvehicle1 || vehicleid ==pilotjobvehicle2)
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)