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

    3. Suggestions

overwrite dynamic gxt entry


gokuta
 Share

Recommended Posts

This opcode

0ADF: add_dynamic_GXT_entry "_test" text "Test string"

I use gxt entry "_test" in few of my cleo scripts. Perhaps I should not invoke this opcode in each of my cleo scripts, since "_test" may already be created and I can run into memory leakage problems. Am I right? In case I am, I should probably check first whether dynamic gxt entry "_test" already exist. How do I do that?

Link to comment
Share on other sites

  • 2 weeks later...
cardboardbox1230

As you said in the title, 0ADF overwrites the dynamic GXT entry. Don't worry about a GXT-related memory leak in CLEO, since it's a very advanced plugin. If you look in the log (CLEO.log) you can see that CLEO deletes all the dynamic GXT entries upon loading/exiting the game. As for checking whether the GXT entry exists, I'm glad you're doing that. Most modmakers don't bother with compatibility.


For checking whether a GXT entry exists, there is a way:

Spoiler
09FD: get_gxt_string '_TEST' width_to 0@
0A08: get_gxt_string_1number '_TEST' number 0 width_to 1@
if and
0@ <= 0
1@ <= 0
then
// gxt doesn't exist
end

 

Some scripts may also have "~1~" or the like as their content; you have to check for that using 0A08. I learned that the hard way.

 

Here is a little script I wrote that returns a new empty GXT every frame and then destroys it by the next:

Spoiler
{$CLEO .cs}

0000: NOP

03F0: enable_text_draw 1

while true
    //for regular text, clear them immediately after using
    if 0ADC: test_cheat "GXTPRI"
    then 0AB1: call_scm_func @f_GetFreeGXTEntry 0 Ret- zsFreeGXTKey{@v} 15@ 16@ 17@ 18@
        0AD1: show_formatted_text_highpriority "GXT String = %s" time 5000 [email protected]
        0ADF: add_dynamic_GXT_entry [email protected] text "GXT Priority Text Test"
        03E5: show_text_box [email protected]
        0AE0: remove_dynamic_GXT_entry [email protected]
    end
    //for text draw, clear them one frame (wait 0) after using
    if 0ADC: test_cheat "GXTTXD"
    then 32@ = 0
        while 32@ < 5000
            0AB1: call_scm_func @f_GetFreeGXTEntry 0 Ret- zsFreeGXTKey 15@ 16@ 17@ 18@ // long string (@v)
            0AD1: show_formatted_text_highpriority "GXT String = %s" time 0 [email protected]
            0ADF: add_dynamic_GXT_entry [email protected] text "GXT Text-Draw Test"
            033E: set_draw_text_position 320.0 224.0 GXT [email protected]
            wait 0
            0AE0: remove_dynamic_GXT_entry [email protected]
        end
    end
    wait 0
end

:f_GetFreeGXTEntry
//0AB1: call_scm_func @f_GetFreeGXTEntry 0 Ret- zsFreeGXTKey{@v} [email protected] [email protected] [email protected] [email protected]
    for 0@ = 0 to 0xFFFFFFF
    0AD3: [email protected] = format "%X" 0@
    09FD: get_gxt_string [email protected] width_to 5@
    0A08: get_gxt_string_1number [email protected] number 0 width_to 6@
        if and
        5@ <= 0
        6@ <= 0
        then break
        end
    end
0AB2: ret 4 1@ 2@ 3@ 4@

 

 

I know that it seems CPU-intensive, but I didn't notice any FPS loss with this method (CORE 2 DUO E8400 3GHz). Besides, you have to sacrifice performance for compatibility most often than not.

 

Don't worry about running out of GXT strings since you can have 4294967295 different GXT entires, and that's just with the hexadecimal number system. With base-36 number system (upto letter Z), you can have more than 8 Octillion!. You're destroying yours every frame anyway, it will be used again until another script starts using it.

 

I would tell you to migrate to MoonLoader (LUA), but I know how difficult it is. I too find myself coming back to CLEO/SCM from time to time.

Anyways, best of luck. For further help, ask me anytime. I will reply in under 12 hours (at most).

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.