Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

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

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

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

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

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

      1. Documentation
    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. Design Your Own Mission
      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. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

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

    2. Support

    3. Suggestions

How many bytes does the PLAYER's money have [CLEO]


funtikar
 Share

Recommended Posts

OK In another thread I would store $PLAYER_CHAR's money to a variable and pass it to a thread

something like this

 

010B: [email protected] = player $PLAYER_CHAR money0A92: create_custom_thread "statsave.s" [email protected]

 

 

Then this thread will receive it and store it into a file but the problem is I don't know how much byte has the variable taken. I don't know what to put for the size of bytes.

As you can see I replaced the size of bytes with a hash.

 

{$VERSION 3.1.0027}{$CLEO .cs}//-------------MAIN---------------name_thread "statsave"wait 100:statsave_10A9A: [email protected] = openfile "CLEO/stats.dat" mode 0x6277 // write binary mode0A9E: writefile [email protected] size # from [email protected]: closefile [email protected]_thread

 

Edited by funtikar
Link to comment
Share on other sites

1 var = 4 bytes.

Link to comment
Share on other sites

Darn it, I was confused . I thought FF FF was four bytes. since FF FF would only fit 65535 money.. ok problem solved... blush.gif

Link to comment
Share on other sites

Ashwin.Star

if you want to pass it to another thread then you should use global variables!

Link to comment
Share on other sites

if you want to pass it to another thread then you should use global variables!

No, he shouldn't.

Link to comment
Share on other sites

The best practice when writing CLEO scripts is to avoid using global variables except for a few special global variables like $ONMISSION, $PLAYER_CHAR, and $PLAYER_ACTOR. Technically, global variables should work just fine in CLEO scripts, but if you are not very careful then you will overwrite values used by the game, or the game will overwrite your values when CJ engages in certain activities or missions. Even if you are very careful, if you use mods from other players, or try to share your mods with others, there is no way to anticipate which global variables might be used in other scripts. Worse yet, if custom global variable names are used then there is a good chance your script will conflict with the main.scm AND other CLEO scripts.

 

 

 

 

 

 

Link to comment
Share on other sites

Not 'special' global variables, as such. But Sanny must be able to match the global var name with an offset defined in CustomVariables.ini. If it doesn't match an entry, it uses an entry which doesn't exist in the list.

 

For me, compiling:

 

$blah = 0$blah2 = 0

 

Decompiled as:

 

$1557 = 0$1558 = 0

 

 

The resulting offsets may be different for other people (I've messed with my CustomVariables.ini) but people with matching CustomVariables.ini (CustomArrays.ini probably matters as well - my version of the file is empty) files will most likely result in the same number, resulting in conflict.

 

 

But regardless, he doesn't even need global variables. He's correctly passing values to the new script here:

 

0A92: create_custom_thread "statsave.s" [email protected]

 

Edited by Deji
Link to comment
Share on other sites

Ashwin.Star

@deji

i know that,

this is the reason when i use global var in any cleo script,

i use numbers only, begins with $9000 onwards

as vc main scm Gvar not exceed than that,

Link to comment
Share on other sites

 

@deji

i know that,

this is the reason when i use global var in any cleo script,

i use numbers only, begins with $9000 onwards

as vc main scm Gvar not exceed than that,

In fact this variables doesn't exist, but the space that they writes continues going from the last var (The var $0 is write in the first byte of the main.scm, $1 in fifth byte...), the second segment is the models data, the third the mission defs and obviosly then the code segment.

 

So, you're overwriting main.scm information, depending on the variable number you're overwriting the Models defs/, Missions defs or the Code segment, Still overwriting important informations tounge.gif

 

The situation worsens if the user is using a TC or a stripped main, because the var seg/models defs/missions defs is shorter, so the code segment is very easily overwritable (or the things after the code...).

Edited by Link2012
Link to comment
Share on other sites

 

@deji

i know that,

this is the reason when i use global var in any cleo script,

i use numbers only, begins with $9000 onwards

as vc main scm Gvar not exceed than that,

But other CLEO scripts or a modified MAIN could use the same variables. It's much better practise to simply not use them.

Link to comment
Share on other sites

  • 2 weeks later...
Ashwin.Star

 

In fact this variables doesn't exist

ohh, please tell me how many VAR exist then

 

 

The var $0 is write in the first byte of the main.scm, $1 in fourt byte...

ha ha ha, i am laughing on your intelligence,

if you are right then i can make a cleo script which can Modify you main.scm,

 

 

you're overwriting main.scm information

i am using a Global VAR which is not used in SCM, okay,

 

overall, please have some TUT & learn more about Variables,

Link to comment
Share on other sites

Noob, you that need to learn some more about SCM at low level, do you think these tutoriais that you learned explains how the things works inside? No, you need to learn by yourself.

 

Open main.scm with a hex editor and see the global variables space, all with zeros.

 

You like this website, so take a look to VC main.scm structure:

http://www.gtamodding.com/index.php?title=VC_SCM

Edited by Link2012
Link to comment
Share on other sites

Ashwin.Star

Try your self what i said, and tell me if you got any problem, okay.

i don't want to fight with you, lol,

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

belated happy 14th birthday to you LINK,

Link to comment
Share on other sites

Ok ashwin, I will not continue with it.

 

I argued and you not, I show you the way to see the truth and you couldn't see it...

Or you want to continue ignorant or you couldn't admit that was wrong.

 

 

belated happy 14th birthday to you LINK,

THANKS! smile.gif

Link to comment
Share on other sites

Link2012 is right here

Link to comment
Share on other sites

Ashwin.Star

@Link

Your welcome,

 

@fastman

just tell me one thing,

if $9000+ are not used in scm, then why will it overwrite anything in SCM ?

Link to comment
Share on other sites

@fastman

just tell me one thing,

if $9000+ are not used in scm, then why will it overwrite anything in SCM ?

You can't be sure if any custom SCM uses it.

Link to comment
Share on other sites

Think it over.

$2 - 4 bytes, int or float, handle - any number

s$2 - 8 bytes, short string Capacity of 7 chars

v$2 - 16 bytes, long string. Capacity of 15 chars.

 

There is reserved, limited memory space for global variables:

 

.data:00A49960    ; char scmBlock[].data:00A49960     _scmBlock       db 200000 dup(?)      ; 0; DATA XREF: _sub_44CA40+2r

 

 

Capacity of 0x00A49960 depends on

http://www.gtamodding.com/index.php?title=SA_SCM

32 bit int Size of global var space

 

The next thing after variables on scmBlock is mission code.

You're overwritting mission code, because you run out of space defined by 32 bit int Size of global var space in main.scm

 

If you have a trouble with amount of local variables and some more:

 

 

:getAdditionalVarsLabelPointedIndex{Description:     Calculates array index pointing to label   Parameters:  Passed:   [email protected] - label    [email protected] - divider           Result:    [email protected] - index, movement   Example: 0AB1: call_scm_func @getAdditionalVarsLabelPointedIndex 2 label @AdditionalVariables divider 4 store_index_to [email protected]  :AddtionalVariables  hex  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  // alignment  00 00 00 00                                      // [email protected]  00 00 00 00                                      // [email protected]  end    Usage in code:  [email protected]([email protected],1i); [email protected]([email protected],1i) and so on}0A9F: [email protected] = [email protected] += 60    // [email protected] adress0A9F: [email protected] = [email protected] += 0x100A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 00062: [email protected] -= [email protected]  // (int)    @label adress0062: [email protected] -= [email protected]  // (int)   [email protected] pointer - @label [email protected] /= [email protected] += [email protected] *= 160072: [email protected] /= [email protected] // (int)0AB2: ret 1 [email protected]

 

You should know how to use this.

Edited by fastman92
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 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.