29.04.2016, 08:41
Hey guys. I made command /askq (to ask question to online admins). Now, how can i make timer so one player can send /askq command every 2 minutes not every second. Thank you

if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount()) return SendClientMessage(playerid,0xFF0000FF,"You must wait before using a command");
SetPVarInt(playerid,"CMDABUSE",GetTickCount()+5000);
#define QUESTION_DELAY 120000 // 120000 = 2 minutes in ms new PlayerLastQuestion[MAX_PLAYERS];
PlayerLastQuestion[playerid] = GetTickCount() - QUESTION_DELAY; // Set the last tick to now minus DELAY
if(GetTickCount() - PlayerLastQuestion[playerid] < QUESTION_DELAY) return SendClientMessage(playerid, 0xFF0000FF, "Sorry, you can only ask a question every 2 minutes!"); PlayerLastQuestion[playerid] = GetTickCount(); // Do ask stuff
CMD:ask(playerid,params[]) {
new question[128];
new asker[MAX_PLAYER_NAME], str[128];
if (sscanf(params, "s", question)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /ask <ID>");
GetPlayerName(playerid, asker, sizeof(asker));
format(str, sizeof(str), "||Question|| %s(%d) asks: %s",asker, question);
MessageToAdmins(COLOR_WHITE,str);
return SendClientMessage(playerid,yellow, "Your question has been sent to online administrators.");
}