pause timer? - 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: pause timer? (
/showthread.php?tid=609794)
pause timer? -
MayaEU - 16.06.2016
Hi everyone, do anyone know how to make that if someone pause the game, it will stop the sweeper timer, so you will get no money while you have tapped/paused the game?
pawn Code:
#include <a_samp>
new stimer;
#define WAIT_TIME 60000
public OnFilterScriptInit()
{
print("[FILTERSCRIPT]Street Sweeping Job has loaded successfully");
return 1;
}
public OnFilterScriptExit()
{
print("[FILTERSCRIPT]Street Sweeping Job has unloaded successfully");
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 574)
{
stimer = SetTimerEx("Sweeping", WAIT_TIME, true, "d", playerid);
SendClientMessage(playerid, 0x58E11EC8, "You are now Street Sweeping to earn money. Drive around and earn money!");
}
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(GetVehicleModel(vehicleid) == 574)
{
KillTimer(stimer);
SendClientMessage(playerid, 0x58E11EC8, "You are no longer doing your Street Sweeping Job!");
}
return 1;
}
forward Sweeping(playerid);
public Sweeping(playerid)
{
new string[128];
new rand = 200 + random(210);
GivePlayerMoney(playerid, rand);
format(string, sizeof(string), "You have received $%d for your Street Sweeping Job!", rand);
SendClientMessage(playerid, 0x58E11EC8, string);
return 1;
}
Re: pause timer? -
MayaEU - 16.06.2016
Also, so when you are paused it will still count, but not give any money, so when you come back to the game, it will start counting money again
Re: pause timer? -
Konstantinos - 16.06.2016
If you have already the pause system then check if the player is not paused and only then give the money. If you however don't have one, search on ****** there are a couple of them or use:
https://sampforum.blast.hk/showthread.php?tid=490436 and "IsPlayerPaused" function.
Re: pause timer? -
MayaEU - 16.06.2016
Or if it is possible to make that it will just not count if the sweeper is not moving?