|
 |
|
|
|
|
|
GTA Modification Forums
Store variable value to memory how to ?
 |
|
 |
| |
Ify24  |
|
0x00000000 --> invisible

Group: Members
Joined: Aug 17, 2011


|
| QUOTE (Deji @ Tuesday, Aug 7 2012, 17:22) | | QUOTE (fastman92 @ Tuesday, Aug 7 2012, 15:16) | | You can use additional variables in a read context, not write to them. |
You especially shouldn't local vars for offsets... the pointer of the script data can sometimes be placed before the script and it doesn't seem to quite like using negative indexes. Global offsets were better, because they are statically allocated and will always result in a positive index.
However, I got crashes simply comparing the value of one in a very rare case. The rest of the script ran fine with them, but comparing one to a normal local var somehow started causing a crash, precisely after the array var was parsed. It didn't even matter if I switched the order of the local and global array, it would crash after the global array was parsed, getting an incorrect pointer overall (I calculated the array info myself and it was conclusive).
A remedy was placing 0000: (or anything) before this check. That seemed to change where the data was allocated and resulted in a good pointer when the array was calculated. Maybe something to do with the fact I used it in a SCM Function? Not sure, but a crash that occurs 'sometimes' is hard to pinpoint, so I wouldn't feel good recommending this as a solution to lack of vars, knowing modders may end up spending ages puzzled about why their mod is crashing so randomly.
But fear not, because this unfortunate discovery encouraged me to come up with a much better solution which has plenty of perks to come soon. It requires an ASI, however...
@Ify24 In coding terms, an offset is the name of the difference between too memory locations. So 4 would be the offset of 2 and 6.
Here we're writing to offset 0x598 of the ped struct:
| CODE | 0A96: 0@ = actor $PLAYER_ACTOR struct 0@ += 0x598 0A8C: write_memory 0@ size 4 value 0 virtual_protect 0 | |
So in this example the offset is this?: 0@ + 0x598 = offset ? And is this: | CODE | 0A96: 0@ = actor $PLAYER_ACTOR struct 0@ += 0x598 0A8C: write_memory 0@ size 4 value 0 virtual_protect 0 |
and this | CODE | 0A96: 0@ = 0xB6F5F0 //- Player pointer (CPed) 0@ += 0x598 0A8C: write_memory 0@ size 4 value 0 virtual_protect 0 |
the same thing ?
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
Wesser  |
|
The complexity simplifier, the efficiency optimizer

Group: Members
Joined: Aug 19, 2006



|
| QUOTE (fastman92 @ Tuesday, Aug 7 2012, 16:52) | | While coder sees a label in the source project, labels are simply negative offsets of different codes compiled somewhere else. |
It isn't that correct. Offsets of the main part are relative to the beginning of the main script and they are positive. Those of missions and allocating scripts (also known as externals) point to their beginning and they are negative. That's because main script, missions and allocating scripts are stored into different buffers. Plus, the last 2 don't start from a 0-based offset. Ify24, the offset is 0x598 in your example. Moreover, both of your codes does the same thing, except that 0xB6F5F0 is the pointer to the first player struct whose first member contains a pointer to CPed. You should read its pointer in the second sample.
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
fastman92  |
|
фастман92 | ف

Group: Members
Joined: Jul 28, 2009


|
.scm is one and possibilities may be only changed by modification of hardcoded gta_sa.exe code, while there may be many programming languages compiled into the .scm following the same rules. Sanny language is one of them to use in source. Similarly there are many programming languages to create EXEs - C++, Pascal, D, but all of them must follow Assembler's standards to produce code
04 00 02 0800 04 01 to 0004: $2 = 1 ???
04 00 - command ID, WORD taking 2-bytes, number 4 02 - data type, meant to be global integer/float variable + 0800 aligned, but not divided offset. Global variable offsets are not divided, integer/float vars take 4-byte, therefore $2 will be on offset 8. 2*4 = 8, right or not?
04 - data type of second argument, meant to be static integer value taking 1-byte, char from C++ 01 - value for the data type of 1-byte
This post has been edited by fastman92 on Tuesday, Aug 7 2012, 18:46
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
Ify24  |
|
0x00000000 --> invisible

Group: Members
Joined: Aug 17, 2011


|
| QUOTE (fastman92 @ Tuesday, Aug 7 2012, 18:43) | 04 00 - command ID, WORD taking 2-bytes, number 4 02 - data type, meant to be global integer/float variable + 0800 aligned, but not divided offset. Global variable offsets are not divided, integer/float vars take 4-byte, therefore $2 will be on offset 8. 2*4 = 8, right or not?
04 - data type of second argument, meant to be static integer value taking 1-byte, char from C++ 01 - value for the data type of 1-byte | Where did you learn this stuff? Where can I learn it?
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
fastman92  |
|
фастман92 | ف

Group: Members
Joined: Jul 28, 2009


|
| QUOTE (Ify24 @ Tuesday, Aug 7 2012, 20:05) | thanks
EDIT: It's very useful, but there are only data types. Where can I found command IDs ?
| QUOTE | | 04 00 - command ID, WORD taking 2-bytes, number 4 | |
What's your native language? Command ID? It's the first thing processed. There is: command ID + appropriate amount of arguments. next command ID + appropriate amount of arguments. next command ID + appropriate amount of arguments. next command ID + appropriate amount of arguments. Amount of arguments depends on commands. I use term "command" since there were no "opcodes" at R*. They had commands, opcode term was invented by modding community. | CODE | * ProcessCommands1000To1099 (i)
* ProcessCommands900To999 (i)
* ProcessCommands800To899 (i)
* ProcessCommands700To799 (i)
* ProcessCommands600To699 (i)
* ProcessCommands500To599 (i)
* ProcessCommands400To499 (i)
* ProcessCommands300To399 (i) |
GTA VC: "Processing command" GTA SA command 2083 (0x823): COMMAND_TASK_GREET_PARTNER What's your native language?
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Pages:
(2) 1 [2]
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
| |
 |
|
 |
|
|
|
|