CLEO Things to remember while writing code (Cleo 4.1)


Well-Known Member
Jun 23, 2014
A list of Cleo coding tips and things that "are supposed to work" but in practice don't work for some reason.

1. "wait 1000" will not work within command callbacks. More info

2. "alloc [email protected] 1000" makes sure that the memory region can be used safely by the cleo mod. After using it the [email protected] variable will hold an address (which is a number) to the begining of that memory. Most often it's used for storing text from what I see but any type of data can be stored there. To store text at that memory region it's possible to use:
format [email protected] "some text"
To store integer and float next to each other the following opcodes could be used:
0A8C: write_memory [email protected] size 4 value 77 virtual_protect 0
[email protected] += 4
0A8C: write_memory [email protected] size 4 value 77.0 virtual_protect 0
3. A lot of opcodes allow using pointers like the aforementioned [email protected] instead of 16-byte strings represented by "[email protected]" but there are some that accept only "[email protected]" expressions such as ini file reading opcodes. The "key" value cannot be specified by a passing pointer to it, I guess it could also be the case with section but I didn't test it.
format [email protected] "some text"
0AF4: [email protected] = read_string_from_ini_file "CLEO\file.ini" section "my_section" key [email protected] // it should work fine

{It wouldn't work with something like that:
alloc [email protected] 30
format [email protected] "some text"
0AF4: [email protected] = read_string_from_ini_file "CLEO\file.ini" section "my_section" key [email protected]
4. Sampfuncs "render" drawing opcodes use integers to define position and size. They represent window resolution pixels (not "game resolution" like 640-480 or something)

Useful resources:
(I suggest using google to translate whole websites to read and using the original russian versions to copy+paste the codes)

About this
Please let me know if you find some false information from this post. I invite anyone who has something to add to the list to share and I'll update the post.