How do I set vehicle to give money every minute for example - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How do I set vehicle to give money every minute for example (
/showthread.php?tid=552010)
How do I set vehicle to give money every minute for example -
davidstyle1125 - 22.12.2014
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.
Re: How do I set vehicle to give money every minute for example -
Threshold - 22.12.2014
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
Re: How do I set vehicle to give money every minute for example -
ThomasEvil - 28.05.2017
Hello,
i did just the same like you did but it doesnt work. The code is without errors but in the game i give me 0 money in the vehicle... Is there any other solution for this? Or anybody know where is the problem in this code? Thanks