CLEO Help Questions about CLEO text_draw

CLEO related
Status
Not open for further replies.

DzkAy

Well-known member
Joined
Feb 20, 2014
Messages
472
Reaction score
1
GgWqyu6.jpg


So i've found some opcodes about text_draw i only understand a fewl so i have questions about it.

0. How to make a simple text_draw ?
1. How to get Screen-Coords?
2.Can you tell me what's opcode use to change text_draw's color ?
3.And things, notice , ... that i need to know about  Text_draw in CLEO
4. I don't understand this well ( GXT .... )
Code:
07FC: text_draw_box_position_XY 145.0 275.0 GXT_reference 'BOAT_7' value 241@ flag 2  // Finish Time:
033E: set_draw_text_position 320.0 180.333 GXT 'BJ_PUSH'  // Push


Thanks in advance!  :somuchwin:
 

TheZeRots

Expert
Joined
Dec 21, 2013
Messages
1,247
Reaction score
1

DzkAy

Well-known member
Joined
Feb 20, 2014
Messages
472
Reaction score
1
There are some examples in NewOpcodes 2.0 so i understand a bit ...
One question : Does GXTHook support for SA-MP ?
 

DzkAy

Well-known member
Joined
Feb 20, 2014
Messages
472
Reaction score
1
I mean create a text_draw that looks like zonetext.cs .. LOS SANTOS , LAS VENTURAS , .... or a Digital HP .. that show Player Health , Armor in texts

Justl like this :
images
 

DzkAy

Well-known member
Joined
Feb 20, 2014
Messages
472
Reaction score
1
I found many opcodes about text_draw but dont know how to create a simple text that shows like the above ... can someone give me an example ?
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
First, textdraws must be in a loop.
Second, font/size etc. must be put before drawing the textdraw.

Code:
{$CLEO}
wait 3000
0000: nop


:text
wait 0
03F0: enable_text_draw 1 
033F: set_text_draw_letter_size 1.0 3.0 // font size (height, width)
081C: draw_text_outline 1 RGBA 0 0 0 255 // text outilne (1/0)(RGBA) 
0340: set_text_draw_RGBA 255 255 255 255 // text color (RGBA)
0349: set_text_draw_font 3 // text font 0/1/2/3
033E: set_draw_text_position 320.0 180.333 GXT 'BJ_PUSH'  // Finally, showing the textdraw. First two parameters are position screen XY, second is GXT. You can only use GXT, not custom things like '%s' etc. (will explain more under)
jump @text // loop

If you want to use custom text in your font(like your name, car name etc.) you need to use a method called gxt hacking;
Code:
0AA8: call_function_method 0x6A0050 0xC1B340 num_params 1 pop 0 'BJ_PUSH' 1@
0AA5: call 0x718600 2 pop 2 1@ "springfield"

'BJ_PUSH' is the GXT you edit(you can use all other GXTs) now 'BJ_PUSH' = 'springfield', not 'PUSH"
"springfield" = the custom text, you can use 0AD3 with a dynamic text.
Like this;
Code:
0AD3: 2@ = "opcode is black"
0AA8: call_function_method 0x6A0050 0xC1B340 num_params 1 pop 0 'BJ_PUSH' 1@
0AA5: call 0x718600 2 pop 2 1@ 2@

Fonts are;
Textdraw_font_styles.png


For numbers it the same, but you can use variables.
Code:
0226: 0@ = $player_actor HEALTH
045A: draw_text_1number posX posY GXT 'NUMBER' number 0@
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
With newOpcodes is even easier.

Code:
{$CLEO}
wait 3000
0000: nop
03F0: enable_text_draw 1

:text
wait 0
0AC8: 0@ = 260 // alocate memory for the text
0D4D: copy_string "opcode is black" to 0@ 
0ACD: show_text_hp 0@ time 10000
0AC9: 0@ // free memory
jump @text

If you use an older version of newOpcodes
Code:
0AD3: string 0@ = "opcode is black"
0D66: print 0@ at posX posY scale 0.6 0.8 style 1 prop TRUE align 0 wrap 600.0 justify FALSE color 255 0 0 255 outline 1 shadow 0 dropColor 0 0 0 255 background FALSE backColor 0 0 0 0
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
SAMPFUNCS text drawing;

Code:
{$CLEO}
wait 3000
0000: nop
03F0: enable_text_draw 1
0B6D: render 0@ = create_font "Arial" height 20 flags 0x04 // flags are text attributes(shadow, italic, underline etc.)
// 0@ = font 

:new
wait 0 
0B5A: get_screen_resolution 20@ 21@
20@ /= 2
21@ /= 2
0B6F: render font 0@ draw_text "opcode is black" pos 20@ 21@  color 0xFFC0FF01
20@ += 20
21@ += 20
0B6F: render font 0@ draw_text "wat, is this??" pos 20@ 21@ color 0xFFC0FF01
jump @new

Unlike the others, sampfuncs uses windows screen coords(desktop resolution) not game screen coords(640/480)
Use '0B6E: render release_font 0@' if you no longer need the font.
Flags are;
Code:
None = 0x0
Bold = 0x1
Italics = 0x2
Border = 0x4
Shadow = 0x8
Underline = 0x10
Striekout = 0x20
If you want 2/3 flags just add them 0x4+0x8=0x12

@credits to mgmoldova for teaching me this.
 

DzkAy

Well-known member
Joined
Feb 20, 2014
Messages
472
Reaction score
1
Would you mind if i ask you a few questions ?
- I dont get it well
Code:
20@ /= 2
21@ /= 2
20@ += 20
21@ += 20

And memories in newOpcodes ...
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
SAMPFUNCS uses window screen resolution. Like 1920x1080 so 20@ = 1920, 21@ = 1080, so in that example the text is in the middle of the screen, that's 1920/2(20@ /=2) and 1080/2(21@ /= 2) and the second text it's XY+20 so under the first text.
 

DzkAy

Well-known member
Joined
Feb 20, 2014
Messages
472
Reaction score
1
Ah now i understand ... i forgot to think about this "/ " , sorry ..
And how about the memories in newOpcodes text_draw ?
 

DzkAy

Well-known member
Joined
Feb 20, 2014
Messages
472
Reaction score
1
Code:
0AC8: 0@ = 260 // alocate memory for the text
0AC9: 0@ // free memory
Here.
P/s: English is not my tongue language so sometimes i dont understand it correctly , sr..
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
@ = 4bytes = 4letters,
@v = @x4 = 16bytes = 16letters
So these are the normal variables memory allocation. If you want a variable to store a long text like "opcode is so black his momma lost him in the night" you need to allocate more memory for that variable.
 

TheZeRots

Expert
Joined
Dec 21, 2013
Messages
1,247
Reaction score
1
springfield link said:
@ = 4bytes = 4letters,
@v = @x4 = 16bytes = 16letters
So these are the normal variables memory allocation. If you want a variable to store a long text like "opcode is so black his momma lost him in the night" you need to allocate more memory for that variable.
[member=60]Opcode.eXe[/member]
LOL
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
Mr.Ze link said:
[quote author=springfield link=topic=7658.msg43676#msg43676 date=1402231470]
@ = 4bytes = 4letters,
@v = @x4 = 16bytes = 16letters
So these are the normal variables memory allocation. If you want a variable to store a long text like "opcode is so black his momma lost him in the night" you need to allocate more memory for that variable.
[member=60]Opcode.eXe[/member]
LOL
[/quote]


Code:
{$CLEO .cs}
0000:
REPEAT
    WAIT 0
UNTIL 0AFA: SAMP IS READY

0B6D: 31@ CREATE_FONT "BigText" HEIGHT 20 FLAGS 0x4

WHILE TRUE
WAIT 0
    0AC8: 0@ = allocate_memory_size 260
    0209: 1@ = random_int_in_ranges 1 9999
    0AD3: 0@ = "Why does Springfield abuse me :(? %d" 1@
    0B6F: FONT 31@ draw_text 0@ pos 350 350 color 0xFFF00000
    0AC9: free_allocated_memory 0@
END
 
Status
Not open for further replies.
Top