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

gokuta

overwrite dynamic gxt entry

Recommended Posts

gokuta

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?

Share this post


Link to post
Share on other sites
gokuta

bump! important

Share this post


Link to post
Share on other sites
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).

  • Like 1

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.


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