undefined Posted June 15, 2015 Posted June 15, 2015 While the weapon bullets 0, weapons disappear. How can I prevent it?
HUNGRY:3 Posted June 15, 2015 Posted June 15, 2015 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
Walid Posted June 15, 2015 Posted June 15, 2015 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()
Anubhav Posted June 16, 2015 Posted June 16, 2015 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.
Walid Posted June 16, 2015 Posted June 16, 2015 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 IIYAMA Posted June 16, 2015 Moderators Posted June 16, 2015 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.
Dealman Posted June 16, 2015 Posted June 16, 2015 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now