new DeliveryDuty[MAX_PLAYERS]; // Change this with your own variable
public OnPlayerExitVehicle(playerid, vehicleid)
{
if( DeliveryDuty[playerid] == 1 ) // If Is Player on Delivery Duty. Change this with your own variables.
{
DisablePlayerCheckpoint(playerid);
}
return 1;
}
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!");
}
}
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!");
}
}
}
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!");
}
}
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. |
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!");
}
}
}