Help /ad command
#1

guys i need to know how to make a loop of 1 minute (you can only use /ad from 1 to 1 minute) heres current code:

Code:
CMD:ad(playerid, params[])
{
  for(new i; i < MAX_PLAYERS; i++)
  {
           new text, pname[25];
           GetPlayerName(playerid, pname, sizeof(pname));
           if(sscanf,params,"s",text) return SendClientMessage(playerid,color_blue,"/ad [text]");
           SendClientMessageToAll(colors_blue,"ad from %s: %s", pname, text);
  }
  return 1;
}
Reply
#2

Here it is:
pawn Code:
forward NoUse(playerid);
new NoUse[MAX_PLAYERS];
CMD:ad(playerid, params[])
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(NoUse[playerid] == 0)
        {
            new text, pname[25];
            GetPlayerName(playerid, pname, sizeof(pname));
            if(sscanf,params,"s",text) return SendClientMessage(playerid,color_blue,"/ad [text]");
            SendClientMessageToAll(colors_blue,"ad from %s: %s", pname, text);
            NoUse[playerid] = 1;
            SetTimer("NoUse", 1000 * 60, false);
        }
        else
            SendClientMessage(playerid, 0xFF0000, "You can only use this command once in a minute");
    }
    return 1;
}
public NoUse(playerid)
{
    NoUse[playerid] = 0;
    return 1;
}
Untested.
Reply
#3

every time i use /ad i shows ad and SERVER;UNKNOWN ERROR, and timer doesnt work(/ad can be used any time),
any ideas?, hole code:

Code:
new NoUse[MAX_PLAYERS];
forward adtime(playerid);
Code:
public adtime(playerid)
{
   	NoUse[playerid] = 0;
	return 1;
}
Code:
CMD:ad(playerid, params[])
{
  if(NoUse[playerid] == 0)
  {
    new text, pname[25], str[64];
    GetPlayerName(playerid, pname, sizeof(pname));
    if(sscanf(params, "s[64]", text))
	{
	  SendClientMessage(playerid, COLOR_LIGHTGREEN,"/ad [text]");
    }
	else
	{
      format(str, sizeof(str),"ad from %s: %s", pname, text);
	  SendClientMessageToAll(COLOR_GREEN, str);
      NoUse[playerid] = 1;
      SetTimer("adtime", 60000, false);
	  return 1;
    }
  }
  else
  {
	  for(new i; i < 61; i--)
	  {
		new str[128];
		format(str, sizeof(str), " %d secs left to place another ad", i);
		SendClientMessage(playerid, COLOR_WHITE, str);
      }
  }
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)