22.12.2014, 09:32
pawn Code:
new PaymentTimer[MAX_PLAYERS] = {-1, ...}; //At the top of your script.
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER) //They have entered the car as a driver
{
if(GetPlayerVehicleID(playerid) == SpecialVehicleID) //If the vehicle is the specific vehicle that you want
{
PaymentTimer[playerid] = SetTimerEx("PayDriver", 60000, false, "i", playerid); //Set a timer for 1 minute to pay them
}
}
if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER) //They exited a car as a driver
{
KillTimer(PaymentTimer[playerid]); //Kill the payment timer
PaymentTimer[playerid] = -1;
}
return 1;
}
forward PayDriver(playerid);
public PayDriver(playerid)
{
if(GetPlayerVehicleID(playerid) != SpecialVehicleID) //If the player isn't in the vehicle, do not give them money.
{
KillTimer(PaymentTimer[playerid]);
PaymentTimer[playerid] = -1;
}
GivePlayerMoney(playerid, 100); //Give them $100
return 1;
}
https://sampwiki.blast.hk/wiki/OnPlayerStateChange
https://sampwiki.blast.hk/wiki/OnPlayerEnterVehicle
https://sampwiki.blast.hk/wiki/GivePlayerMoney
https://sampwiki.blast.hk/wiki/SetTimerEx