IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
Forum Rules GTA Modification Forums

Please post mod releases in the Mod Showroom

GTAGarage.com
free mod hosting from GTANet, simply login with your GTAForums account details

GTAModding.com
GTANet's modding wiki

GTA Modding Chatroom
provided by irc.gtanet.com (Don't have an IRC client? Click here)


Pages: (2) [1] 2   ( Go to first unread post ) Reply to this topicStart new topicStart Poll

 Store variable value to memory

 how to ?
 
Ify24  
Posted: Monday, Aug 6 2012, 18:21
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



Hy guys, I have a question?


Is it possible/how can I store variable value in memory??
The game is VC
PM
  Top
 

 
fastman92  
Posted: Monday, Aug 6 2012, 18:23
Quote Post


фастман92 | ف
Group Icon
Group: Members
Joined: Jul 28, 2009

pl.gif

XXXXX



What are these commands for?

CODE
05DF: write_memory 0xA10B2E size 1 value 0 virtual_protect 0
05E0: 0@ = read_memory 1@ size 4 virtual_protect 0

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

 
Ify24  
Posted: Monday, Aug 6 2012, 18:59
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



QUOTE (fastman92 @ Monday, Aug 6 2012, 18:23)
What are these commands for?

CODE
05DF: write_memory 0xA10B2E size 1 value 0 virtual_protect 0
05E0: 0@ = read_memory 1@ 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. 1@ = 10
2. store value from variable 1@ in memory

PM
  Top
 

 
Link2012  
Posted: Monday, Aug 6 2012, 19:03
Quote Post


Wut?
Group Icon
Group: Members
Joined: Jan 30, 2011

ba.gif

XXXXX



What? Fastman92 give you the answer, do you want a example?
So:
CODE
1@ = 10
05DF: write_memory ? size 4 value 1@ virtual_protect 0


This post has been edited by Link2012 on Tuesday, Aug 7 2012, 02:52
PMMSN
  Top
 

 
Ify24  
Posted: Monday, Aug 6 2012, 19:04
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



Yes, but what memory adress should I use ?

I don't want to do something effective in-game with memory adress.
EDIT:
This variable 1@ will be used in script, not just as a memory value, but will b stored there.

This post has been edited by Ify24 on Monday, Aug 6 2012, 19:12
PM
  Top
 

 
Link2012  
Posted: Monday, Aug 6 2012, 19:11
Quote Post


Wut?
Group Icon
Group: Members
Joined: Jan 30, 2011

ba.gif

XXXXX



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

CODE
:Hey_PutNumber10Here
hex
00 00 00 00 // 4 bytes
end


CODE
05F7: 0@ = label @label offset

To get the offset of the label

PMMSN
  Top
 

 
fastman92  
Posted: Monday, Aug 6 2012, 19:25
Quote Post


фастман92 | ف
Group Icon
Group: Members
Joined: Jul 28, 2009

pl.gif

XXXXX



QUOTE (Link2012 @ Monday, Aug 6 2012, 20:11)
CODE
05F7: 0@ = label @label offset

To get the offset of the label

Where did you get this opcode from, there's no 05F7: 0@ = 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

CODE
05F5: call_scm_func @GetBaseIP 0 store_to 3@

// you can do
// 3@ -= @label
// to get memory address to @label



This post has been edited by fastman92 on Monday, Aug 6 2012, 19:37
Users WebsitePMMSN
  Top
 

 
Link2012  
Posted: Monday, Aug 6 2012, 19:27
Quote Post


Wut?
Group Icon
Group: Members
Joined: Jan 30, 2011

ba.gif

XXXXX



That's for VC
PMMSN
  Top
 

 
Ify24  
Posted: Monday, Aug 6 2012, 20:40
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



QUOTE (Link2012 @ Monday, Aug 6 2012, 19:11)
CODE

:Hey_PutNumber10Here
hex
00 00 00 00 // 4 bytes
end



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.
PM
  Top
 

 
Deji  
Posted: Monday, Aug 6 2012, 21:10
Quote Post


Coding like a Rockstar!
Group Icon
Group: Members
Joined: Dec 24, 2007

ja.gif

XXXXX



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.
Users WebsitePM
  Top
 

 
Ify24  
Posted: Monday, Aug 6 2012, 21:22
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



CODE
:Hey_PutNumber10Here
hex
00 00 00 00 // 4 bytes
end


05F7: 0@ = label @label offset


So let's analize this code.

first we create a lable like

CODE
:BLABLA

and then this

CODE
hex
numbers      <--- what to type here
end


CODE
05F7: 0@ = label @label offset // <--- and with this we ???
PM
  Top
 

 
Wesser  
Posted: Monday, Aug 6 2012, 21:36
Quote Post


The complexity simplifier, the efficiency optimizer
Group Icon
Group: Members
Joined: Aug 19, 2006

eu.gif

Member Award




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.
PMMSNPlayStation Network
  Top
 

 
Ashwin the new boy  
Posted: Tuesday, Aug 7 2012, 12:04
Quote Post


I am The Most Confused Person
Group Icon
Group: Members
Joined: Nov 14, 2010

ia.gif

XXXXX



QUOTE
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)
Users WebsitePM
  Top
 

 
Ify24  
Posted: Tuesday, Aug 7 2012, 13:44
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



QUOTE (Ashwin the new boy @ Tuesday, Aug 7 2012, 12:04)
QUOTE
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.
PM
  Top
 

 
Ashwin the new boy  
Posted: Tuesday, Aug 7 2012, 14:57
Quote Post


I am The Most Confused Person
Group Icon
Group: Members
Joined: Nov 14, 2010

ia.gif

XXXXX



QUOTE
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

---------------------------------------------------------------
QUOTE
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

This post has been edited by Ashwin the new boy on Tuesday, Aug 7 2012, 15:13
Users WebsitePM
  Top
 

 
fastman92  
Posted: Tuesday, Aug 7 2012, 15:16
Quote Post


фастман92 | ف
Group Icon
Group: Members
Joined: Jul 28, 2009

pl.gif

XXXXX



QUOTE (Deji @ Monday, Aug 6 2012, 22:10)
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 0@(0@,1i) ; 1@(0@,1i)
where 1@ is index pointing to label

When it comes to CLEO opcodes - you can put
CODE
0AB0:   key_pressed 1@(0@,1i)


But not
CODE
0AC6: 1@(0@,1i) = label @label offset

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

A workaround to this problem is
CODE
0AC6: 5@ = label @label offset
0085: 1@(0@,1i) = 5@ // (int)


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

 
Ashwin the new boy  
Posted: Tuesday, Aug 7 2012, 15:33
Quote Post


I am The Most Confused Person
Group Icon
Group: Members
Joined: Nov 14, 2010

ia.gif

XXXXX



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,
Users WebsitePM
  Top
 

 
fastman92  
Posted: Tuesday, Aug 7 2012, 15:52
Quote Post


фастман92 | ف
Group Icon
Group: Members
Joined: Jul 28, 2009

pl.gif

XXXXX



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.

QUOTE
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.
Users WebsitePMMSN
  Top
 

 
Ify24  
Posted: Tuesday, Aug 7 2012, 16:43
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



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.

QUOTE
I used some Unused Stats memory address for that purpose

Do you still have them? (memory adresses?)

This post has been edited by Ify24 on Tuesday, Aug 7 2012, 17:04
PM
  Top
 

 
Deji  
Posted: Tuesday, Aug 7 2012, 17:22
Quote Post


Coding like a Rockstar!
Group Icon
Group: Members
Joined: Dec 24, 2007

ja.gif

XXXXX



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
Users WebsitePM
  Top
 

 

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

0 Members:

Pages: (2) [1] 2 

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG