Mysql timers - 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: Mysql timers (
/showthread.php?tid=431546)
Mysql timers -
zT KiNgKoNg - 18.04.2013
I know its not the most descriptive title, But its something...
So i need to make a system that lets say a player uses /rp (ECT: Rep player) it adds a time stamp to database `rep` with the name of the player lets sat `Bob Marston` and a timestamp that i can then use ingame to stop the player using the example command for lets say an hour even if he/she leaves the server.
I've been looking around but nothing seems to solve this problem :P
Re: Mysql timers -
Azazelo - 18.04.2013
Quote:
Originally Posted by zT KiNgKoNg
I know its not the most descriptive title, But its something...
So i need to make a system that lets say a player uses /rp (ECT: Rep player) it adds a time stamp to database `rep` with the name of the player lets sat `Bob Marston` and a timestamp that i can then use ingame to stop the player using the example command for lets say an hour even if he/she leaves the server.
I've been looking around but nothing seems to solve this problem :P
|
Reference:
https://sampforum.blast.hk/showthread.php?tid=129183
For more info read this link.
Код:
new string[256];
new stamp;
stamp = gettime();
format(string,sizeof(string),"INSERT INTO `rep` (`username`, `stamp`) VALUES ('%s', '%i')",PlayerName, stamp);
mysql_query(string);
and for check part:
Код:
new string[256];
format(string,sizeof(string),"SELECT `stamp` FROM `rep` WHERE `username` = '%s'",PlayerName);
mysql_query(string);
Re: Mysql timers -
zT KiNgKoNg - 18.04.2013
I need to check if the time has passed?
Re: Mysql timers -
Azazelo - 18.04.2013
oldTimeStamp is time(stamp) when you hit first time command
secondsToWait is time in seconds that need to pass
timeStampNow is gettime() in this moment(moment of check )
pawn Код:
if((oldTimeStamp + (secondsToWait) ) <= timeStampNow)
{
//time passed
}
else
{
//not passed
}