Random Servermessages -
#Pwn. - 02.01.2012
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.
Re: Random Servermessages -
Littlehelper - 02.01.2012
Hello,
It has some bugs + SendClientMessageToAll(playerid? it must not have playerid only SendClientMessageToAll(-1, " Welcome To My Server");
kthxbai
EDIT: No, but atleast test the code before posting.
AW: Random Servermessages -
#Pwn. - 02.01.2012
Hello,
Thanks (: I edit it!
Is it bad for my first Tutorial?
Respuesta: Random Servermessages -
[Nikk] - 03.01.2012
Good tutorial, but are diferent ways of do this, more short and easy
Re: Random Servermessages -
[SP]Mr.Kakashi[WP] - 03.01.2012
This is good tutorial but like Nikk says theres more short and easy code for this. but i prefer this is good.
Re: Random Servermessages -
#Pwn. - 03.01.2012
Thanks ! Its my first tutorial
Re: Random Servermessages -
luckie12 - 03.01.2012
Getting a error @ Return 1;
error 002: only a single statement (or expression) can follow each "case"