Simple things
#5

To make a command only usable after a set amount of time you need to capture the current tick time and add to it 5 minutes and compare once the player types in the command again.

Example:
pawn Code:
#define DELAY_TIME 5000 //5 seconds in millseconds

#define DELAY_COMMANDS 2 //2 different commands are delayed

#define DELAY_ADVERT 0 //first command is 0

#define DELAY_HEAL 1 //second command is 1 and so on...

new pDelayCommands[MAX_PLAYERS][DELAY_COMMANDS];

public OnPlayerCommandText(playerid,cmdtext)
{
  if(!strcmp(cmdtext[1],"advert",true,6))
  {
    if(pDelayCommands[playerid][DELAY_ADVERT]>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"You cannot do that yet!");
    pDelayCommands[playerid][DELAY_ADVERT]=GetTickCount()+DELAY_TIME;
    new string[200];
    format(string,sizeof(string),"Advertisement: %s",cmdtext[8]);
    SendClientMessageToAll(0xAAAA00FF,string);
    return 1;
  }
  if(!strcmp(cmdtext[1],"heal",true,6))
  {
    if(pDelayCommands[playerid][DELAY_HEAL]>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"You cannot do that yet!");
    pDelayCommands[playerid][DELAY_HEAL]=GetTickCount()+DELAY_TIME;
    SetPlayerHealth(playerid,100.0);
    new string[128];
    GetPlayerName(playerid,string,sizeof(string));
    format(string,sizeof(string),"%s healed himself.",string);
    SendClientMessageToAll(0xAAAA00FF,string);
    return 1;
  }
  return 0;
}
Reply


Messages In This Thread
Simple things - by shoru93 - 15.01.2010, 18:35
Re: Simple things - by DeathOnaStick - 15.01.2010, 18:37
Re: Simple things - by shoru93 - 15.01.2010, 18:46
Re: Simple things - by shoru93 - 15.01.2010, 19:08
Re: Simple things - by Joe Staff - 15.01.2010, 20:37
Re: Simple things - by Perker12345 - 15.01.2010, 21:05
Re: Simple things - by Joe Staff - 15.01.2010, 21:09
Re: Simple things - by Perker12345 - 15.01.2010, 21:12
Re: Simple things - by Joe Staff - 15.01.2010, 21:51
Re: Simple things - by GTAguillaume - 15.01.2010, 21:57
Re: Simple things - by shoru93 - 22.01.2010, 22:20

Forum Jump:


Users browsing this thread: 2 Guest(s)