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

[SA] Maximum clip ammo


aStiffSausage
 Share

Recommended Posts

aStiffSausage

So, as most of you know, you can read current ammo in clip with this little snippet:

 

 

  0A96: [email protected] = actor $PLAYER_ACTOR struct [email protected] += 0x718 // Current Weapon Slot0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0 0A96: [email protected] = actor $PLAYER_ACTOR struct [email protected] += 0x5A0 // Start of weapon data (28 bytes)[email protected] *= 28 005A: [email protected] += [email protected] // Get weapon [email protected] += 8 // Pointer to "Ammo in clip"0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0 // Ammo in clip

 

 

But, what about getting the maximum ammo in clip?

 

EDIT: Oh, and how I can disable automatic reload when there is no ammo in clip?

Edited by oksa8
Link to comment
Share on other sites

You can set the player idle when the player is reloading, so no reload animation.

 

05B9: AS_actor $PLAYER_ACTOR stay_idle 1 ms

 

If the weapon ammo is reloaded by itself, you can write to the memories right? The current ammo in clip and the current ammo remaining.

idk if it can works.

Link to comment
Share on other sites

aStiffSausage

I tried few things, like checking when ammo in clip is zero, then waiting until weapon state is set to 2 (reloading), and then writing it to 0. It almost worked, player did the reload-animation but the ammo in clip stayed at 0, but as soon as you fire, the clip ammo goes to maximum.

Link to comment
Share on other sites

Take this snippet to get the maximum ammo in clip:

 

{$CLEO}const   FIRETYPE_MELEE = 0   FIRETYPE_INSTANT_HIT = 1   FIRETYPE_PROJECTILE = 2   FIRETYPE_AREA_EFFECT = 3   FIRETYPE_CAMERA = 4   FIRETYPE_USE = 5end0000: NOPwhile true   wait 0   0470: [email protected] = actor $PLAYER_ACTOR current_weapon   0A96: [email protected] = actor $PLAYER_ACTOR struct   0AA8: call_function_method 0x5E6580 struct [email protected] num_params 0 pop 0 cSkillIndex [email protected] // CPed__getWeaponSkillIndex   0AA7: call_function 0x743C60 num_params 2 pop 2 cSkillIndex [email protected] sWeaponType [email protected] pclWeaponInfo [email protected] // getWeaponInfo   //[email protected] += 0x00 // CWeaponInfo.m_eFireType   0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0   if       [email protected] == FIRETYPE_INSTANT_HIT   then       [email protected] += 0x20 // CWeaponInfo.m_sMaxClipAmmo       0A8D: [email protected] = read_memory [email protected] size 2 virtual_protect 0       // [email protected] will contain the maximum ammo in clip.   endend

 

As regards disabling the automatic reload, I have to check.

012          345
678   9A   BCD
EFG HIJK LMN
OPQR  STUV
WX    YZ

Link to comment
Share on other sites

aStiffSausage

Thank you, it works like a charm! smile.gif

 

And well, just a question about disabling the automatic reload, is it basically just disabling the function that calls reload when ammo in clip is zero?

Link to comment
Share on other sites

You can try the same method you but use -------> 0792: disembark_instantly_actor $PLAYER_ACTOR

 

Link to comment
Share on other sites

Okey, after few hours I drew up a proper reload script which is seemingly what are you asking for:

 

{$CLEO}const   FIRETYPE_MELEE = 0   FIRETYPE_INSTANT_HIT = 1   FIRETYPE_PROJECTILE = 2   FIRETYPE_AREA_EFFECT = 3   FIRETYPE_CAMERA = 4   FIRETYPE_USE = 5endconst   FIRESTATE_IDLE = 0   FIRESTATE_FIRE = 1   FIRESTATE_RELOAD = 2   // There are probably more.endvar   [email protected]: Integer   [email protected]: Integerend0000: [email protected] = [email protected] = 0// Disable automatic reload when scrolling weapons.0A8C: write_memory 0x0060B4DA size 4 value 0xEB08C483 virtual_protect 10A8C: write_memory 0x0060B4DE size 1 value 0x21 virtual_protect 1while true   wait 0   0A96: [email protected] = actor $PLAYER_ACTOR struct   0AA8: call_function_method 0x5E6580 struct [email protected] num_params 0 pop 0 cSkillIndex [email protected] // CPed__getWeaponSkillIndex   0470: [email protected] = actor $PLAYER_ACTOR current_weapon   0AA7: call_function 0x743C60 num_params 2 pop 2 cSkillIndex [email protected] sWeaponType [email protected] pclWeaponInfo [email protected] // getWeaponInfo   0A8E: [email protected] = [email protected] + 0x00 // CWeaponInfo.m_eFireType   0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0   if       [email protected] == FIRETYPE_INSTANT_HIT   then       0A8E: [email protected] = [email protected] + 0x0718 // CPed.m_cWeaponSlot       0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0       [email protected] *= 0x1C // sizeof(CWeaponSlot)       0A8E: [email protected] = [email protected] + 0x5A0 // CPed.m_aclWeaponSlots       005A: [email protected] += [email protected]       0A8E: [email protected] = [email protected] + 0x04 // CWeaponSlot.m_iFireState       0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0       if and           [email protected] == true           not [email protected] == FIRESTATE_RELOAD       then           // Disable automatic reload when the weapon clip is empty.           0A8C: write_memory 0x006860D2 size 2 value 0xE990 virtual_protect 1           0A8C: write_memory 0x0060F1F5 size 2 value 0x15EB virtual_protect 1           0992: set_player $PLAYER_CHAR weapons_scrollable 1           [email protected] = false       end       0A8E: [email protected] = [email protected] + 0x20 // CWeaponInfo.m_sMaxClipAmmo       0A8D: [email protected] = read_memory [email protected] size 2 virtual_protect 0       0A8E: [email protected] = [email protected] + 0x08 // CWeaponSlot.m_sClipAmmo       0A8D: [email protected] = read_memory [email protected] size 2 virtual_protect 0       if or           [email protected] > [email protected]           [email protected] == 0       then           if and               [email protected] == false               [email protected] > 250           0AB0:  key_pressed 0x52 // R           then               if                   not [email protected] == FIRESTATE_RELOAD               then                   0A8C: write_memory [email protected] size 4 value FIRESTATE_RELOAD virtual_protect 0               end               01BD: [email protected] = current_time_in_ms               0AA8: call_function_method 0x743D70 struct [email protected] num_params 0 pop 0 iTime [email protected] // CWeaponInfo__getReloadTime               005A: [email protected] += [email protected]               0A8E: [email protected] = [email protected] + 0x10 // CWeaponSlot.m_iLastBulletTime               0A8C: write_memory [email protected] size 4 value [email protected] virtual_protect 0               // Enable automatic reload when the weapon clip is empty.               0A8C: write_memory 0x006860D2 size 2 value 0x840F virtual_protect 1               0A8C: write_memory 0x0060F1F5 size 2 value 0xBE0F virtual_protect 1               0992: set_player $PLAYER_CHAR weapons_scrollable 0               [email protected] = true               [email protected] = 0           end       end   endend

 

There might be a better way to achieve the same thing but not that much sophisticated than the current script.

 

//Edit: script updated.

Edited by Wesser

012          345
678   9A   BCD
EFG HIJK LMN
OPQR  STUV
WX    YZ

Link to comment
Share on other sites

aStiffSausage

Heh, will probably take a while to get full knowledge on what everything does in your script, but anyways, thanks a lot! If I could, I'd kiss you. smile.gif

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.