Problem with getting jacked
#1

Hey guys im having a problem with a job im working on, its almost all complete. The only problem now is when the driver gets jacked from their vehicle. i want all the dynamic checkpoints related t othe job to disapear and some variables to reset etc..
How do i get when a player is jacked?
The job vehicle being jacked is: IsDeliveryVeh(vehicleid)
thanks guys
Reply
#2

PHP код:
new DeliveryDuty[MAX_PLAYERS]; // Change this with your own variable
public OnPlayerExitVehicle(playeridvehicleid)
{
if( 
DeliveryDuty[playerid] == // If Is Player on Delivery Duty. Change this with your own variables.
{
DisablePlayerCheckpoint(playerid);
}
return 
1;

Reply
#3

it doesnt work iv already setup that with this:
pawn Код:
if(IsDeliveryVeh(vehicleid))
    {
        new Float:Health;
        GetVehicleHealth(GetPlayerVehicleID(playerid), Health);
        if(Health < 250)
        {
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[0],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[1],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[2],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[3],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[4],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[5],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[6],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[7],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[8],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[9],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[10],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[11],0);
            PlayerInfo[playerid][pDeliveryVeh] = -1;
            DeliverWHpay[playerid] = 0;
            DeliverCounter[playerid] = 0;
            StartingDeliveryJob[playerid] = 0;
            LastDeliveryCP[playerid] = 0;
            DeliveryMission[playerid] = 0;
            SendClientMessage(playerid, COLOR_ORANGE, "Your vehicle is badly damaged. You lost your wage!");
        }
        else
        {
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[0],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[1],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[2],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[3],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[4],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[5],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[6],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[7],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[8],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[9],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[10],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[11],0);
            SendClientMessage(playerid, COLOR_ORANGE, "Don't lose your vehicle or you will lose your wage!");
        }
    }
Reply
#4

You wanted once the player exits from the delivery vehicle the checkpoints to disappear right?

Here
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(IsDeliveryVeh(vehicleid))
    {
        new Float:Health;
        GetVehicleHealth(GetPlayerVehicleID(playerid), Health);
        if(Health < 250)
        {
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[0],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[1],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[2],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[3],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[4],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[5],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[6],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[7],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[8],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[9],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[10],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[11],0);
            PlayerInfo[playerid][pDeliveryVeh] = -1;
            DeliverWHpay[playerid] = 0;
            DeliverCounter[playerid] = 0;
            StartingDeliveryJob[playerid] = 0;
            LastDeliveryCP[playerid] = 0;
            DeliveryMission[playerid] = 0;
            DisablePlayerCheckpoint(playerid);
            SendClientMessage(playerid, COLOR_ORANGE, "Your vehicle is badly damaged. You lost your wage!");
        }
        else
        {
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[0],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[1],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[2],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[3],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[4],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[5],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[6],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[7],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[8],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[9],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[10],0);
            TogglePlayerDynamicCP(playerid, DeliveryJobCP[11],0);
            DisablePlayerCheckpoint(playerid);
            SendClientMessage(playerid, COLOR_ORANGE, "Don't lose your vehicle or you will lose your wage!");
        }
    }
}
Reply
#5

What did you change? Iv got that code under onplayerexit.. When he exits its perfect, but when he gets jacked from the vehicle the markers dont go away...
Reply
#6

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(IsDeliveryVeh(vehicleid))
    {
        new Float:Health;
        GetVehicleHealth(GetPlayerVehicleID(playerid), Health);
        for(new i = 0; i < 12; i++) TogglePlayerDynamicCP(playerid, DeliveryJobCP[i],0);
        DisablePlayerCheckpoint(playerid);
        if(Health < 250)
        {
            PlayerInfo[playerid][pDeliveryVeh] = -1;
            DeliverWHpay[playerid] = 0;
            DeliverCounter[playerid] = 0;
            StartingDeliveryJob[playerid] = 0;
            LastDeliveryCP[playerid] = 0;
            DeliveryMission[playerid] = 0;
            return SendClientMessage(playerid, COLOR_ORANGE, "Your vehicle is badly damaged. You lost your wage!");
        }
        else return SendClientMessage(playerid, COLOR_ORANGE, "Don't lose your vehicle or you will lose your wage!");
    }
}
Shortened the code a little

EDIT:

From the wiki
Quote:

Not called if the player falls off a bike or is removed from a vehicle by other means such as using SetPlayerPos. You must use OnPlayerStateChange and check if their old state is PLAYER_STATE_DRIVER or PLAYER_STATE_PASSENGER.

Reply
#7

Cool misiur But does it affect the player when the vehicle is stolen from another player?
Reply
#8

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate==PLAYER_STATE_ONFOOT
{
now disable all checkpoints
Reply
#9

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    //This will be called always when player changes state from driver to other
    if(oldstate == PLAYER_STATE_DRIVER)
    {
        if(IsDeliveryVeh(PlayerInfo[playerid][pDeliveryVeh])) //There is no vehicleid
        {
            new Float:Health;
            GetVehicleHealth(GetPlayerVehicleID(playerid), Health);
            for(new i = 0; i < 12; i++) TogglePlayerDynamicCP(playerid, DeliveryJobCP[i],0);
            DisablePlayerCheckpoint(playerid);
            if(Health < 250)
            {
                PlayerInfo[playerid][pDeliveryVeh] = -1;
                DeliverWHpay[playerid] = 0;
                DeliverCounter[playerid] = 0;
                StartingDeliveryJob[playerid] = 0;
                LastDeliveryCP[playerid] = 0;
                DeliveryMission[playerid] = 0;
                return SendClientMessage(playerid, COLOR_ORANGE, "Your vehicle is badly damaged. You lost your wage!");
            }
            else return SendClientMessage(playerid, COLOR_ORANGE, "Don't lose your vehicle or you will lose your wage!");
        }
    }
}
Reply
#10

Misiure that worked great, but im getting the:
return SendClientMessage(playerid, COLOR_ORANGE, "Your vehicle is badly damaged. You lost your wage!");

Message everytime I exit the vehicle and am on foot. No matter if I exit myself or get the vehicle and regardless of health stolen..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)