Jump to content

Save Weapon


Recommended Posts

just you need to check everytime when they use the weapon to see if the ammo is 1, if yes just disable the fire control.

Note : you need to do the same thing when they switch weapons.

So all what you need is

onClientPlayerWeaponFire 
onClientPlayerWeaponSwitch 
getPedTotalAmmo() 
toggleControl() 

Link to comment
just you need to check everytime when they use the weapon to see if the ammo is 1, if yes just disable the fire control.

Note : you need to do the same thing when they switch weapons.

So all what you need is

onClientPlayerWeaponFire 
onClientPlayerWeaponSwitch 
getPedTotalAmmo() 
toggleControl() 

Why when 1 ammo?

Just check when the weapon is gone, client side with onClientRender. ToggleControl -> add ammo for that weapon. Pretty simple and better.

Link to comment

Why you need to use "onClientRender" event simply it can be done using this two events "onClientPlayerWeaponFire" and

"onClientPlayerWeaponSwitch" .

-- Example

addEventHandler ( "onClientPlayerWeaponFire", localPlayer,  
    function ( weapon ) 
        if ( getPedTotalAmmo ( localPlayer ) == 1 ) then  
            toggleControl ( "fire", false )  
        end  
    end  
) 
  
addEventHandler ( "onClientPlayerWeaponSwitch", localPlayer,  
    function ( ) 
        toggleControl ( "fire", true )  
        if ( getPedTotalAmmo ( localPlayer ) == 1 ) then  
            toggleControl ( "fire", false )  
        end  
    end  
) 

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