Jump to content

Save Weapon


Recommended Posts

Posted
can you give us more info what do you want to do ?

when the weapon bullets is 0 ....it disappear...so he want to keep the weapon with the player when the weapon bullets is 0

Posted

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() 

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

Posted

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  
) 

  • Moderators
Posted

Doesn't work with all weapons, some weapons (minigun/spray can) do have a fire rate of 1 bullet per frame. They will always fire 1 more bullet ahead of the toggleControl block.

Posted

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.

Yeah, better to run it 30-60 times per second than once every time he tries to fire. :roll:

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