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

    1. GTANet.com

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

      1. St Andrews Cathedral
    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 Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

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

      1. Guides & Strategies
      2. Help & Support
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
    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

      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. 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. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

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

    1. Announcements

    2. Support

    3. Suggestions

Sign in to follow this  
TheSiggi

[Q] issue with created globals

Recommended Posts

TheSiggi

Hi,

 

When I create globals in custom script, it seems like Sannys compiler messes these globals up

 

eg.:

 

I created:

 

 

$TEMPVAR_FLOAT_Z_ALTITUDE = 0.0    $TEMPVAR_FLOAT_Z_DISTANCE = 0.0   

 

 

 

I set them to 0.0 to 'initialize' them but after decompiling the turned into

 

 $4 = 0.0$5 = 0.0

 

now ingame the text draw gives me strange numbers (I can remember something like 19aaaaaaaaaaa) *a = any number-to show the length

 

Also I recognized that the global from James227uk's Ammo mod ($CURRENTGUN or $CURRGUN) turned into $4 aswell and since this problem occours, the ammo mod doesn't waorrk anymore bored.gif

 

Is there a way to fix the issue of renaming vars?

 

Is there any possibilty to fix that issue?

thanks in advance

 

cheers,

The_Siggi

Edited by The_Siggi

Share this post


Link to post
Share on other sites
james227uk

I think that when a script is compiled, the globals are turned into number globals. That is how CLEO-SCM conflicts occur

 

But I could always be wrong since I never really looked into the sibject

Share this post


Link to post
Share on other sites
ZAZ

main.scm or cleo?

have you changed settings in options/Format: Angepasste Variablenamen ? (custom variablenames)

 

Edited by ZAZ

Share this post


Link to post
Share on other sites
TheSiggi

I'm sorry I forgot blush.gif : CLEO 3

and nope, I never changed anything in the Sannysettings except for language and compile scrip ' As is' beside syntax highlighting but what do I have to change there?

btw. thanks for your fast repplys

 

 

d'oh.... could it be that the upper one is a coord but since the text draw doesn't support coords it doesn't show the comma?

 

 

Edited by The_Siggi

Share this post


Link to post
Share on other sites
Wesser

SB compiler doesn't recognize global vars as their name on his own since they are offsets. You should assign all name with the relative offsets by adding these lines in data/sa/CustomVariables.ini:

 

10948=TEMPVAR_FLOAT_Z_ALTITUDE10949=TEMPVAR_FLOAT_Z_DISTANCE

 

Share this post


Link to post
Share on other sites
ZAZ

 

I'm sorry I forgot blush.gif : CLEO 3

and nope, I never changed anything in the Sannysettings except for language and compile scrip ' As is' beside syntax highlighting but what do I have to change there?

btw. thanks for your fast repplys

 

d'oh.... could it be that the upper one is a coord but since the text draw doesn't support coords it doesn't show the comma?

 

 

don't know colgate.gif

it always decompiles as it was written

and I don't have $TEMPVAR_FLOAT_Z_ALTITUDE in my CustomVariables.ini

 

// This file was decompiled using sascm.ini published by Seemann (http://sannybuilder.com/files/SASCM.rar) on 13.10.2007{$VERSION 3.1.0027}{$CLEO .cs}//-------------MAIN---------------$TEMPVAR_FLOAT_Z_ALTITUDE = 0.0 $TEMPVAR_FLOAT_Z_DISTANCE = 0.0 0A93: end_custom_thread 

 

 

i didn't got the pics, only empty sites on abload.de

 

Edited by ZAZ

Share this post


Link to post
Share on other sites
TheSiggi

Uploaded the photos somewhere else: http://img293.imageshack.us/gal.php?g=ce1200620102.jpg

 

@Wesser: I can't because Windows says it can't change the file due to an unknown issue; I added them here:

 

 

; 10947=useless; highest variable ever10948=TEMPVAR_FLOAT_Z_ALTITUDE10949=TEMPVAR_FLOAT_Z_DISTANCE

 

 

wouldn't this edit of CustomVariables.ini occour trouble at somebody elses pc? Because then theri Sannybuilder will mess up these globals

 

@ZAZ: odd, I know that something changed my Sanny since I could decompile all other mods (eg. James227uk's ammo mod) and the correct global names showed up

 

Share this post


Link to post
Share on other sites
Wesser

There's no way to print up coords because of the param type of text-draw opcodes. I wrote a simple cleo function to hack this limit:

 

{$CLEO}0000: NOP03F0: enable_text_draw 1 while true wait 0  0AB1: call_scm_func @drawFloatAt 4 posX 320.0 poxY 240.0 num 1.25 dec 2 end:getTruncVal{ Parameters:   Passed:     [email protected] - number     [email protected] - decimals   Result:     [email protected] - float Example:   0AB1: call_scm_func @getTruncVal 2 num 0.5465 dec 2 store_to [email protected] }0AB1: call_scm_func @getPowVal 2 num 10 exp [email protected] store_to [email protected] 0093: [email protected] = integer [email protected] to_float006B: [email protected] *= [email protected] 0092: [email protected] = float [email protected] to_integer0093: [email protected] = integer [email protected] to_float0073: [email protected] /= [email protected] 0AB2: ret 1 [email protected] :getDecVal{ Parameters:   Passed:     [email protected] - number   Result:     [email protected] - float Example:   0AB1: call_scm_func @getDecVal 1 num 1.5 store_to [email protected] }0AB1: call_scm_func @getIntVal 1 num [email protected] store_to [email protected] 0063: [email protected] -= [email protected] 0AB2: ret 1 [email protected] :getPowVal{ Parameters:   Passed:     [email protected] - base     [email protected] - exponent   Result:     [email protected] - integer/float Example:   0AB1: call_scm_func @getPowVal 2 num 2 exp 3 store_to [email protected] }0085: [email protected] = [email protected] if  [email protected] > 0 then for [email protected] = 1 to [email protected]    if      [email protected] > 1    then     006A: [email protected] *= [email protected]    end endelse if    [email protected] < 0  then   0093: [email protected] = integer [email protected] to_float   0093: [email protected] = integer [email protected] to_float   for [email protected] = -1 to [email protected]      if        [email protected] < -1      then       006B: [email protected] *= [email protected]      end   end   [email protected] = 1.0    0073: [email protected] /= [email protected]    0087: [email protected] = [email protected]  else   [email protected] = 1  endend0AB2: ret 1 [email protected] :drawFloatAt{ Parameters:   Passed:     [email protected] - position x     [email protected] - position y     [email protected] - number     [email protected] - decimals -> 1 to 8   Result:     none Example:   0AB1: call_scm_func @drawFloatAt 4 320.0 240.0 num 1.25 dec 2 }0AB1: call_scm_func @getTruncVal 2 num [email protected] dec [email protected] store_to [email protected] 0AB1: call_scm_func @getDecVal 1 num [email protected] store_to [email protected] 0AB1: call_scm_func @getPowVal 2 num 10 exp [email protected] store_to [email protected] 0093: [email protected] = integer [email protected] to_float006B: [email protected] *= [email protected] 0AB1: call_scm_func @getIntVal 1 num [email protected] store_to [email protected] 0085: [email protected] = [email protected] 0092: [email protected] = float [email protected] to_integer0092: [email protected] = float [email protected] [email protected] = False [email protected] = 0x30 [email protected] -= 1 for [email protected] = 0 to [email protected]  0AB1: call_scm_func @getDecVal 1 num [email protected] store_to [email protected]  [email protected] *= 10.0  0AB1: call_scm_func @getIntVal 1 num [email protected] store_to [email protected]  0063: [email protected] -= [email protected]  0087: [email protected] = [email protected]  0092: [email protected] = float [email protected] to_integer if and   [email protected] == 0    [email protected] == False  then   if    803B:  [email protected] <> [email protected]    then     [email protected] += 0x1    else     [email protected] = 0x30    end else   [email protected] = True  [email protected] = 'NUMFLT' 098B: [email protected] = [email protected] + [email protected] 045B: draw_text_2numbers [email protected] [email protected] GXT [email protected] numbers [email protected] [email protected] 0AB2: ret 0 

 

This is the the content of the .fxt file to draw from 1 up to 7 zeroes as well:

 

NUMFLT0 ~1~.~1~NUMFLT1 ~1~.0~1~NUMFLT2 ~1~.00~1~NUMFLT3 ~1~.000~1~NUMFLT4 ~1~.0000~1~NUMFLT5 ~1~.00000~1~NUMFLT6 ~1~.000000~1~NUMFLT7 ~1~.0000000~1~

 

I don't know why that error occurs, maybe these var names are too long. I've already tried to add some and it worked. confused.gif

Edited by Wesser

Share this post


Link to post
Share on other sites
TheSiggi

odd,

I'll post my script so you can imagine what this trouble is all about

 

 

{$CLEO}thread 'PPT'0662: NOP "Parachute teleportation script"const   DEVKey = 0x30 // 0    Para = 371 // #GUN_PARA   KEY_Jump = 14   KEY_Crouch = 18   KEY_Exit = 15end$TEMPVAR_ALTITUDE = 0.0    // TEMPVAR_FLOAT_Z_ALTITUDE stores the players Z coord $TEMPVAR_DISTANCE = 0.0    // TEMPVAR_FLOAT_Z_DISTANCE stores the players distance from ground:STARTwait 10if0256:   player $PLAYER_CHAR defined jf @STARTif03EE:   player $PLAYER_CHAR controllable jf @STARTif056D:   actor $PLAYER_ACTOR defined jf @START                                  if and80DF:   not actor $PLAYER_ACTOR driving84AD:   not actor $PLAYER_ACTOR in_water8818:   not actor $PLAYER_ACTOR in_air jf @STARTif0ab0: DEVKeyjf @STARTjump @SETTINGS:SETTINGS// label was created to increase the scripts readability04D7: set_actor $PLAYER_ACTOR locked 101B4: set_player $PLAYER_CHAR can_move 003F0: enable_text_draw 1 //-------------------------------if8491:   not actor $PLAYER_ACTOR has_weapon 46 then   0247: load_model Para  // 371 // #GUN_PARA   gosub @LOAD_MODEL_CHECK   wait 0   01B2: give_actor $PLAYER_ACTOR weapon 46 ammo 1 // Load the weapon model before using this    wait 0   0249: Para // 371 // #GUN_PARAendwhile true    wait 10   if or   8256:   not player $PLAYER_CHAR defined    856D:   not actor $PLAYER_ACTOR defined      then       break // -- cleanup   end   // TEMPVAR_ALTITUDE stores the players Z coord    00A0: store_actor $PLAYER_ACTOR position_to [email protected] [email protected] $TEMPVAR_ALTITUDE   $TEMPVAR_ALTITUDE-= 1.0    0819: $TEMPVAR_DISTANCE = actor $PLAYER_ACTOR distance_from_ground   008E: [email protected] = float $TEMPVAR_ALTITUDE to_integer    008E: [email protected] = float $TEMPVAR_DISTANCE to_integer      008D: $TEMPVAR_ALTITUDE = integer [email protected] to_float    008D: $TEMPVAR_DISTANCE = integer [email protected] to_float    04F7: status_text $TEMPVAR_ALTITUDE type 0 line 1 GXT 'DUMMY' // global_variable   04F7: status_text $TEMPVAR_DISTANCE type 0 line 2 GXT 'DUMMY' // global_variable   if   00E1:   player 0 pressed_key KEY_Jump // KEY Jump     then       04C4: store_coords_to [email protected] [email protected] $TEMPVAR_ALTITUDE from_actor $PLAYER_ACTOR with_offset 0.0 0.0 4.5       wait 0       00A1: put_actor $PLAYER_ACTOR at [email protected] [email protected] $TEMPVAR_ALTITUDE   end   if   00E1:   player 0 pressed_key KEY_Crouch // KEY_Crouch     then       04C4: store_coords_to [email protected] [email protected] $TEMPVAR_ALTITUDE from_actor $PLAYER_ACTOR with_offset 0.0 0.0 -5.5       wait 0       00A1: put_actor $PLAYER_ACTOR at [email protected] [email protected] $TEMPVAR_ALTITUDE   end   if   00E1:   player 0 pressed_key KEY_Exit     then       if       50.0 > $TEMPVAR_DISTANCE         then           00A0: store_actor $PLAYER_ACTOR position_to [email protected] [email protected] [email protected]            02CE: [email protected] = ground_z_at [email protected] [email protected] [email protected]           00A1: put_actor $PLAYER_ACTOR at [email protected] [email protected] [email protected]           break // -- cleanup       end       break // -- cleanup   endend    0151: remove_status_text $TEMPVAR_ALTITUDE 0151: remove_status_text $TEMPVAR_DISTANCE $TEMPVAR_FALTITUDE = 0.0   $TEMPVAR_DISTANCE = 0.004D7: set_actor $PLAYER_ACTOR locked 001B4: set_player $PLAYER_CHAR can_move 103F0: enable_text_draw 0 [email protected] = [email protected] = [email protected] = [email protected] = 0.0wait 10jump @START:LOAD_MODEL_CHECKwait 4if0248: Para // 371 // #GUN_PARAjf @LOAD_MODEL_CHECKreturn

 

 

I guess there's something wrong with this part then:

 

 

   // TEMPVAR_ALTITUDE stores the players Z coord  00A0: store_actor $PLAYER_ACTOR position_to [email protected] [email protected] $TEMPVAR_ALTITUDE  $TEMPVAR_ALTITUDE-= 1.0  0819: $TEMPVAR_DISTANCE = actor $PLAYER_ACTOR distance_from_ground  008E: [email protected] = float $TEMPVAR_ALTITUDE to_integer  008E: [email protected] = float $TEMPVAR_DISTANCE to_integer    008D: $TEMPVAR_ALTITUDE = integer [email protected] to_float  008D: $TEMPVAR_DISTANCE = integer [email protected] to_float  04F7: status_text $TEMPVAR_ALTITUDE type 0 line 1 GXT 'DUMMY' // global_variable  04F7: status_text $TEMPVAR_DISTANCE type 0 line 2 GXT 'DUMMY' // global_variable

 

Edited by The_Siggi

Share this post


Link to post
Share on other sites
Wesser

I'm a bit confused but when the problem occurs? Does it show when you print it onscreen or when the game reads those values?

Share this post


Link to post
Share on other sites
TheSiggi
right after I ress 0 to activate the script, the first photo shows the values I get when I activated the script and the second photo was taken while I was in air, and the third shows the formates settings of my Sannybuilder Edited by The_Siggi

Share this post


Link to post
Share on other sites
Wesser

It's normal you get these strange values cause it isn't allowed to use float vars for 04F7. bored.gif

Share this post


Link to post
Share on other sites
ZAZ

 

odd,

I'll post my script so you can imagine what this trouble is all about

 

I guess there's something wrong with this part then:

 

 

   // TEMPVAR_ALTITUDE stores the players Z coord  00A0: store_actor $PLAYER_ACTOR position_to [email protected] [email protected] $TEMPVAR_ALTITUDE  $TEMPVAR_ALTITUDE-= 1.0  0819: $TEMPVAR_DISTANCE = actor $PLAYER_ACTOR distance_from_ground  008E: [email protected] = float $TEMPVAR_ALTITUDE to_integer  008E: [email protected] = float $TEMPVAR_DISTANCE to_integer    008D: $TEMPVAR_ALTITUDE = integer [email protected] to_float  008D: $TEMPVAR_DISTANCE = integer [email protected] to_float  04F7: status_text $TEMPVAR_ALTITUDE type 0 line 1 GXT 'DUMMY' // global_variable  04F7: status_text $TEMPVAR_DISTANCE type 0 line 2 GXT 'DUMMY' // global_variable

 

this makes sense:

 

Actor.StorePos($PLAYER_ACTOR, [email protected], [email protected], [email protected])[email protected] -= 1.0 0819: [email protected] = actor $PLAYER_ACTOR distance_from_ground 008E: $TEMPVAR_ALTITUDE = float [email protected] to_integer 008E: $TEMPVAR_DISTANCE = float [email protected] to_integer  04F7: status_text $TEMPVAR_ALTITUDE type 0 line 1 GXT 'DUMMY' // global_variable 04F7: status_text $TEMPVAR_DISTANCE type 0 line 2 GXT 'DUMMY' // global_variable

 

 

also the globals are decompiled as they was written

 

// This file was decompiled using sascm.ini published by Seemann (http://sannybuilder.com/files/SASCM.rar) on 13.10.2007{$VERSION 3.1.0027}{$CLEO .cs}//-------------MAIN---------------thread 'PPT' 0662: NOP "PARACHUTE TELEPORTATION SCRIPT" $TEMPVAR_ALTITUDE = 0.0 $TEMPVAR_DISTANCE = 0.0 :PPT_65wait 10 if   Player.Defined($PLAYER_CHAR)jf @PPT_65

 

 

Share this post


Link to post
Share on other sites
TheSiggi

Okay,

 

I fixed these parts to make the script a bit more logical:

 

 

[...]if8491:   not actor $PLAYER_ACTOR has_weapon 46 then   0247: load_model Para  // 371 // #GUN_PARA   gosub @LOAD_MODEL_CHECK   wait 0   01B2: give_actor $PLAYER_ACTOR weapon 46 ammo 1 // Load the weapon model before using this    wait 0   0249: Para // 371 // #GUN_PARAendwhile true    wait 10   if or   8256:   not player $PLAYER_CHAR defined    856D:   not actor $PLAYER_ACTOR defined      then       break // -- cleanup   end   // TEMPVAR_ALTITUDE stores the players Z coord    00A0: store_actor $PLAYER_ACTOR position_to [email protected] [email protected] [email protected]   [email protected] -= 1.0   // 0819: [email protected] = actor $PLAYER_ACTOR distance_from_ground   008E: $TEMPVAR_ALTITUDE = float [email protected] to_integer    008E: $TEMPVAR_DISTANCE = float [email protected] to_integer   04F7: status_text $TEMPVAR_ALTITUDE type 0 line 1 GXT 'DUMMY' // global_variable   04F7: status_text $TEMPVAR_DISTANCE type 0 line 2 GXT 'DUMMY' // global_variable   if   00E1:   player 0 pressed_key KEY_Jump // KEY Jump     then       04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 0.0 0.0 4.5       wait 0       00A1: put_actor $PLAYER_ACTOR at [email protected] [email protected] [email protected]       008E: $TEMPVAR_ALTITUDE = float [email protected] to_integer   end   if   00E1:   player 0 pressed_key KEY_Crouch // KEY_Crouch     then       04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 0.0 0.0 -5.5       wait 0       00A1: put_actor $PLAYER_ACTOR at [email protected] [email protected] [email protected]                                                          008E: $TEMPVAR_ALTITUDE = float [email protected] to_integer   end   if   00E1:   player 0 pressed_key KEY_Exit     then        0819: [email protected] = actor $PLAYER_ACTOR distance_from_ground       if       50.0 > [email protected]         then           00A0: store_actor $PLAYER_ACTOR position_to [email protected] [email protected] [email protected]            02CE: [email protected] = ground_z_at [email protected] [email protected] [email protected]           00A1: put_actor $PLAYER_ACTOR at [email protected] [email protected] [email protected]           break // -- cleanup       end       break // -- cleanup   endend    [...]

 

I only have to fix the distance to ground display smile.gif

thanx alot guys

 

take some cookies (warning, they're still hot biggrin.gif) cookie.gifcookie.gifcookie.gifcookie.gif

 

but the globals are still messed up sneaky2.gif

 

@ZAZ:

can you check the screenshot of my format settings and yours? maybe I messed something up in the option menu (although I use a fresh install of Sanny and deleted my Sannybuilder folder aswell mercie_blink.gif )

 

 

Edited by The_Siggi

Share this post


Link to post
Share on other sites
Silent

ZAZ, but they are compiled as numbers and can cause errors, so if you REALLY need to use globals in CLEO, write something like this on the top of script:

 

alloc($TEMPVAR_ALTITUDE,10948)alloc($TEMPVAR_DISTANCE,10949)

 

That WILL mess up variable names even if 'Custom variable names' is enabled, but that will fix compiling to low numbers like $4.

 

You can use also $TEMPVAR_FLOAT_1 and $TEMPVAR_FLOAT_2 globals. These are allocated in game to store data, and they exists at every SCM & CustomVariables.ini.

 

OR you can use Seeman's script to use local variables in status text:

http://sannybuilder.com/forums/viewtopic.php?id=255

Sadly, the website is down by now confused.gif

Edited by SilentPL

Share this post


Link to post
Share on other sites
TheSiggi

 

ZAZ, but they are compiled as numbers and can cause errors, so if you REALLY need to use globals in CLEO, write something like this on the top of script:

 

alloc($TEMPVAR_ALTITUDE,10948)alloc($TEMPVAR_DISTANCE,10949)

 

That WILL mess up variable names even if 'Custom variable names' is enabled, but that will fix compiling to low numbers like $4.

 

You can use also $TEMPVAR_FLOAT_1 and $TEMPVAR_FLOAT_2 globals. These are allocated in game to store data, and they exists at every SCM & CustomVariables.ini.

 

OR you can use Seeman's script to use local variables in status text:

http://sannybuilder.com/forums/viewtopic.php?id=255

Sadly, the website is down by now  confused.gif

But $TEMPVAR_1 -3 are used in the main alot, so its even more likely that the game crashes while using $TEMVAR_1 -3 with different values and even data types at the same times as the usage of 2 created globals does

Share this post


Link to post
Share on other sites
Silent

So wait for Sannybuilder forums and use Seeman's script to use local vars to status text - it's the best way, I think.

Share this post


Link to post
Share on other sites
Wesser

I've already explained how to add custom variable names some posts above and I've just got it to work again. smile.gif

 

I added these lines at the very end of the CustomVariables.ini file:

 

10948=TEMPVAR_ALTITUDE10949=TEMPVAR_DISTANCE

 

Share this post


Link to post
Share on other sites
Silent

You are right, but globals in CLEO can cause problems with modded SCM, when CLEO is using $10948 and SCM too wink.gif

Edited by SilentPL

Share this post


Link to post
Share on other sites
Wesser

What kind of bug could it cause? I haven't ever found one when scripting with CLEO using global vars. dozingoff.gif

Share this post


Link to post
Share on other sites
Silent

When SCM and CLEO uses same variable. For example:

In that CLEO $10948 is height data + in modded SCM $10948 is car number 489534086489608590859 handle = crash, bugs blahblahblah.

Share this post


Link to post
Share on other sites
Wesser

That's not a real bug but an user mistake which is really different. wink.gif

Share this post


Link to post
Share on other sites
Seemann

sb dot com is up, sorry, I've had some troubles with payment dozingoff.gif .

 

The answer is, DO NOT add your own custom global variables in a CLEO script. The compiler when it sees a global variable in a script (cleo or main.scm, it does not matter) firstly checks the CustomVariables.ini file if there's a pre-defined offset for this one. Any variable are compiled and then read by the game under a specific number (2, 3, 4, etc). This number is the offset from the beginning of the main.scm where all global variables store their values. If the CustomVariables.ini file does not contain such a name, the compiler uses first free number to allocate the variable. It will always be number 4, as 2 is $PLAYER_CHAR, and $3 is PLAYER_ACTOR. Any new custom variable met by the compiler will be compiled as $4. Next variable as - $5. Etc.

 

So, when two CLEO scripts use a custom variable that are not defined in the CustomVariables.ini, they both will share SAME memory slot (if one CLEO script will set $VAR1 to 100, another script's $VAR2 will have same value of 100).

 

Most times you've to work with local variables in CLEO. For the status_texts the game requires a global variable, so I made a simple script that allows to use local variables there. The link was already given but I repeat:

http://sannybuilder.com/forums/viewtopic.php?id=255

Share this post


Link to post
Share on other sites
Silent

Seemann, so 'alloc' function does not work in CLEO?

Share this post


Link to post
Share on other sites
Wesser

The SB "alloc" function doesn't do anything but it's just a formal way to decleare a global var using a name instead of its offset. I never used it but I think that's true. wink.gif

Share this post


Link to post
Share on other sites
Deji

I still don't exactly understand the global variable problems, but I kinda get why using them can be a bad idea.

 

Still, nothing has stopped me from simply using read/write_memory as a replacement. It's still good to check which globals you're trying to mess with, though.

 

 

I like to create SCM functions to work like operators...

 

 

(call @SetGlob 4 255):SetGlob(calculate address for $4)(writes 255 to the address for $4)

 

 

etc. But lately file operations seem like the best way, however I'm still annoyed by the lack of ways to basically "save" information in a CLEO.

 

For example, when the player saves, I want CLEO to save.. But there is no way I know of determining the slot the player saved to, so all CLEO information saved would be used for all slots... Annoying.

 

If the use for permanent globals existed (ones where I could be sure another CLEO thread would not interfere with the value of the globals I used) I could use them to detirmine which individual file to save to. I'll try looking for a function to return the last slot that was saved to, though.

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  

  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

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