26.07.2009, 09:34
It's pretty simple and can be done in many different ways. While reading your posts I had thought of a pretty cool method. Now for the benefit for everyone else I will create the snippet.
This will allow a player to do up to 4 but then only let them do 1 per second, which that 1 will roll over to the next second (allowing a build up of 4 again).
Enjoy it!
pawn Код:
#define MAX_COMMAND_FREQUENCY 4 //effects how many times a player can type a command without being stopped
new PlayerCmdFrq[MAX_PLAYERS]; //Player Command Frequency
forward UpdateCmdFreq();
public OnPlayerCommandText(playerid,cmdtext[])
{
PlayerCmdFrq[playerid]++;
if(PlayerCmdFrq[playerid]>MAX_COMMAND_FREQUENCY)
{
SendClientMessage(playerid,0xFF0000FF,"You can't use commands so often.");
return 1;
}
//Then your commands and everything else go here
}
public OnGameModeInit()
{
SetTimer("UpdateCmdFreq",2000,1);
}
public UpdateCmdFreq()
{
for(new playerid;playerid<MAX_PLAYERS;playerid++)
{
if(PlayerCmdFrq[playerid])PlayerCmdFrq[playerid]--;
}
}
Enjoy it!