12.01.2015, 07:47
Basically when you type the function gettime(); without callbacks you will get the current unix timestamp you add 2 hours to the current time then if the player types this command again you'll have to see if it has passed 7200 MS (2 hours) yet or not.
pawn Код:
new jTime[MAX_PLAYERS]; //
CMD:examplecmd(playerid,params[])
{
new timestamp = gettime();
if(timestamp > jTime[playerid])
{
jTime[playerid] = gettime()+3600*2; // 1hour: 3600 ms
printf(" Typed /examplecmd. gettime stored in jTime ");
}
else
{
new hoursleft = (jTime[playerid]-timestamp)/3600; // 1 hour is 3600 MS as I've stated above, therefore dividing jTime[playerid]-timestamp will result into the hours left.
printf("Current time: %i | 2 Hours Added: %i | Hours left for you to type this command again %i.",timestamp,jTime[playerid],hoursleft);
}
}