CLEO Help sampfuncs draw distance

CLEO related
Status
Not open for further replies.

fiha4155

Member
Joined
May 16, 2014
Messages
15
Reaction score
0
I cant draw numbers with render function. I dont know what to do. I got the distance between 2 xyz cords as integer but I dont know how to draw it as this code draws. Whenever I try to draw it with draw_text it crashes my game cuz I think it is a integer. 



Code:
                   if 19@ == 3013 
                       then 
                       Actor.StorePos($PLAYER_ACTOR, 26@, 25@, 24@)
                       0B55: convert_3D_coords 29@ 28@ 27@ to_screen 23@ 22@
                       0B55: convert_3D_coords 26@ 25@ 24@ to_screen 21@ 20@                                         
                       0B68: render draw_line_point1 23@ 22@ point2 21@ 20@ width 1 color 0x8833ff33                                                                        
                       0B70: render draw_polygon_pos 23@ 22@ size 3 3 corners 7 rotation 0 color 0xba00ff00
                       050A: 17@ = distance_between_XYZ 26@ 25@ 24@ and_XYZ 29@ 28@ 27@
       	0092: 17@ = float 17@ to_integer    
                       format 0@ "AMMO"
                       23@ += 5
                       22@ -= 7
                       0B6F: render font 1@ draw_text 0@ pos 23@ 22@ color 0xcac1f4c1
                   end
I tryed it with format like this;

Code:
                      format 0@ "AMMO\nDISTANCE: %d" 17@
But it writes like 
"AMMO\NDISTANCE: D" in game.
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
did you allocate memory for the string? If not you could use "alloc 0@ 40" once at the begining of the script (not in a loop)

Idk for sure but the fact that "n" is printed could indicate that "\n" is not supported as a newline escape sequence using that opcode, maybe try removing it and check what happens
 

fiha4155

Member
Joined
May 16, 2014
Messages
15
Reaction score
0
monday said:
did you allocate memory for the string? If not you could use "alloc 0@ 40" once at the begining of the script (not in a loop)

Idk for sure but the fact that "n" is printed could indicate that "\n" is not supported as a newline escape sequence using that opcode, maybe try removing it and check what happens

There is alloc 0@ 128 at beginning of the script and not in a loop. \n just outputs like \N in game. btw what is the difference between 40 and 128?  does it represent length of string?
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
length of the allocated memory, idk what exactly happens there but that's how it is:

When you use "alloc 0@ 40", 0@ becomes a pointer to the begining of 40 bytes free space ready to be used by you, if you add more than 39 to the pointer and try to write memory to it then some problems may arise. So storing a string greater in length than 40 characters (1 byte each) would not be possible (or even 39 because the 40th byte should be left for "0" terminating the string, in case if it's not there automatically)

Btw I guess this should help:
springfield said:
Set case converting to 'as is' from sanny builder options, you're probably have it set to uppercase, and it makes your script do /pm I test instead of an actual number.
 
Status
Not open for further replies.
Top