SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 27/03/2012, 03:32 PM   #1
sniperwars
Huge Clucker
 
Join Date: Jan 2011
Location: Under your bed.
Posts: 444
Reputation: 22
Default Random Messages [Simple]

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.
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.
Code:
//Forwards//
forward RandomMessages();

We will be defining the random messages in this function.
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:
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.
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
__________________

Last edited by sniperwars; 21/04/2012 at 10:05 AM.
sniperwars is offline   Reply With Quote
Old 27/03/2012, 03:38 PM   #2
emokidx
Gangsta
 
emokidx's Avatar
 
Join Date: Jul 2011
Posts: 555
Reputation: 63
Default Re: Random Messages [Simple]

i don't see the thing called explanation.
emokidx is offline   Reply With Quote
Old 27/03/2012, 03:43 PM   #3
Nicholas.
Guest
 
Posts: n/a
Default Re: Random Messages [Simple]

Simple but it's okay.

Someone already made a tutorial like this.
  Reply With Quote
Old 27/03/2012, 05:16 PM   #4
mehdi-jumper
High-roller
 
mehdi-jumper's Avatar
 
Join Date: Sep 2011
Location: New-Zealand
Posts: 1,878
Reputation: 51
Default Re : Random Messages [Simple]

This isn't a tutorial, you just past the code and say add this^^ 0/10
mehdi-jumper is offline   Reply With Quote
Old 27/03/2012, 05:27 PM   #5
captainjohn
Huge Clucker
 
captainjohn's Avatar
 
Join Date: Jul 2010
Location: United Kingdom
Posts: 421
Reputation: 29
Default Re: Random Messages [Simple]

This is just copied from a filterscript.

When making a tutorial you should explain in detail why and how you do it.
captainjohn is offline   Reply With Quote
Old 27/03/2012, 05:45 PM   #6
Twisted_Insane
Gangsta
 
Twisted_Insane's Avatar
 
Join Date: Feb 2012
Posts: 983
Reputation: 95
Default Re: Random Messages [Simple]

By the way, it wouldn't work ANYWAYS, lol! Where are you telling the script to send them random? It has to look like (for example) this:

Code:
public RandomMessages()
{
	new randomMsg = random(sizeof(randomMessages));
	SendClientMessageToAll(COLOR_ORANGERED, randomMessages[randomMsg]);
}
__________________
Join the BEST Gangwar-server ever; Los Santos Gangwars!
http://forum.sa-mp.com/showthread.ph...42#post2235842
^ Read!

Any problems with ZCMD-commands? Simply PM me your topic or check out the tutorial(s) in my signature, more'll come soon!

Twisted_Insane is offline   Reply With Quote
Old 27/03/2012, 05:50 PM   #7
Hiddos
High-roller
 
Hiddos's Avatar
 
Join Date: Sep 2008
Posts: 4,853
Reputation: 2179
Default Re: Random Messages [Simple]

Quote:
Originally Posted by Twisted_Insane View Post
By the way, it wouldn't work ANYWAYS, lol! Where are you telling the script to send them random? It has to look like (for example) this:

Code:
public RandomMessages()
{
	new randomMsg = random(sizeof(randomMessages));
	SendClientMessageToAll(COLOR_ORANGERED, randomMessages[randomMsg]);
}
Actually, the way he does it works as well. Doesn't change the fact that this isn't a tutorial but just a bunch of code though.
__________________
Quote:
Originally Posted by DeWolf View Post
For fuck's sake people, this whole thread is fucked up now.
Hiddos is offline   Reply With Quote
Old 27/03/2012, 05:52 PM   #8
Twisted_Insane
Gangsta
 
Twisted_Insane's Avatar
 
Join Date: Feb 2012
Posts: 983
Reputation: 95
Default Re: Random Messages [Simple]

Hiddos, tell me how the hell the concept would work? They should become "RANDOM messages", what he does is just sending them to all! He has to get out the info outta the arrray and define them randomly with the function.
__________________
Join the BEST Gangwar-server ever; Los Santos Gangwars!
http://forum.sa-mp.com/showthread.ph...42#post2235842
^ Read!

Any problems with ZCMD-commands? Simply PM me your topic or check out the tutorial(s) in my signature, more'll come soon!

Twisted_Insane is offline   Reply With Quote
Old 27/03/2012, 05:52 PM   #9
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 11,049
Reputation: 2647
Default Re: Random Messages [Simple]

Already explained a thousand times and almost a straight copy from the wiki: http://wiki.sa-mp.com/wiki/Random_Messages
__________________
Vince is offline   Reply With Quote
Old 27/03/2012, 05:53 PM   #10
shitbird
High-roller
 
shitbird's Avatar
 
Join Date: Nov 2007
Posts: 1,288
Reputation: 31
Default Re: Random Messages [Simple]

This is hardly a tutorial.

First off, this looks like it's been completely ripped off the SA-MP wiki.
With the exception that you have additionally defined 6 colours, which are not used anywhere in the final script.
shitbird is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] Simple Random Messages 2KY Tutorials 4 19/01/2012 07:58 PM
[Tutorial] How to create Simple Random Messages. [Nikk] Tutorials 13 16/01/2012 05:15 PM
[FilterScript] SW 3D Random Messages [VERY SIMPLE][13.12.2011] SpiderWalk Filterscripts 8 13/12/2011 04:51 PM
[Help] Random Messages Trawltrawl Help Archive 4 16/08/2011 09:50 PM
[FilterScript] P-Messages [Random Messages system] Pooh7 Filterscripts 5 30/11/2010 04:43 PM


All times are GMT. The time now is 12:00 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.