PDA

View Full Version : help with showing remaining time


alvin6
26/06/2019, 07:51 PM
Hey guys i added anti command spam in server and i did set its time to 60 seconds but i want something to show player remaining time in error, current error is You must wait 60 seconds to use the command again so instead of 60 seconds i want to show current remaining to use command again

Can anyone help please

new
Player_ACS[MAX_PLAYERS];

// OnPlayerConnect:
Player_ACS[playerid] = 0;

// command here
if (gettime() - Player_ACS[playerid] < 3) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"You must wait 60 seconds to use command again.");
// code..
Player_ACS[playerid] = gettime();

Plastikmensch
26/06/2019, 08:03 PM
Time until command works again - current time should do the trick and give the remaining time in seconds.
Instead of returning SendClientMessage you would have to format the message before.

if(gettime() < timeUntilCommandWorksAgain)
{
new msg[148];
format(msg,sizeof(msg), "You have to wait %i seconds", timeUntilCommandWorksAgain-gettime());
SendClientMessage(...);
return 1;
}