Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTA Online

      1. The Diamond Casino Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

      1. Events
    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA 6

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    3. Gangs

    1. News

    2. Forum Support

    3. Site Suggestions

Sign in to follow this  
Ify24

Store variable value to memory

Recommended Posts

Ify24

Hy guys, I have a question?

 

 

Is it possible/how can I store variable value in memory??

The game is VC

Share this post


Link to post
Share on other sites
fastman92

What are these commands for?

 

 

05DF: write_memory 0xA10B2E size 1 value 0 virtual_protect 005E0: [email protected] = read_memory [email protected] size 4 virtual_protect 0

 

You didn't even take your time to search for "memory" opcodes in SB.

Share this post


Link to post
Share on other sites
Ify24
What are these commands for?

 

 

05DF: write_memory 0xA10B2E size 1 value 0 virtual_protect 005E0: [email protected] = read_memory [email protected] size 4 virtual_protect 0

 

You didn't even take your time to search for "memory" opcodes in SB.

I think you missunderstood me.

 

I want something like this:

 

1. [email protected] = 10

2. store value from variable [email protected] in memory

 

 

Share this post


Link to post
Share on other sites
LINK/2012

What? Fastman92 give you the answer, do you want a example?

So:

 

[email protected] = 1005DF: write_memory ? size 4 value [email protected] virtual_protect 0

 

Edited by Link2012

Share this post


Link to post
Share on other sites
Ify24

Yes, but what memory adress should I use ?

 

I don't want to do something effective in-game with memory adress.

EDIT:

This variable [email protected] will be used in script, not just as a memory value, but will b stored there.

Edited by Ify24

Share this post


Link to post
Share on other sites
LINK/2012

I don't know, you that know, If you want a new space to save the variable you can use the thread memory.

 

 

:Hey_PutNumber10Herehex00 00 00 00 // 4 bytesend

 

 

 

05F7: [email protected] = label @label offset

 

To get the offset of the label

 

 

Share this post


Link to post
Share on other sites
fastman92

 

05F7: [email protected] = label @label offset

 

To get the offset of the label

Where did you get this opcode from, there's no 05F7: [email protected] = label

http://gtag.gtagaming.com/opcode-database.php?opcode=05F7

 

To get address of label please refer to this post: http://www.gtaforums.com/index.php?showtop...st&p=1061449272

 

 

05F5: call_scm_func @GetBaseIP 0 store_to [email protected]// you can do// [email protected] -= @label// to get memory address to @label

 

 

Edited by fastman92

Share this post


Link to post
Share on other sites
LINK/2012

That's for VC

Share this post


Link to post
Share on other sites
Ify24
:Hey_PutNumber10Herehex00 00 00 00 // 4 bytesend

 

 

 

Can you explain this to me??

I mean, I know what is hex and I assume that 4 *00 are representing 4 bytes. Here where you say :Hey_PutNumber... you mean to put 10 as the name of the lable?? hmmm... confused.gif memory has always been hard part of coding, actually not as that hard as incomprehensible.

Share this post


Link to post
Share on other sites
Deji

No, a label is no representation of data. It's simply a 'label' for the current position in the script. You get the address of the script position using 05F7 and you write your data to it.

 

And I no longer recommend the 'ExtraVars' method. It's not completely stable in every situation. I got crashes which were solved by simply adding 0000: before using them in a very rare case which I still don't fully understand. It took quite a while to figure out, but in theory, there should've been no problem.

Share this post


Link to post
Share on other sites
Ify24

 

:Hey_PutNumber10Herehex00 00 00 00 // 4 bytesend05F7: [email protected] = label @label offset

 

 

So let's analize this code.

 

first we create a lable like

 

 

:BLABLA

 

and then this

 

 

hexnumbers      <--- what to type here end

 

 

 

05F7: [email protected] = label @label offset // <--- and with this we ???

 

Share this post


Link to post
Share on other sites
Wesser

Basically, a label is a relative offset starting from the beginning of the current script. 05F7 gives you the pointer of that label, that is the absolute address.

Share this post


Link to post
Share on other sites
Ashwin.Star

 

numbers      <--- what to type here

Hexadeciaml or Hex

from 00 to FF

 

Do you want to say that you need some memory address which you may freely use to store something,

and game should also store it in Savegames??

(also game should not effect with them)

Share this post


Link to post
Share on other sites
Ify24
numbers      <--- what to type here

Hexadeciaml or Hex

from 00 to FF

 

Do you want to say that you need some memory address which you may freely use to store something,

and game should also store it in Savegames??

(also game should not effect with them)

1. Yeah but what do they do?

 

2. That is exactly what I want. And then stored value in memory should change

if some claims are true, and then value will be drawn in text box.

Share this post


Link to post
Share on other sites
Ashwin.Star

 

1. Yeah but what do they do?

these are the Converted Symbols of Binary language,

like

HEX > > > Decimal > > > Binary > > > size

9E > > > > -98 > > > > 1001 1110 > >(1 Byte)

 

i don't think i should tell you more what binary actually is lol.gif

 

so, Hex Show you the Value of that Byte

 

---------------------------------------------------------------

 

2. That is exactly what I want. And then stored value in memory should change

if some claims are true, and then value will be drawn in text box.

i knew it,

because i also had nee of them ha ha ha,

I used some Unused Stats memory address for that purpose

Edited by Ashwin the new boy

Share this post


Link to post
Share on other sites
fastman92

 

No, a label is no representation of data. It's simply a 'label' for the current position in the script. You get the address of the script position using 05F7 and you write your data to it.

 

And I no longer recommend the 'ExtraVars' method. It's not completely stable in every situation. I got crashes which were solved by simply adding 0000: before using them in a very rare case which I still don't fully understand. It took quite a while to figure out, but in theory, there should've been no problem.

Maybe i can explain.

 

If you're using additional variables

such as [email protected]([email protected],1i) ; [email protected]([email protected],1i)

where [email protected] is index pointing to label

 

When it comes to CLEO opcodes - you can put

 

0AB0:   key_pressed [email protected]([email protected],1i)

 

 

But not

 

0AC6: [email protected]([email protected],1i) = label @label offset

 

You can use additional variables in a read context, not write to them.

 

A workaround to this problem is

 

0AC6: [email protected] = label @label offset0085: [email protected]([email protected],1i) = [email protected] // (int)

 

 

On other hand ExtraVars are impossible in GTA VC since there is no array support.

Share this post


Link to post
Share on other sites
Ashwin.Star

Labels are like syntax/Comments which are not compiled in Scripts

but it shows the offset or Location when used in opcodes by taking 4 Byte,

 

I have just wrote what i think about Labels.

if any Senior Codder found me incorrect,

please let me know so that i can change my point of view,

Share this post


Link to post
Share on other sites
fastman92

SCM Label - they occur in source to allow programmer refer to them by putting a '@' sign + name of label.

Labels do not exist in source in sense that they're registered/defined somewhere. Instead label is turned into negative offset when it points to current script.

It's possible to go outside the boundaries of the current script's code, especially when creating threads, go to into other parts of main.scm

In that case a positive offset > 0 is being used.

Any offset < 0 is assumed automatically to point to the current script, while offset >= 0 is relative to the beginning of main.scm.

While coder sees label in project source, labels are simply negative offsets of different codes compiled somewhere else.

Note that label offsets are ABSOLUTE, unlike in Assembly code where the rule of relative offsets is respected strongly.

 

 

but it shows the offset or Location when used in opcodes by taking 4 Byte,

It actually depends upon the compiler used to create a code. Offsets may be 1-byte, 2-byte or 4-byte, however due to limitations of R* compiler and Sanny Builder, they always occupy 4-bytes.

Share this post


Link to post
Share on other sites
Ify24

Alright guys, you might think that I am stupid now, but what is offset?

In Croatian language offset is ofset, but I have no clue what it is.

I never used that word.

 

 

I used some Unused Stats memory address for that purpose

Do you still have them? (memory adresses?)

Edited by Ify24

Share this post


Link to post
Share on other sites
Deji
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:

 

0A96: [email protected] = actor $PLAYER_ACTOR [email protected] += 0x5980A8C: write_memory [email protected] size 4 value 0 virtual_protect 0

 

Share this post


Link to post
Share on other sites
Ify24

 

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:

 

0A96: [email protected] = actor $PLAYER_ACTOR [email protected] += 0x5980A8C: write_memory [email protected] size 4 value 0 virtual_protect 0

 

So in this example the offset is this?:

[email protected] + 0x598 = offset ?

 

And is this:

 

0A96: [email protected] = actor $PLAYER_ACTOR [email protected] += 0x5980A8C: write_memory [email protected] size 4 value 0 virtual_protect 0

 

 

and this

 

 

0A96: [email protected] = 0xB6F5F0 //- Player pointer (CPed) [email protected] += 0x5980A8C: write_memory [email protected] size 4 value 0 virtual_protect 0

 

the same thing ?

Share this post


Link to post
Share on other sites
Wesser

 

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.

Share this post


Link to post
Share on other sites
Ify24

 

hex04 00 02 0800 04 01end

 

 

It will be compiled as

0004: $2 = 1

 

 

 

hmmm dozingoff.gif

How do sanny builder compile

04 00 02 0800 04 01 to 0004: $2 = 1 ???

Does it first convert to binary and then to ''sanny language''?

 

Oh, and this:

 

 

 

:get_offsethex04 00 02 $PLAYER_CHAR 01 @get_offsetend

 

 

It will be compiled as 0004: $PLAYER_CHAR = @get_offset

 

 

I don't understand this.

 

Share this post


Link to post
Share on other sites
fastman92

.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

Edited by fastman92

Share this post


Link to post
Share on other sites
Ify24
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?

Share this post


Link to post
Share on other sites
fastman92

Read: http://www.mediafire.com/?6j6prenz7v47tnh

Please note that commands with variable amount of arguments have one more byte at the end - 00.

It ends up list of arguments.

 

These commands have -1 undefined amount of arguments in Sanny Builder.

Edited by fastman92

Share this post


Link to post
Share on other sites
Ify24

thanks

 

EDIT:

It's very useful, but there are only data types.

Where can I found command IDs ?

 

 

04 00 - command ID, WORD taking 2-bytes, number 4
Edited by Ify24

Share this post


Link to post
Share on other sites
fastman92

 

thanks

 

EDIT:

It's very useful, but there are only data types.

Where can I found command IDs ?

 

 

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.

 

    * 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?

Share this post


Link to post
Share on other sites
Bad.boy!

Read this topic if you want to know more about cleo files.

 

This is a file in hex:

 

00 00 06 00 03 01 00 04 03 06 00 03 02 00 04 05 02 00 01 FE FF FF FF

 

 

2 hexadecimals are 1 byte. The offset is the position in bytes. The hex value "02 00" at the end means opcode 0002 (jump). The next 01 says that the next 4 bytes are an integer. FE FF FF FF is -2 in decimals (see previous post why it's a -). So we have start reading at the end of the second byte.

 

 

00 00 |!START HERE!| 06 00 03 01 00 04 03 06 00 03 02 00 04 05 02 00 01 FE FF FF FF

 

 

As you can see there is nothing like a label name. It's just a number, and if you decompile the code you'll see this:

 

0000: NOP :NONAME_20006: [email protected] = 3 0006: [email protected] = 5 0002: jump @NONAME_2 

 

 

As you can see the 2 returns. Sanny Builder converts it into a name to make it more readable.

 

EDIT: About the compiler it's sort of finished, the for loop is buggy but I barely use it.

Share this post


Link to post
Share on other sites
Ify24
What's your native language?

 

What's your native language?

Croatian.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.