Random Client message (not a single line)
#1

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
Reply
#2

pawn Код:
new randMsg = random(2);
if(randMsg == 0)
{
    // Messages
}
else if(randMsg == 1)
{
    // Other messages
}
Reply
#3

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.
Reply
#4

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


Forum Jump:


Users browsing this thread: 2 Guest(s)