SA-MP Forums Archive
[Tutorial] Random Messages - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Random Messages (/showthread.php?tid=375921)



Random Messages - Dare Devil..... - 08.09.2012

Okay today I will show you how can you make Random Messages.
Lets Begin!

The first step you will do to make random messages is this.
pawn Code:
new RandomMSG[][] =
{
    "Random Tutorial Message 1",//This is the first message it will send,You ca change it to any thing you want.
    "Random Tutorial Message 2",//Second Message
    "Random Tutorial Message 3",//Third Message
    "Random Tutorial Message 4"//Fourth Message
};
I added 4 messages here you can add as many as you want but after every message you need to make a
Code:
,
and you do not have to do this for last one.

Under on gamemode init you need to set timer like this
pawn Code:
SetTimer("SendMSG", 30000, true);
Timer is in miliseconds so 30000 is 30 seconds for 1 minute you can use 60000 and so on.

You need to forward this to make it work like this.
pawn Code:
forward SendMSG();
Now just you need to add callback of this its just sending the message to player.
pawn Code:
public SendMSG()
{
    new randMSG = random(sizeof(RandomMSG));
    SendClientMessageToAll(-1, RandomMSG[randMSG]);
}
I hope you have learned something from this.


Re: Random Messages - xMCx - 08.09.2012

easy but useful , thanks


Re: Random Messages - Dare Devil..... - 08.09.2012

Thankyou.


Re: Random Messages - leonardo1434 - 08.09.2012

https://sampwiki.blast.hk/wiki/Random_Messages
copied from samp wiki,pathetic.


Re: Random Messages - TaLhA XIV - 08.09.2012

You failed to explain the tutorial.Like this part:
pawn Code:
public SendMSG()
{
    new randMSG = random(sizeof(RandomMSG));
    SendClientMessageToAll(-1, RandomMSG[randMSG]);
}
This a tutorial for newbies so newbies would not be able to understand what they just saw.All in all,a bad tutorial.