[SNIPPET] Ammo in clip

Current Ammo in the clip

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

3@ is the ammo in the clip.

-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.


Maximum Ammo in the clip :


{$CLEO}

const
  FIRETYPE_MELEE = 0
  FIRETYPE_INSTANT_HIT = 1
  FIRETYPE_PROJECTILE = 2
  FIRETYPE_AREA_EFFECT = 3
  FIRETYPE_CAMERA = 4
  FIRETYPE_USE = 5
end

0000: NOP

while true
  wait 0
  0470: 1@ = actor $PLAYER_ACTOR current_weapon
  0A96: 0@ = actor $PLAYER_ACTOR struct
  0AA8: call_function_method 0x5E6580 struct 0@ num_params 0 pop 0 cSkillIndex 2@ // CPed__getWeaponSkillIndex
  0AA7: call_function 0x743C60 num_params 2 pop 2 cSkillIndex 2@ sWeaponType 1@ pclWeaponInfo 0@ // getWeaponInfo
  //0@ += 0x00 // CWeaponInfo.m_eFireType
  0A8D: 3@ = read_memory 0@ size 4 virtual_protect 0
  if
      3@ == FIRETYPE_INSTANT_HIT
  then
      0@ += 0x20 // CWeaponInfo.m_sMaxClipAmmo
      0A8D: 4@ = read_memory 0@ size 2 virtual_protect 0
      // 4@ will contain the maximum ammo in clip.
  end
end

4@ is the maximum ammo count that the clip can contain.
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
Re: Ammo in clip

Here's an function for that so you dont loose variables:

0AB1: @GET_CURRENT_AMMO_IN_CLIP 0 _STORE_TO 0@

:GET_CURRENT_AMMO_IN_CLIP
0A96: 0@ = actor $PLAYER_ACTOR struct
0@ += 0x718 // Current Weapon Slot
0A8D: 1@ = read_memory 0@ size 1 virtual_protect 0
0A96: 0@ = actor $PLAYER_ACTOR struct
0@ += 0x5A0 // Start of weapon data (28 bytes)
1@ *= 28
005A: 0@ += 1@ // Get weapon structure
0@ += 8 // Pointer to "Ammo in clip"
0A8D: 3@ = read_memory 0@ size 1 virtual_protect 0 // Ammo in clip
0AB2: RET 1 3@
 

Grubitsh

Active member
Joined
Jul 28, 2014
Messages
104
Reaction score
0
Re: Ammo in clip

DOes it work with another actor than player_actor ? (like other player on SAMP ?)
 

Grubitsh

Active member
Joined
Jul 28, 2014
Messages
104
Reaction score
0
Re: Ammo in clip

Is there any other way to know the ammo of another player (in samp) ?
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
Re: Ammo in clip

Grubitsh link said:
Is there any other way to know the ammo of another player (in samp) ?

I dont think so. There's no stored info about the ammo of another player. But you can create a cleo that counts how many times he has shoot...
 

Grubitsh

Active member
Joined
Jul 28, 2014
Messages
104
Reaction score
0
Re: Ammo in clip

Opcode.eXe link said:
I dont think so. There's no stored info about the ammo of another player. But you can create a cleo that counts how many times he has shoot...

Ok, thx for replying.

Well at least i was curious and I tried it. It work, I get the number of ammo of a samp streamed player. (of course it's the ammo of the current gun held by the player, not the ammo of all his guns).
Thx for the snippets
 
Top