SA-MP Forums Archive
Random messages with string - 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: Random messages with string (/showthread.php?tid=476521)



Random messages with string - Lorenzosdm - 18.11.2013

So i have a simple random message system made, But my question is now how can i put strings in the random messages.

Here the code to explain more:

pawn Код:
new randominf[][] =
    {
        "[BOT]Do you know that %s %d kills have!",
        "[BOT]Do you know that %s registered on %s!",
        "[BOT]Do you know that %s is member level %d!"
    };
[BOT]Do you know that %s %d kills have! = Than is the %s the name and the %d the kills but how can i get the kills and the name in the random messages.




Already thanks for the help!


Re: Random messages with string - Jefff - 18.11.2013

pawn Код:
new str[128];
new rand = random(sizeof(randominf));
switch(rand)
{
    case 0: format(str,sizeof(str),randominf[rand],GetName(giveplayerid),kills[giveplayerid]);
    case 1: format(str,sizeof(str),randominf[rand],GetName(giveplayerid),something);
    default: format(str,sizeof(str),randominf[rand],GetName(giveplayerid),level[giveplayerid]);
}
SendClientMessageToAll(-1,str);



Re: Random messages with string - Lorenzosdm - 18.11.2013

worked thanks! +rep