SA-MP Forums Archive
Help /ad command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help /ad command (/showthread.php?tid=316024)



Help /ad command - ttloko2 - 05.02.2012

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;
}



Re: Help /ad command - thimo - 05.02.2012

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.


Re: Help /ad command - ttloko2 - 06.02.2012

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;
}