|
|
#1 |
|
Little Clucker
![]() Join Date: Jan 2012
Location: Oberbayern
Posts: 31
Reputation: 3
|
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(); Code:
public OnGameModeInit Code:
SetTimer("Servermessage",1800000,1);
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;
}
We add this ( Code:
new rand = random(2); Code:
public Servermessage()
{
new rand=random(2);
return 1;
}
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;
}
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!");
}
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;
}
Feedback is Welcome! Greetz, #Pwn. |
|
|
|
|
|
#2 |
|
Gangsta
![]() ![]() ![]() ![]() Join Date: Nov 2011
Location: 420
Posts: 788
Reputation: 117
|
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. Last edited by Littlehelper[MDZ]; 02/01/2012 at 06:24 PM. |
|
|
|
|
|
#3 |
|
Little Clucker
![]() Join Date: Jan 2012
Location: Oberbayern
Posts: 31
Reputation: 3
|
Hello,
Thanks (: I edit it! Is it bad for my first Tutorial? |
|
|
|
|
|
#4 |
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Jun 2011
Location: Argentina.
Posts: 1,513
Reputation: 48
|
Good tutorial, but are diferent ways of do this, more short and easy
|
|
|
|
|
|
#5 |
|
Banned
![]() Join Date: Oct 2011
Location: Philippines
Posts: 33
Reputation: 1
|
This is good tutorial but like Nikk says theres more short and easy code for this. but i prefer this is good.
|
|
|
|
|
|
#6 |
|
Little Clucker
![]() Join Date: Jan 2012
Location: Oberbayern
Posts: 31
Reputation: 3
|
Thanks ! Its my first tutorial
|
|
|
|
|
|
#7 |
|
Huge Clucker
![]() ![]() ![]() Join Date: Mar 2009
Posts: 260
Reputation: 0
|
Getting a error @ Return 1;
error 002: only a single statement (or expression) can follow each "case" |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Include] Insanity Random Lists(generate a random number from your list) | CyNiC | Includes | 10 | 23/07/2011 01:45 PM |
| Random payment to Random player | ViruZZzZ_ChiLLL | Help Archive | 1 | 01/05/2010 05:43 PM |
| Random location + Random skin | Naruto4 | Help Archive | 2 | 03/12/2009 04:07 PM |
| new mode = random(1); lets pawno crash + mode = random number FOR all public's | hipy | Help Archive | 3 | 23/07/2009 08:50 PM |