How do I set vehicle to give money every minute for example
#2

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;
}
References:
https://sampwiki.blast.hk/wiki/OnPlayerStateChange
https://sampwiki.blast.hk/wiki/OnPlayerEnterVehicle
https://sampwiki.blast.hk/wiki/GivePlayerMoney
https://sampwiki.blast.hk/wiki/SetTimerEx
Reply


Messages In This Thread
How do I set vehicle to give money every minute for example - by davidstyle1125 - 22.12.2014, 09:16
Re: How do I set vehicle to give money every minute for example - by Threshold - 22.12.2014, 09:32
Re: How do I set vehicle to give money every minute for example - by ThomasEvil - 28.05.2017, 17:42

Forum Jump:


Users browsing this thread: 1 Guest(s)