01.04.2014, 16:40
Allright, here's some pseudo-code:
This should give you a rough idea of what i mean.
Код:
new commandCooldown[MAX_PLAYERS]; // The variable that tells us if the cooldown is active. OnPlayerConnect(playerid) { commandCooldown[playerid] = 0; // Disable the cooldown when the player joins the game. } CMD:myCooldownCommand(params[], playerid) { if(commandCooldown[playerid] == 0) { // Do what the command needs to do. // Start a timer here for how long it needs to cool down. // Also, set the cooldown to 1. commandCooldown[playerid] = 1; } else { // Display an error, eg. "You must wait blah blah". } } myTimerFunction(playerid) { // Stop the timer and disable the cooldown. commandCooldown[playerid] = 0; }