[Tutorial] Random Messages [Simple]
#1

Hi guys,

Some people have been asking me how to add random messages into your gamemode because
they can't do it. So I'm going to show you how to add it in your script step by step.

You can define any of the below colors into your script.
pawn Code:
#define COLOR_GREEN         0x33AA33AA
#define COLOR_GREY          0xAFAFAFAA
#define COLOR_WHITE         0xFFFFFFAA
#define COLOR_YELLOW        0xFFFF00AA
#define COLOR_BLUE          0x0000BBAA
#define COLOR_ORANGE        0xFF9900AA
#define COLOR_RED           0xCC0000AA
Then you will need to forward the Random Messages function.
pawn Code:
//Forwards//
forward RandomMessages();
We will be defining the random messages in this function.
pawn Code:
//Random Messages//
new RandomMessages[][] =
{
       "Message 1 (Change this)",
       "Message 2 (Change this)",
       "Message 3 (Change this)"
};
Then we will need to set a timer for the Random Messages and the timer will
be placed below the public OnGameModeInit() function:
pawn Code:
public OnGameModeInit()
{
     SetTimer("RandomMessages",95000,1);
     return 1;
}
You will need to find an empty place in your script to add this callback.
This will get the Random Messages from above and send them as a client message.
pawn Code:
public RandomMessages()
{
     SendClientMessageToAll(COLOR_GREEN, RandomMessages[random(sizeof(RandomMessages))];
     return 1;
}
If this works for you, please feel free to rep me.

- Sean aka Sniperwars
Reply


Messages In This Thread
Random Messages [Simple] - by sniperwars - 27.03.2012, 14:32
Re: Random Messages [Simple] - by emokidx - 27.03.2012, 14:38
Re: Random Messages [Simple] - by Nicholas. - 27.03.2012, 14:43
Re : Random Messages [Simple] - by mehdi-jumper - 27.03.2012, 16:16
Re: Random Messages [Simple] - by captainjohn - 27.03.2012, 16:27
Re: Random Messages [Simple] - by Twisted_Insane - 27.03.2012, 16:45
Re: Random Messages [Simple] - by Hiddos - 27.03.2012, 16:50
Re: Random Messages [Simple] - by Twisted_Insane - 27.03.2012, 16:52
Re: Random Messages [Simple] - by Basssiiie - 27.03.2012, 16:54
Re: Random Messages [Simple] - by emokidx - 27.03.2012, 16:56
Re: Random Messages [Simple] - by Hiddos - 27.03.2012, 16:59
Re: Random Messages [Simple] - by FireCat - 27.03.2012, 17:11
Re: Random Messages [Simple] - by Dripac - 27.03.2012, 18:21
Re: Random Messages [Simple] - by sniperwars - 27.03.2012, 19:22
Re: Random Messages [Simple] - by shitbird - 27.03.2012, 20:17
Re: Random Messages [Simple] - by Basssiiie - 29.03.2012, 13:18
Re: Random Messages [Simple] - by $$inSane - 02.05.2012, 10:44
Re: Random Messages [Simple] - by RedWingz - 18.05.2012, 21:47
Re: Random Messages [Simple] - by 2xRichard - 14.07.2017, 13:01
Re: Random Messages [Simple] - by H4RR1s - 14.07.2017, 13:11
Re: Random Messages [Simple] - by xMoBi - 14.07.2017, 13:24
Re: Random Messages [Simple] - by 2xRichard - 19.08.2017, 05:51

Forum Jump:


Users browsing this thread: 3 Guest(s)