[Tutorial] Simple TextDraws For Noobs
#1

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.
pawn Code:
new Text:Hosted;
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.
pawn Code:
public OnGameModeInit()
{
Now type this in
pawn Code:
Hosted = TextDrawCreate
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.My personal favourite is 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
So it will then look like this.
pawn Code:
Hosted = TextDrawCreate(500.000000,422.000000,
(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.
pawn Code:
Hosted = TextDrawCreate(500.000000,422.000000, "Hosted by CaptainJohn"
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.
pawn Code:
Hosted = TextDrawCreate(500.000000,422.000000, "Hosted by CaptainJohn");
Now lets go on to adding the TextDrawAlignment.
pawn Code:
TextDrawAlignment(Hosted,
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?
  • 1 = Left
  • 2 = Centre
  • 3 = Right
For this tutorial, I will keep my Alignment at 0 as I don't want to use it.
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);
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.
pawn Code:
TextDrawFont(Hosted,3);
So far my TextDraw will look like this.
pawn Code:
Hosted = TextDrawCreate(500.000000,422.000000, "Hosted by CaptainJohn");
TextDrawAlignment(Hosted,0);
TextDrawFont(Hosted,3);
Now we will add some colour to the TextDraw.
Under the TextDrawFont, add the following line.
pawn Code:
TextDrawColor(Hosted,
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).
pawn Code:
TextDrawColor(Hosted,0xffffffff);
So the code so far will look like 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);
Now we can set an outline for the TextDraw by using this.
pawn Code:
TextDrawSetOutline(Hosted,
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.
pawn Code:
TextDrawSetOutline(Hosted,1);
So far the whole code will look like 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);
Now we will add the TextDraw Proportionality.
Our next line will be this.
pawn Code:
TextDrawSetProportional(Hosted,
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.
pawn Code:
TextDrawSetProportional(Hosted,1);
So far the whole code will look like 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);
Now for this final bit, we will add the TextDrawSetShadow.
So your next and final line will be this.
pawn Code:
TextDrawSetShadow(Hosted,
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.
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);
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,
pawn Code:
TextDrawShowForPlayer(playerid, Hosted);
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.
Reply
#2

To much to read for a textdraw..i have a program for this,will generate the code.
Reply
#3

Quote:
Originally Posted by TzAkS.
View Post
To much to read for a textdraw..i have a program for this,will generate the code.
Yes there maybe too much to read.
But what does the title say? "For Noobs"
I hope people who are new to TextDraws will find this helpful.
Reply
#4

https://sampforum.blast.hk/showthread.php?tid=2867

looks easier to me
Reply
#5

nice tutorial. i'll try.
Reply
#6

awesome tut 5/5
Reply
#7

Perhaps a screen of it in game?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)