Making random messages -
bensmart469 - 20.10.2013
Hello there, and thank you for viewing this tutorial. First of all, i would like to let you know that i know there are a lot of these tutorials around, but I plan on fully explaining everything.
Firstly, we will need to forward our timer, otherwise we will receive an error that a 'public function lacks forward declaration'. Example:
Secondly, find OnGameModeInit/OnFilterscriptInit, or wherever you plan to use the timer. I plan on using ongamemodeinit/onfilterscriptinit as it is when the server is started. Example:
pawn Код:
// under ongamemodeinit/onfilterscriptinit
SetTimer("MyTimer",600000,1); // Repeating timer, every 10 mins
Now, we will make our timer. The below code has multiple comments to tell you what each thing does, so it isn't just copying and pasting:
pawn Код:
public MyTimer()
{
new rand = random(4); // We will have 4 different random messages, and rand is either 0, 1, 2 or 3
if(rand == 0) SendClientMessageToAll(0xFFFFFFFF,"My first message!"); // If the random number is equal to 0, it sends the 1st message in a white colour
else if(rand == 1)SendClientMessageToAll(0xFFFFFFFF,"My second message!"); // If the random number is equal to 1, it sends the 2nd message in a white colour
else if(rand == 2)SendClientMessageToAll(0xFFFFFFFF,"My third message!"); // If the random number is equal to 2, it sends the 3rd message in a white colour
else if(rand == 3)SendClientMessageToAll(0xFFFFFFFF,"My fourth message!"); // If the random number is equal to 3, it sends the 4th message in a white colour
return 1;
}
Constructive criticism is always welcome, just no insults e.g. "You suck, you never explain anything" or whatever. This was made for scripting newbies that may want random messages. If there is anything which isn't explained well, tell me, and i will edit the tutorial. Thank you for viewing this, and don't forget to post your opinion of it!
Re: Making random messages -
Akira297 - 20.10.2013
You should be alittle descriptive on every piece of the tutorial. Besides that, not bad.
Re: Making random messages -
XStormiest - 20.10.2013
I can give you many advise :
- Use switch instead of if everytime , is just ugly to see alot of if( condition ) every single time
- Try to use a variable where to stock all the messages
- Try to convert it for textdraw
Is good for newbies, but you have to improove , do not take it as offensive or destructive criticism ... take it as constructive one
Re: Making random messages -
bensmart469 - 20.10.2013
Quote:
Originally Posted by XStormiest
I can give you many advise :
- Use switch instead of if everytime , is just ugly to see alot of if( condition ) every single time
- Try to use a variable where to stock all the messages
- Try to convert it for textdraw
Is good for newbies, but you have to improove , do not take it as offensive or destructive criticism ... take it as constructive one
|
I will edit this tutorial later on, when i have time. Thanks for your post anyway, helping me to make my tutorials better.
Re: Making random messages -
Twizted - 20.10.2013
Can the same process be used to show random textdraws?
Re: Making random messages -
bensmart469 - 20.10.2013
Quote:
Originally Posted by Twizted
Can the same process be used to show random textdraws?
|
With TextDrawSetString, yes it can. (correct me if i am wrong)
Re: Making random messages -
[WA]iRonan - 21.10.2013
The tutorial isn't bad but except 0xFFFFFFF you can also use -1, it's also white
Re: Making random messages -
Vince - 21.10.2013
http://forum.sa-mp.com/showthread.ph...andom+messages
http://forum.sa-mp.com/showthread.ph...andom+messages
http://forum.sa-mp.com/showthread.ph...andom+messages
http://forum.sa-mp.com/showthread.ph...andom+messages
http://forum.sa-mp.com/showthread.ph...andom+messages
http://forum.sa-mp.com/showthread.ph...andom+messages
Now please tell me how this one is any different from the other ones. The general idea of your thread is okay, but you should've used the search feature since this particular topic has been discussed countless times.