Mysql timers
#1

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
Reply
#2

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);
Reply
#3

I need to check if the time has passed?
Reply
#4

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
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)