CLEO Help How to show variable as text

CLEO related
Status
Not open for further replies.

Mennims

Active member
Joined
Mar 18, 2014
Messages
41
Reaction score
0
Hi, I want to display a variable in text, now I'm still new to cleo, and the text confuses me with all the GTX's and stuff like that. For now I want to show a integer as a variable, I saw this
Code:
0AD1: show_formatted_text_highpriority "This is %.4X opcode" time 2000 0x0AD1
Now I do not understand this. IG that says "This is a 0AD1 opcode"
Wow, HOW THE HELL DOES THAT WORK.What is %.4X? Why is it telling my the memory address? I can't find any answers for any questions about Cleo. Where do I need to look? Where are the explanations for these functions?
Also. What is writing to memory? Can someone explain these please, what they do, how to use them and when to use them
Code:
0550: keep_object 0@ in_memory 1
0A8C: write_memory 0xC0BC15 size 1 value 1 virtual_protect 0
0A8D: $result = read_memory 1@ size 4 virtual_protect 0
0AC8: 0@ = allocate_memory_size 260
0AC9: free_allocated_memory 0@
What is virtual protect? And what does it mean by write memory 0xC0BC15? What I mean is, how did he get that number? Does it have to be in a specific range? And what can you write to memory? numbers? Size, that's obviously the size of the memory you want to allocate in bytes, value is what you're writing? Can you write text there? Then with the read memory, why is there a size argument? Is it how much of the memory you want to read? And what does allocate memory do? Make it available? And free allocated memory? Does it clear it? I don't see a tutorial for these, like I said earlier, I find it so hard to find answers, it's like they gave you one terrible example and you must learn from just that. And how are these commands used in conjunction? For example. You allocate the memory, free it, then write, then maybe keep object in memory, then read? If it's used in a order like that why must you allocate a memory size 260 for example, then still have the option to write a different size memory, AND READ A DIFFERENT SIZE???? I'm new this is obviously the basics. But please guys can you tutor me :bawww: :angry:
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
%s = String like "HAII"
%d = integer like 1 2 4 1000230
%f = float like 239.0 32.0 23.0
%% = % like 23%
%x = hex like 0x4

0AD1: show_formatted_text_highpriority "String: %s, Integer: %d, Float: %f." TIME 1000 "STRING" 100 20.0
 

Mennims

Active member
Joined
Mar 18, 2014
Messages
41
Reaction score
0
Haha Opcode, we meet again, I met you on Xportal, you told me you hacked their Rcon. Haha, now I'm doing cleo

It doesn't work... If I try it with a string, the text comes up but where the string is supposed to be  it's blank. Same with a float, but with a int nothing appears. I know how to use this formatting becuase it's the same in Pawn, but now what? Why is it doing this
 

pepeelpubero

Well-known member
Joined
Jan 21, 2014
Messages
433
Reaction score
1
Try doing this:

ALL AT SANNY BUILDER: PRESS F10 > Formats tab > Case converting > Choose "As is" > compile and try again.

Also for read_memory, read THIS POST.

Code:
Description: 
Writes a value to the game memory.

Parameters:
1 = memory address (any integer value)
2 = number of bytes to write: 1, 2 or 4 bytes
3 = value to write (any number)
4 = Virtual Protect: use 1 to write to the read-only address, 0 - if the address is rewritable.

Parameters (v2)	
1) Memory address (Integer) (INT)
2) Integer (INT)
3) Integer or Float (ANY)
4) Boolean (1 or 0) (INT)

0A8C: write_memory 0xC0BC15 size 1 value 1 virtual_protect 0
 

Mennims

Active member
Joined
Mar 18, 2014
Messages
41
Reaction score
0
It helped in some way, but not completely, here's my code
Code:
{$CLEO .cs}
:test
03A4: name_thread 'test' 
wait 0
var
$fVar: float = 0.1
end

:test_1
wait 0
if
    0256:   player $PLAYER_CHAR defined 
then
    $fVar += 0.7
    jf @test_1
    0AD1: show_formatted_text_highpriority "Float: %f" TIME 200 $fVar
    wait 200
end
jump @test_1
004E: end_thread
        
                                                               

But when tested it prints 0.700000 (Something like that) and not 0.7. Also it seems like intializing it does not set it's value. And with the loop I set it should add 0.7 each time but it stays the same
 

DzkAy

Well-known member
Joined
Feb 20, 2014
Messages
472
Reaction score
1
Mennims link said:
It helped in some way, but not completely, here's my code
Code:
{$CLEO .cs}
:test
03A4: name_thread 'test' 
wait 0
var
$fVar: float = 0.1
end

:test_1
wait 0
if
    0256:   player $PLAYER_CHAR defined 
then
    $fVar += 0.7
    jf @test_1
    0AD1: show_formatted_text_highpriority "Float: %f" TIME 200 $fVar
    wait 200
end
jump @test_1
004E: end_thread
        
                                                               

But when tested it prints 0.700000 (Something like that) and not 0.7. Also it seems like intializing it does not set it's value. And with the loop I set it should add 0.7 each time but it stays the same
try %0.1f 
 

Mennims

Active member
Joined
Mar 18, 2014
Messages
41
Reaction score
0
That helped, it now only shows 0.7 not 0000000. But my problem isn't solved, even if I add to the variable it still shows 0.7 and if I mess with the script sometimes it just shows 0.0. WHy? It's like if you declare the variable as 0.4 it will show 0.0. Even with integers it just shows 0. And if I use the status thing it also shows 0, like my variables are resetting themselves. Why am I having so many issues
 

pepeelpubero

Well-known member
Joined
Jan 21, 2014
Messages
433
Reaction score
1
Mennims link said:
That helped, it now only shows 0.7 not 0000000. But my problem isn't solved, even if I add to the variable it still shows 0.7 and if I mess with the script sometimes it just shows 0.0. WHy? It's like if you declare the variable as 0.4 it will show 0.0. Even with integers it just shows 0. And if I use the status thing it also shows 0, like my variables are resetting themselves. Why am I having so many issues

Code:
{$CLEO .cs}

03A4: name_thread 'test'

var
$fVar: float = 0.1
end

:test_1
wait 0
if
    0256:   player $PLAYER_CHAR defined 
then
    $fVar += 0.7
    jf @test_1
    0AD1: show_formatted_text_highpriority "Float: %f" TIME 200 $fVar
    wait 200
end 
jump @test_1
004E: end_thread

Also, first do what i said:
ALL AT SANNY BUILDER: PRESS F10 > Formats tab > Case converting > Choose "As is" > compile and try again.

Otherwise it won't work.
 

Mennims

Active member
Joined
Mar 18, 2014
Messages
41
Reaction score
0
[member=8650]pepeelpubero[/member] Thanks for the help man, I had tried the "As is" but I didn't see it help as I was using the wrong type of variable, thanks to [member=60]Opcode.eXe[/member] for help on that, but I'm sure it was one of the problems and will save me future problems. Thanks guys its all working properly.
 
Status
Not open for further replies.
Top