24.10.2013, 15:15
Random Message - Textdraws Tutorial
What will this teach me?
This tutorial will teach you how to make random messages display at the bottom of your screen.
How could this help my server?
This could help your server by displaying basic commands or even updates, rules and advertising.
Step 1:
Ok so lets begin by defining the colors we gonna use at the top of the script.
Step 2:
Next we gonna have to forward a function we will use later and we will need to define the text and messages.
The "~y~" is gonna make the "Random News: " in yellow.
The "~w~" is gonna make the "Text" in white.
I will post all the colors at the end of the tutorial for you.
Step 3:
Now under your public OnGameModeInit() we need to make the text draws.
is gonna make the text change ever 8000 miliseconds
This line will create the textdraw.
These lines are just setting the color, font and size of the message.
Step 4:
Now we need to set the string for what the textdraw needs to display.
We forwarded the public earlier so we don't need to do that again.
This line will set the string and will display a random message that we set under the "RMessages[][]".
Step 5:
Now we need to make the textdraw display when the player spawns.
So under
Add:
This line will show the player the messages.
Hope this tutorial helped and please give me feedback and let me know if I missed something out or needs more explaining.
What will this teach me?
This tutorial will teach you how to make random messages display at the bottom of your screen.
How could this help my server?
This could help your server by displaying basic commands or even updates, rules and advertising.
Step 1:
Ok so lets begin by defining the colors we gonna use at the top of the script.
Code:
#define Light_Blue 0x00CCFF #define White 0xFFFFFF #define Gray 0x222222BB
Next we gonna have to forward a function we will use later and we will need to define the text and messages.
Code:
forward MSG(); new Text:ServerMSG; new RMessages[][] = { "~y~Random News: ~w~Random Text Here", "~y~Random News: ~w~Random Text Here", "~y~Random News: ~w~Random Text Here", "~y~Random News: ~w~Random Text Here", "~y~Random News: ~w~Random Text Here" };
The "~w~" is gonna make the "Text" in white.
I will post all the colors at the end of the tutorial for you.
Step 3:
Now under your public OnGameModeInit() we need to make the text draws.
Code:
SetTimer("MSG", 8000, true); ServerMSG = TextDrawCreate(2.000000, 428.000000, "[ Server MSG"); TextDrawColor(ServerMSG, Light_Blue); TextDrawFont(ServerMSG, 1); TextDrawLetterSize(ServerMSG, 0.400000, 0.800000);
Code:
SetTimer("MSG", 8000, true);
Code:
ServerMSG = TextDrawCreate(2.000000, 428.000000, "[ Server MSG");
Code:
TextDrawColor(ServerMSG, Light_Blue); TextDrawFont(ServerMSG, 1); TextDrawLetterSize(ServerMSG, 0.400000, 0.800000);
Step 4:
Now we need to set the string for what the textdraw needs to display.
Code:
public MSG() { TextDrawSetString(ServerMSG, RMessages[random(sizeof(RMessages))]); return 1; }
Code:
TextDrawSetString(ServerMSG, RMessages[random(sizeof(RMessages))]);
Step 5:
Now we need to make the textdraw display when the player spawns.
So under
Code:
public OnPlayerSpawn(playerid)
Code:
TextDrawShowForPlayer(playerid, ServerMSG);
Hope this tutorial helped and please give me feedback and let me know if I missed something out or needs more explaining.