22.12.2014, 09:16
Hello, I wanted to create a job which people will drive in a specific vehicle and after driving
1 minute, It will Pay them 100 dollars for example.
1 minute, It will Pay them 100 dollars for example.
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;
}