SA-MP Forums Archive
How to make a advertise 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to make a advertise command (/showthread.php?tid=218954)



How to make a advertise command - Matej_ - 31.01.2011

How to make a advertise command, here's example:

/advertise Selling infernus for 50.000$ 15423 < phone number

so it will look like this:

Selling infernus for 50.000$ (phone number 15423) Matej_


Re: How to make a advertise command - Rock18 - 31.01.2011

Code:
if(strcmp(cmd, "/ad", true) == 0)
    {
      new message[256];
      new playername[MAX_PLAYER_NAME];
      strmid(message, cmdtext, 3, strlen(cmdtext));
      GetPlayerName(playerid, playername, sizeof(playername));
      if(!strlen(message))
      {
      SendClientMessage(playerid, 0xFF0606FF, "|| Use /ad [text] ||");
      }
      else
      {
         format(string, sizeof(string), "{FFFFFF}[RadioZu]{F81414} %s {6EF83C}|Message sent by{B700FF} %s {F81414}(playerid:%d) pm me!",message, playername, playerid);
         printf(string);
         SendClientMessageToAll(0xADFF2FAA, string);
         GivePlayerMoney(playerid,-2000);
      }
      return 1;
    }



Re: How to make a advertise command - THE_KNOWN - 31.01.2011

what command processor are you using?

this is zcmd:

CMD:advertise(playerid, params[])
{
new adv[128];
if(sscanf(params,"s",adv)) return SendClientMessage(playerid, red, "USAGE:/advertise [msg]");
SendClientMessageToAll(playerid, some_color, adv);
return 1;
}


Re: How to make a advertise command - HyperZ - 31.01.2011

Use sscanf and zcmd xD

pawn Code:
CMD:advertise( playerid, params[ ] )
{
    new string[ 128 ], pName[ MAX_PLAYER_NAME ];
    GetPlayerName(playerid, pName, sizeof(pName));
    new item[ 66 ], Price, PH;
    if(sscanf(params, "s[65]dd",item, Price, PH)) return SendClientMessage(playerid, -1, "Usage: /advertise [Item] [Price] [Phone Number]");
    format(string, sizeof(string), "Selling %s for %d$  (Phone Number: %d) %s", item, Price, PH, pName);
    SendClientMessageToAll(-1,string);
    return 1;
}



Re: How to make a advertise command - Matej_ - 31.01.2011

Ok, thanks guys.


Re: How to make a advertise command - [03]Garsino - 31.01.2011

Quote:
Originally Posted by THE_KNOWN
View Post
what command processor are you using?

this is zcmd:

CMD:advertise(playerid, params[])
{
new adv[128];
if(sscanf(params,"s",adv)) return SendClientMessage(playerid, red, "USAGE:/advertise [msg]");
SendClientMessageToAll(playerid, some_color, adv);
return 1;
}
Actually, if you only have 1 parameter and it is a string then you don't need to use sscanf for it, you can just use params[]


Re: How to make a advertise command - THE_KNOWN - 31.01.2011

oh thanks garsino =]