[Tutorial] Random Servermessages
#1

Hello SAMP Community!

Today i want to show you, a tutorial how you create random Servermessages
What we need:
1. Pawno

2. Brain

3. A little bit of your lifetime

So Let`s go!

At first we define a forward at the top of the script:

Code:
forward Servermessage();
Then you go to

Code:
public OnGameModeInit
and create a Timer

Code:
SetTimer("Servermessage",1800000,1);
Explanations:

SetTimer = CreateTimer
Servermessage= function of the timer
1 = [true] Is for repeating [2=[false] Is for not repeating]

So, we have created a Timer, but he isn`t helpfull!

You make in your Script a new public, like that:

Code:
public Servermessage()
{
 return 1;
}
Now it comes the random function.

We add this (
Code:
new rand = random(2);
) to our public :

Code:
public Servermessage()
{
 new rand=random(2);
 return 1;
}
Explanations:

new rand mean, that we create a new variable
random(2) , because Pawno select the case 0 or case 1!

Now it`s look like this:

Code:
public Servernachricht()
{
new rand=random(2);
return 1;
}
The random select case 0 or case 1, but we haven`t case 0 or case 1....Let`s make it!

Code:
switch(rand) 
{
case 0: //If random select case 0
{
SendClientMessageToAll(-1,"Your Message!");
}
case 1: //If Random select case 1
{
 SendClientMessageToAll(-1,"Your Message!");
}
Now....It`s all that you have to do, to make random Servermessages

It look`s now like this:

Code:
public Servernachricht()
{
new rand=random(2);
switch(rand) 
{
case 0:
{
SendClientMessageToAll(-1,"Your Message!");
}
case 1:
{
 SendClientMessageToAll(-1,"Your Message!");
}
return 1;
}
This is my first Tutorial! Please don`t be hard with me :'D. And I`m German, sorry for the bad english!

Feedback is Welcome!


Greetz,

#Pwn.
Reply


Messages In This Thread
Random Servermessages - by #Pwn. - 02.01.2012, 17:26
Re: Random Servermessages - by Littlehelper - 02.01.2012, 17:37
AW: Random Servermessages - by #Pwn. - 02.01.2012, 17:39
Respuesta: Random Servermessages - by [Nikk] - 03.01.2012, 01:40
Re: Random Servermessages - by [SP]Mr.Kakashi[WP] - 03.01.2012, 08:04
Re: Random Servermessages - by #Pwn. - 03.01.2012, 08:52
Re: Random Servermessages - by luckie12 - 03.01.2012, 09:56

Forum Jump:


Users browsing this thread: 3 Guest(s)