Random Client message (not a single line) - 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 Client message (not a single line) (
/showthread.php?tid=363550)
Random Client message (not a single line) -
SnG.Scot_MisCuDI - 28.07.2012
How can i make it send radnomly either the first "sendclientmessages" or the second "sendclientmessages"
I know how to do it if its a single line, but i want it to either send the first portion or the second portion randomly.
Ex:
Either send this:
pawn Код:
SendClientMessage(targetid,0x24FF0AB9, "message");
SendClientMessage(targetid,0x24FF0AB9, "message");
SendClientMessage(targetid,0x24FF0AB9, "message");
SendClientMessage(targetid,0x24FF0AB9, "message");
SendClientMessage(targetid,0xFF00FFFF, "message");
or send this
pawn Код:
SendClientMessage(targetid,0x24FF0AB9, "message2");
SendClientMessage(targetid,0x24FF0AB9, "message2"");
SendClientMessage(targetid,0x24FF0AB9, "message2"");
SendClientMessage(targetid,0x24FF0AB9, "message2"");
SendClientMessage(targetid,0xFF00FFFF, "message2"");
I hope i explained it good enough
Re: Random Client message (not a single line) -
[KHK]Khalid - 28.07.2012
pawn Код:
new randMsg = random(2);
if(randMsg == 0)
{
// Messages
}
else if(randMsg == 1)
{
// Other messages
}
Re: Random Client message (not a single line) -
BlackWolf120 - 28.07.2012
pawn Код:
new Message[][] = //Define your messages
{
{"message1"},
{"message2"},
{"message3"}
//etc.
};
//Randomize it
new randomMSG = random(sizeof(Message)),
string[128];
//Send it (e.g. using a timer)
format(string, sizeof(string),"%s",Message[randomMSG]);
SendClientMessageToAll(0xFFFF00FF, string);
Hope i got you right
Kind regards, wolf.
Re: Random Client message (not a single line) -
Youice - 28.07.2012
This is a simple code which I hope to give ideas or hints to you.
Код:
forward messages(targetid);
public messages(targetid)
{
new RandMessage = random(5);//max number of the messages line is "5"
switch(RandMessage)//now we switch the messages
{
case 1:
{
SendClientMessage(targetid,0x24FF0AB9, "message");
}
case 2:
{
SendClientMessage(targetid,0x24FF0AB9, "message");
}
case 3:
{
SendClientMessage(targetid,0x24FF0AB9, "message");
}
case 4:
{
SendClientMessage(targetid,0x24FF0AB9, "message");
}
case 5:
{
SendClientMessage(targetid,0xFF00FFFF, "message");
}
}
return 1;
}