Coding

 Reply to this postStart new topic

[CLEO]Changing Global Variables via Memory

Deji
post Feb 12 2010, 06:32 PM
Post #1


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Indeed, you can just change the global variable directly, but this way is much better for CLEO modders and people interested in making hooks.


0xA49960
is the start of the scm block. From this, you have access to all the global variables.

4 bytes is the size of each global variable.


To change or read a global variable, we can use this address as a pointer in order to make things easier.


Each Global Variable has a number...

SANNY
$2
$3
$11
$14

etc.

Which is converted by Sanny to...

SANNY
$PLAYER_CHAR
$PLAYER_ACTOR
$PLAYER_GROUP
$DEFAULT_WAIT_TIME


And so on... You can find the list of the conversions in Sanny Builders program files

CODE
Program Files\Sanny Builder 3\data\sa\CustomVariables.ini



What we need is the number, not the name. As this can be used to find the address of the variable.



Say we want to check if $ONMISSION is on using memory. The number for it is $409, as shown in the file.


All the words I've boldened above; 0xA49960, 4 bytes, number... these are important for changing the variable. We have to times 4 by our number and add the result to our pointer.


As so...

SANNY
0006: 0@ = 0xA49960
0006: 1@ = 4        // 4 bytes per variable
0012: 1@ *= 409    // $409
005A: 0@ += 1@
0A8D: $ONMISSION = read_memory 0@ size 4 virtual_protect 0



Capich?

Now, we have the status of $ONMISSION, stored in... $ONMISSION. Overall, this script is pointless... but I'm sure you can find a use.


--------------------
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members: