[Tutorial] Random message Tutorial by Toxik
#1

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


Messages In This Thread
Random message Tutorial by Toxik - by Toxik - 17.08.2015, 19:37
Re : Random message Tutorial by Toxik - by Dutheil - 17.08.2015, 20:01
Re: Re : Random message Tutorial by Toxik - by Toxik - 17.08.2015, 20:35
Re : Random message Tutorial by Toxik - by Dutheil - 17.08.2015, 20:37

Forum Jump:


Users browsing this thread: 1 Guest(s)