Random Messages Using y_timers - Glint - 02.07.2012
Create Random Messages Using y_timers
YSI contains libraries that has more functions then what you think, these functions are designed to save us time and speed up our script, one of these libraries is the y_timers library, when i first begun scripting about 2 years ago i was still using normal timers which is a performance issue if you have more then 10 timers, why ? well because this big amount of timers has a very HUGE impact on you Gamemode's performance, nevertheless i wasn't aware of y_timers until 2 days ago i was looking around the YSI topic and found, because my work was based on using, y_ini, y_commands, so i forgot about the others and how handy the come if you use them wisely. However in this tutorial i am going to teach you how to save time and a little bit of space by using the
tasks function in the y_timers, you may now wonder what is
tasks, well tasks are simply functions that Gets called at the amount of time you specify, enough talking, let's get working.
What Do We Need ?
Before we start the tutorial we need y_timers, which can be found in the YSI library which can be found
Here
Let's Get Started
Step 1
Open a new clean
.pwn document and add the followings on top :
pawn Code:
#include <a_samp>
#include <YSI\y_timers>
these are the includes the
a_samp is the ordeal SA:MP functions that we get (must be included in every script you make), and the
y_timers include that we are going to use, note that there is YSI in front of it meaning load y_timers from the YSI folder in your includes folder
Step 2
Now under your includes define the color that will be used when sending the Random Messages to the players, simply add.
Under Your Includes
Step 3
Now we are going to create an array for our Random Messages, that will contain the random messages, like the following
pawn Code:
new randomMessages[][] =
{
"Random Message 1",
"Random Message 2",
"Random Message 3"
};
you can add as many as messages as you want.
Step 4
Now anywhere in your script add the following function (the task function)
pawn Code:
task RandomMessages[1000]()
{
new randomMsg = random(sizeof(randomMessages));
SendClientMessageToAll(Red, randomMessages[randomMsg]);
print(randomMessages[randomMsg]);
}
as you can see here this is a task that is used by y_timers, the
1000 is the time that this function repeats itself in our case every second, change the time to any time you want.
That is it you now have the simplest Random Message system.
Credits
Y_Less - YSI & y_timers
Re : Random Messages Using y_timers -
mehdi-jumper - 02.07.2012
I didn't understand why do you need y_timers include? you can make it without that.
Re: Re : Random Messages Using y_timers - Glint - 02.07.2012
Quote:
Originally Posted by mehdi-jumper
I didn't understand why do you need y_timers include? you can make it without that.
|
Yes you can by using the old classic way this uses tasks which is a function of y_timers you can read more about it
Here
Re: Random Messages Using y_timers -
Mr.Fames - 02.07.2012
Good job on the tutorial, and thanks for the information i honestly didn't know that you can make functions with integrated timer's so easily
Re: Random Messages Using y_timers -
Saad_ - 02.07.2012
Good tutorial
Re: Random Messages Using y_timers -
MdeRooy - 04.07.2012
Well made tutorial! Easy to follow and well written!
Re: Random Messages Using y_timers - Glint - 04.07.2012
Quote:
Originally Posted by MdeRooy
Well made tutorial! Easy to follow and well written!
|
Thank you.
Re: Random Messages Using y_timers -
Kathleen - 04.07.2012
Very easy and nice
Re: Random Messages Using y_timers - Glint - 04.07.2012
Quote:
Originally Posted by Kathleen
Very easy and nice
|
I am happy you like it thanks.
Re: Random Messages Using y_timers -
Zom3ie - 07.07.2012
Thanks a bunch
Re: Random Messages Using y_timers - Glint - 07.07.2012
Quote:
Originally Posted by Zom3ie
Thanks a bunch 
|
I am currently working on another tutorial on the YSI library, and thanks.
Re: Random Messages Using y_timers -
Saad_ - 29.08.2012
Sorry for the stupid question but can i use task instead of ptask ?
and again nice job.
Re: Random Messages Using y_timers - Glint - 29.08.2012
Quote:
Originally Posted by Saad_
Sorry for the stupid question but can i use task instead of ptask ?
and again nice job.
|
What ptask i am using task ?
what do you mean ?
Re: Random Messages Using y_timers -
JesterlJoker - 08.02.2017
of all the tuts I have been looking for from complicated one, to the most in-depth and long ones, I just finally realize what I was doing wrong with y_timers because of this short but concise tuts. Explained for starters.
Re: Random Messages Using y_timers -
Primes007 - 21.03.2017
Cool! Thanks..