[Tutorial] Everything you need to know about Global Textdraws :D!
#1

Global Textdraws!


Introduction

Hello, today i explain everything about textdraws . This tutorial is specially focused for newbies, it may help some average scripters too. I'd try to explain everything i know. All the questions, any bugs (in the tutorial code), Constructive criticism are welcomed in the comments below. Lets begin !

What is a textdraw?

First of all, a textdraw is Different from Gametext, never get confused within these two. a textdraw can appear for indefined time and is only limited to your imagination. Textdraws can be made anywhere on the screen at any size and can use different kind of fonts.

There are basically 2 types of textdraws -
1. Global Textdraws
2. Player Textdraws

1. Global textdraws are textdraws which can be shown to all players at a single time. They can be used for basically textdraws which wont change player to player. A global textdraw is easier to create in my opinion than player textdraws. Global Textdraws can be used for example to display Welcome Message for the server. or your website url or any other textdraws which remains constant.

2. Player Textdraws are different than global textdraws. They are created for each player, they may or may not be same. Player textdraws can be used to show stuffs like their stats, which wont be same for each player of course. or maybe for the speedometer for the car. which displays fuel health etc.I'd cover player textdraw in next tutorial. Sorry for that


How to create a textdraw?
Textdraws seems hard to create right? But they're relatively easy.
sooo this is how we do it!
We need to tell our script about the textdraw we are going to create (Dont think im drunk. m trying to explain it to newbs). Like. we need to declare a textdraw Everytime we create a new textdraw at the top of the script so its useable anywhere in the script below since we already told the script above about it

For example -
Код:
new Text:hi; // we just told the script that we are going to create a textdraw called hi. now you can use it throught the script.

public OnGameModeInit()
{
   hi = TextDrawCreate(123.456, 789.1011, "Hi bro");
    return 1;
}
We just created our textdraw called hi Note: the x and y coordinates i used were just imaginary, so m not sure if the textdraw would be visible or not.

Time to explain the native we used
TextDrawCreate(float,float:y,"text");
TextDrawCreate - it is the function which creates the textdaw, note - all the textdraw that we create needs to come under OnGameModeInit. since our textdraw should be created when the gamemode begins (intializes). this function has 3 arguements/ parameters. which are -
float - it is the x coordinate of the textdraw. (cartesian components, hope you know that.). i mean, the x coordinate of the textdraw that we created.
float:y - it is the y coordinate of the textdraw we created.
we used the float, not int because, our coordinates may have decimal.
Text- the text needs to come under double quotes ALWAYS. the text can be anything. whatever we like, keep it under double quotes though.

Okay, we created the textdraw but its not visible!!

well, after creating the textdraw we need to manually show it to the player using another samp function.
Код:
public OnPlayerConnect(playerid)
{
    TextDrawShowForPlayer(playerid, hi);
    return 1;
}
TextDrawShowForPlayer(playerid, textdrawid);

TextDrawShowForPlayer is the native which is used to show textdraw to the player, it has 2 parameters / arguements which are -
playerid - its the playerid that just connected to the server. and the playerid who'd see the textdraw.
textdrawid - its the id of the textdraw. i.e the textdraw we told the script above in the top remember?

Its not important that we show the textdraw when player connects, we can show it anywhere according to the scripters. it be OnPlayerSpawn OnPlayerDeath etc.

Similarly we can hide the textdraw for the specific player like we showed. (dope right?)
the native used for it is-

TextDrawHideForPlayer(playerid, textdrawid); i hope i dont really need to explain both the parameters again.

Showing our textdraws to everyone

we can show the textdraws for all the players and hide it for the players using -

TextDrawShowForAll(textdrawid); - it doesnt have the playerid parameter because we are showing it to all the players so we dont need an specific player id. textdrawid is the id of the textdraw that we will show to all players.

TextDrawHideForAll(textdrawid); - works the same as TextDrawShowForAll. just hides it rather than showing it.

I dont really like the texdraw i created, what to do?

Textdraws can be destroyed, using an default samp native which is -

TextDrawDestroy(textdrawid); - it has only one params. which is textdrawid, it is important to specify the textdrawid because our script wants to know what textdraw we exactly need to destroy.

How to set textdraw colors.
Textdraw color can be set by another native function called TextDrawColor

TextDrawColor(textdrawid, color); - this function has 2 parameters.

textdrawid - the id of the texdraw whom we are willing to change color.
color - the color that we want to apply

GAMETEXT COLORS CAN BE USED INTO TEXTDRAWS TO REDUCE HASSLE! THIS PART WILL BE COVERED IN MISCELLANEOUS BELOW

How to change the style of the text of the textdraw.

the style in which in the text is written, i.e its font can be changed with TextDrawFont, its an existing samp native.
TextDrawFont(textdrawid, fontid);

textdrawid - if you are reading the tutorial with concentration, this doesnt need an explanation.
fontid - there are 4 types of font, all of which have 4 different ids, - 0, 1, 2, 3. please check samp.wiki for their appearance, sorry for any issue.

i'd consider the textdraw we created above, which was 'hi'. if we want to change it to orignal gta sa style font. we'd do.
Код:
TextDrawFont(hi, 0);
I havent explained all the functions yet, my apologises. please consider samp.wiki.

Miscellaneous

Coding textdraws manually was the trend of the past, nowadays. textdraw creation tools are used. One of my fav textdraw editor is iPLEOMAX textdraw editor, its really simple and magical.
I strongly recommend using any textdraw editor. It makes textdraw much much easier.

All the gametext color available for Textdraws
Код:
~n~ New line
~r~ Red
~g~ Green
~b~ Blue
~w~ White
~y~ Yellow
~p~ Purple
~l~ Black (lower case L)
~h~ Turn text color lighter (used too much will make your text white, doesn't work on black)
Credits to samp.wiki for the gametext colors.
it took me around 1 hour to write the tutorial, hope its worth it
Thanks a lot for reading this.

Credits.
Internet - for letting me write.
[ND]xXZeusXx - for writing the tutorial.
Kalcor - for writing the functions :P
samp.wiki - for helping me to write
you - to read what i wrote.

Good bye
[ND]xXZeusXx
Reply
#2

Nice one.
Reply
#3

These definitions are really "bullshit", trust me, you need to change them and write some professional and meaningful words.
Quote:

1. Global textdraws are textdraws which can be shown to all players at a single time. They can be used for basically textdraws which wont change player to player. A global textdraw is easier to create in my opinion than player textdraws. Global Textdraws can be used for example to display Welcome Message for the server. or your website url or any other textdraws which remains constant.

2. Player Textdraws are different than global textdraws. They are created for each player, they may or may not be same. Player textdraws can be used to show stuffs like their stats, which wont be same for each player of course. or maybe for the speedometer for the car. which displays fuel health etc.I'd cover player textdraw in next tutorial. Sorry for that

FACT: Global textdraws are not constant/static, you can even use a single textdraw to fade, change color, change preview model, rotation, background color, font etc per player. All matters is the string.

Refer to wiki.
Reply
#4

Quote:
Originally Posted by Gammix
Посмотреть сообщение
These definitions are really "bullshit", trust me, you need to change them and write some professional and meaningful words.


FACT: Global textdraws are not constant/static, you can even use a single textdraw to fade, change color, change preview model, rotation, background color, font etc per player.

Refer to wiki.
Well, you could say the same thing with respect and not by saying "bullshit".He took time and made this tutorial.
Reply
#5

Quote:
Originally Posted by Gammix
Посмотреть сообщение
These definitions are really "bullshit", trust me, you need to change them and write some professional and meaningful words.


FACT: Global textdraws are not constant/static, you can even use a single textdraw to fade, change color, change preview model, rotation, background color, font etc per player. All matters is the string.

Refer to wiki.
Thanks karan007

i never meant global textdraws are static, they cannot be changed. they can of course. i meant the textdraws remains static for every player, every player gets to see same global textdraw and i already declared above that im trying to make things easier for newbs. i dont really think newbs would start their work by fading textdraws, and yes all matter is the string.

Sorry for the inconvience though and thanks for the constructive criticism mate
Reply
#6

"Everything?" Especially not.
English grammar? Nope...

XD

Not a bad attempt though, you can always add more later.
Reply
#7

Quote:
Originally Posted by Crayder
Посмотреть сообщение
"Everything?" Especially not.
English grammar? Nope...

XD

Not a bad attempt though, you can always add more later.
Thanks mate, oh well yes it doesnt cover everything bout global textdraws, n grammar is a bit wrecked i was kinda nervous. I started out thinking that ill cover up everything but it went wrong. i got tired later so yeah :P

ill expand it later dude. Thanks
Reply
#8

I would also like to point out it is bad practice to use decimals in textdraw positions using whole pixel values goes a long way for making resolution friendly textdraws!
Reply
#9

Quote:
Originally Posted by Pottus
Посмотреть сообщение
I would also like to point out it is bad practice to use decimals in textdraw positions using whole pixel values goes a long way for making resolution friendly textdraws!
Thanks for letting me know though. Can you explain more bout this?

I mean like. Textdraws position would be float values of course?
Reply
#10

Nice One +Rep for ur effort
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)