Long timers question - 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: Long timers question (
/showthread.php?tid=628395)
Long timers question -
AndreiWow - 10.02.2017
Hey guys, can you help me with some links regarding long timers or some examples?
For example, I want to make a drug system, and there is a medical drug that will hold off the drug effect for 4 hours?
Do I make something like this?:
PHP код:
new drugtimer[MAX_PLAYERS] = 60;
And a timer that will lower it by 1 every minute?
Re: Long timers question -
Type-R - 10.02.2017
I think you could use a timestamp. You could do something like this:
On getting drug effect:
Код:
DrugTimeStamp[playerid] = gettime() + 14400; // thats 4hours in seconds
Druged[playerid] = 1;
Then if you have a global timer in the server you could do something like this:
Код:
public MinuteTimer()
{
foreach(new i : Player)
{
if(Druged[playerid] == 1)
{
if(DrugTimeStamp[i] < gettime())
{
//Wear off the drugs
}
}
}
return 1;
}
Though if you did this and the player disconnected, and connected 5 hours later the drugs would have worn off. (Also sorry for messy code)