04.04.2012, 22:03
Hello everyone.
I am just making some Tutorials for my friends, so I thought I would share them with the SA-MP Community.
What I will do is go through step by step on how to create a basic textdraw, then I will go through adding more features.
First of all you need to create a variable for your textdraw.
For this tutorial, we will name the TextDraw "Hosted".
So the variable that will be placed at the top of your script (under your #defines and #includes) will look something like this.
Basically what this variable does is store the name/ID of the TextDraw. So you can use it throughout your script.
Now we will go onto creating the TextDraw.
Now find this callback.
Now type this in
Hosted = The name/ID of the TextDraw.
TextDrawCreate shows that we are creating a TextDraw.
Now we need to get the co-ordinates of the TextDraw.
There's multiple ways you can do this.
So if you follow anyone of these methods and get your co-ordinates, you should end up with some co-ordinates looking like this.
500.000000,422.000000
Now we will add these back to this.
So it will then look like this.
(I added the first bracket and a comma).
After the comma, you need to put what you want the TextDraw to show.
I will have it showing this "Hosted by CaptainJohn"
So now the code should look like this.
Now we need to close it off by adding a closed bracket ")" and a Semicolon. ";"
So for the first line, the final code will look like this.
Now lets go on to adding the TextDrawAlignment.
Remember the ID of the TextDraw is Hosted.
After the comma that is placed after Hosted we need can add the Alignment.
What are the Alignments?
So here's my first and second line (yours might be different).
Now we will go onto adding the TextDrawFont.
Your next line in the TextDraw will start like this.
[pawn]TextDrawFont(Hosted,[pawn]
Now, here are the 4 types of fonts you can use.
For this tutorial, I will use ID 3.
So my final code for the font will look like this.
So far my TextDraw will look like this.
Now we will add some colour to the TextDraw.
Under the TextDrawFont, add the following line.
Now, you can get your colours by using the hexadecimal way. You can find hexadecimals here
Now add your hexadecimal to the line, it will then look like this (or similar to this).
So the code so far will look like this.
Now we can set an outline for the TextDraw by using this.
The number that will go after the comma defines the thickness of the outline you will have.
I recommend you use either number 1 or 2, it really depends on how big your textdraw will be.
In this tutorial, I will be keeping the outline at number 1.
So my code will look like this now.
So far the whole code will look like this.
Now we will add the TextDraw Proportionality.
Our next line will be this.
What this does is sets your text spacing to scale.
ID 1 = Enable.
ID 0 = Disable.
In this tutorial I will be using ID 1.
So my code will look like this.
So far the whole code will look like this.
Now for this final bit, we will add the TextDrawSetShadow.
So your next and final line will be this.
The number that you will be putting is the size of the shadow.
Again I recommend either ID 1 or 2.
For this tutorial, I will use ID 1.
So my code will be this.
Now this is your basic TextDraw.
What this TextDraw does is displays at the bottom right of your screen the words "Hosted by CaptainJohn".
// EXTRAS -----------------
// EXTRAS -----------------
WILL BE UPDATED TOMORROW
If you want to show your TextDraw when a player connects to the server, then search for this callback in your script "OnPlayerConnect".
Now place this in it,
What this does is show the TextDraw to the player that has connected to the server.
If you want to show the TextDraw for a Player that has spawned (as in when they die and respawn or after connecting to the server and choosing their skin/class).
Just put the same code as above but under the "OnPlayerSpawn" callback.
If I helped you at all, please give me some reputation, that would be highly appreciated.
Thanks,
CaptainJohn.
I am just making some Tutorials for my friends, so I thought I would share them with the SA-MP Community.
What I will do is go through step by step on how to create a basic textdraw, then I will go through adding more features.
First of all you need to create a variable for your textdraw.
For this tutorial, we will name the TextDraw "Hosted".
So the variable that will be placed at the top of your script (under your #defines and #includes) will look something like this.
pawn Code:
new Text:Hosted;
Now we will go onto creating the TextDraw.
Now find this callback.
pawn Code:
public OnGameModeInit()
{
pawn Code:
Hosted = TextDrawCreate
TextDrawCreate shows that we are creating a TextDraw.
Now we need to get the co-ordinates of the TextDraw.
There's multiple ways you can do this.
- Trial and Error
- BSN TextDraw Editor Online - https://sampforum.blast.hk/showthread.php?tid=254315
- Zamaroht's Textdraw Editor v1.0
So if you follow anyone of these methods and get your co-ordinates, you should end up with some co-ordinates looking like this.
500.000000,422.000000
Now we will add these back to this.
pawn Code:
Hosted = TextDrawCreate
pawn Code:
Hosted = TextDrawCreate(500.000000,422.000000,
After the comma, you need to put what you want the TextDraw to show.
I will have it showing this "Hosted by CaptainJohn"
So now the code should look like this.
pawn Code:
Hosted = TextDrawCreate(500.000000,422.000000, "Hosted by CaptainJohn"
So for the first line, the final code will look like this.
pawn Code:
Hosted = TextDrawCreate(500.000000,422.000000, "Hosted by CaptainJohn");
pawn Code:
TextDrawAlignment(Hosted,
After the comma that is placed after Hosted we need can add the Alignment.
What are the Alignments?
- 1 = Left
- 2 = Centre
- 3 = Right
So here's my first and second line (yours might be different).
pawn Code:
Hosted = TextDrawCreate(500.000000,422.000000, "Hosted by CaptainJohn");
TextDrawAlignment(Hosted,0);
Your next line in the TextDraw will start like this.
[pawn]TextDrawFont(Hosted,[pawn]
Now, here are the 4 types of fonts you can use.
For this tutorial, I will use ID 3.
So my final code for the font will look like this.
pawn Code:
TextDrawFont(Hosted,3);
pawn Code:
Hosted = TextDrawCreate(500.000000,422.000000, "Hosted by CaptainJohn");
TextDrawAlignment(Hosted,0);
TextDrawFont(Hosted,3);
Under the TextDrawFont, add the following line.
pawn Code:
TextDrawColor(Hosted,
Now add your hexadecimal to the line, it will then look like this (or similar to this).
pawn Code:
TextDrawColor(Hosted,0xffffffff);
pawn Code:
Hosted = TextDrawCreate(500.000000,422.000000, "Hosted by CaptainJohn");
TextDrawAlignment(Hosted,0);
TextDrawFont(Hosted,3);
TextDrawLetterSize(Hosted,0.299999,1.000000);
TextDrawColor(Hosted,0xffffffff);
pawn Code:
TextDrawSetOutline(Hosted,
I recommend you use either number 1 or 2, it really depends on how big your textdraw will be.
In this tutorial, I will be keeping the outline at number 1.
So my code will look like this now.
pawn Code:
TextDrawSetOutline(Hosted,1);
pawn Code:
Hosted = TextDrawCreate(500.000000,422.000000, "Hosted by CaptainJohn");
TextDrawAlignment(Hosted,0);
TextDrawFont(Hosted,3);
TextDrawLetterSize(Hosted,0.299999,1.000000);
TextDrawColor(Hosted,0xffffffff);
TextDrawSetOutline(Hosted,1);
Our next line will be this.
pawn Code:
TextDrawSetProportional(Hosted,
ID 1 = Enable.
ID 0 = Disable.
In this tutorial I will be using ID 1.
So my code will look like this.
pawn Code:
TextDrawSetProportional(Hosted,1);
pawn Code:
Hosted = TextDrawCreate(500.000000,422.000000, "Hosted by CaptainJohn");
TextDrawAlignment(Hosted,0);
TextDrawFont(Hosted,3);
TextDrawLetterSize(Hosted,0.299999,1.000000);
TextDrawColor(Hosted,0xffffffff);
TextDrawSetOutline(Hosted,1);
TextDrawSetProportional(Hosted,1);
So your next and final line will be this.
pawn Code:
TextDrawSetShadow(Hosted,
Again I recommend either ID 1 or 2.
For this tutorial, I will use ID 1.
So my code will be this.
pawn Code:
Hosted = TextDrawCreate(500.000000,422.000000, "Hosted by CaptainJohn");
TextDrawAlignment(Hosted,0);
TextDrawFont(Hosted,3);
TextDrawLetterSize(Hosted,0.299999,1.000000);
TextDrawColor(Hosted,0xffffffff);
TextDrawSetOutline(Hosted,1);
TextDrawSetProportional(Hosted,1);
TextDrawSetShadow(Hosted,1);
What this TextDraw does is displays at the bottom right of your screen the words "Hosted by CaptainJohn".
// EXTRAS -----------------
// EXTRAS -----------------
WILL BE UPDATED TOMORROW
If you want to show your TextDraw when a player connects to the server, then search for this callback in your script "OnPlayerConnect".
Now place this in it,
pawn Code:
TextDrawShowForPlayer(playerid, Hosted);
If you want to show the TextDraw for a Player that has spawned (as in when they die and respawn or after connecting to the server and choosing their skin/class).
Just put the same code as above but under the "OnPlayerSpawn" callback.
If I helped you at all, please give me some reputation, that would be highly appreciated.
Thanks,
CaptainJohn.