Jump to content

Dont destroy weapon when ammo is 0


Zafire

Recommended Posts

ohhh, you want to give the player the weapon with ammo?

no, i want when player have "0" ammo, gta sa dont DELETE the weapon, i want to the player have the weapon in his hand with 0 ammo.. he cant use it, but the weapon dont dissapear

Link to comment
ohhh, you want to give the player the weapon with ammo?

no, i want when player have "0" ammo, gta sa dont DELETE the weapon, i want to the player have the weapon in his hand with 0 ammo.. he cant use it, but the weapon dont dissapear

Then a good way to do that is using ♫ MI550 ♫ way. When he ran out of ammo put an weapon object of the same weapon in his hand. I don't think there is any other way.

Link to comment

Oh just you stop with those attachments, will ye? there is great way to do it, work-around like always:

Always give player 1 bullet more than it is needed.

Also note that you have to make custom hud, or at least custom ammo showing with DX draw or GUI functions. And make it show one bullet less than it really has.

gMe = getLocalPlayer() 
  
addEventHandler('onClientPlayerWeaponFire',gMe,function(weapon,ammo,inClip,hitX, hitY, hitZ, hitElement) 
    if(weapon > 15 and weapon < 19) or weapon == 39 then return  
    if(ammo == 1) then 
        toggleControl('fire',false) 
        --bindKey('fire','down',playTickSound) --also make a function to play empty clip sound for better playback 
    end 
end) 
  
addEventHandler('onClientPlayerWeaponSwitch',gMe,function(prevSlot,currSlot) 
    if(getPedTotalAmmo(prevSlot) == 1) then 
        toggleControl('fire',true) 
    end 
    if(getPedTotalAmmo(currSlot) == 1) then 
        toggleControl('fire',false) 
    end 
end) 

Of course no guarantee if it will work perfectly, as i've edited a big piece of code.

And make alternative ammo showing (at least) yourself. Disable old one using showPlayerHudComponent('ammo',false)

Link to comment
Oh just you stop with those attachments, will ye? there is great way to do it, work-around like always:

Always give player 1 bullet more than it is needed.

Also note that you have to make custom hud, or at least custom ammo showing with DX draw or GUI functions. And make it show one bullet less than it really has.

gMe = getLocalPlayer() 
  
addEventHandler('onClientPlayerWeaponFire',gMe,function(weapon,ammo,inClip,hitX, hitY, hitZ, hitElement) 
    if(weapon > 15 and weapon < 19) or weapon == 39 then return  
    if(ammo == 1) then 
        toggleControl('fire',false) 
        --bindKey('fire','down',playTickSound) --also make a function to play empty clip sound for better playback 
    end 
end) 
  
addEventHandler('onClientPlayerWeaponSwitch',gMe,function(prevSlot,currSlot) 
    if(getPedTotalAmmo(prevSlot) == 1) then 
        toggleControl('fire',true) 
    end 
    if(getPedTotalAmmo(currSlot) == 1) then 
        toggleControl('fire',false) 
    end 
end) 

Of course no guarantee if it will work perfectly, as i've edited a big piece of code.

And make alternative ammo showing (at least) yourself. Disable old one using showPlayerHudComponent('ammo',false)

thxx it works perfect, but the tickSound dont works, i think its because is disabled control Fire.. but its fine..

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...