ASK CMD
#5

Allright, here's some pseudo-code:

Код:
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;
}
This should give you a rough idea of what i mean.
Reply


Messages In This Thread
ASK CMD - by [IND]Crazy - 01.04.2014, 16:27
Re: ASK CMD - by Sithis - 01.04.2014, 16:30
Re: ASK CMD - by [IND]Crazy - 01.04.2014, 16:32
Re: ASK CMD - by CroM256 - 01.04.2014, 16:36
Re: ASK CMD - by Sithis - 01.04.2014, 16:40
Re: ASK CMD - by Konstantinos - 01.04.2014, 17:15
Re: ASK CMD - by [IND]Crazy - 01.04.2014, 17:30

Forum Jump:


Users browsing this thread: 5 Guest(s)