SA-MP Forums Archive
[Tutorial] Random message Tutorial by Toxik - 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 message Tutorial by Toxik (/showthread.php?tid=585917)



Random message Tutorial by Toxik - Toxik - 17.08.2015

So lets start
Creating Arry for random message and adding messages
pawn Код:
//on top of script
#define     COLOR_GREEN     (0x32CD32FF)  // Green color used for Random messages
  new randomMessages[][] =  //here, we're creating the array with the name "randomMessages"
    {
        "MESSAGE 1 ", //this is the text of your first message ------Change the MESSAGE 1 to your own message
        "MESSAGE 2", //this is the text of your second message -------- Change MESSAGE 2 to your own message
        "MESSAGE 3" //this is the text of your third message ---------- Change MESSAGE 3 to your own message
};
Creating Timer
pawn Код:
OnGameModeInit()
{
SetTimer("RandomMessages", 1000*6, true); //here, you're defining a timer with the name "RandomMessages"
return 1;
forwarding the Random message
pawn Код:
forward RandomMessages();
public RandomMessages()
{
    new randomMsg = random(sizeof(randomMessages)); //create a variable "randomMsg" and give it the value of our array we've created ("randomMessages")
//the word "random" is included into PAWN, which will tell the script, to work randomly with the array
    SendClientMessageToAll(COLOR_GREEN, randomMessages[randomMsg]); //this will send the content of our array to EVERYBODY on the server
// the content are strings, and we're using our array "randomMessages" with our created variable "randomMsg" again
}



Re : Random message Tutorial by Toxik - Dutheil - 17.08.2015

There are already lot of tutorials for that.


Re: Re : Random message Tutorial by Toxik - Toxik - 17.08.2015

Quote:
Originally Posted by Dutheil
Посмотреть сообщение
There are already lot of tutorials for that.
Didn't Check out


Re : Random message Tutorial by Toxik - Dutheil - 17.08.2015

https://sampforum.blast.hk/showthread.php?tid=324497
https://sampforum.blast.hk/showthread.php?tid=375921
https://sampforum.blast.hk/showthread.php?tid=401096
https://sampforum.blast.hk/showthread.php?tid=341291
https://sampwiki.blast.hk/wiki/Random_Messages