Jump to content

toggle player shooting


klaw

Recommended Posts

function checkClip(weapon, ammo, clipammo)
	if clipammo == 1 then
		bindKey("R", "down", clientReloadClip)
		toggleControl("fire", false)
		toggleControl("next_weapone", false)
		toggleControl("previous_weapon", false)
	end
end
addEventHandler("onClientPlayerWeaponFire", getRootElement(), checkClip)

For some reason, when shooting a gun, you get to the last bullet and it stops shooting. But if you release the fire button and press it again, it allows you to continue shooting even though I've used toggleControl and disabled the ability to shoot.

Is this a bug with toggleControl or did I do something wrong?

 

next_weapon is spelt wrong, I fixed that, but it didn't affect anything.

Link to comment
4 hours ago, pa3ck said:

When this "bug" happens, what's the value of clipammo? Do an outputChatBox on that and let us know.

I'm firing a round with 5 rounds total. It goes from 4, 3, 2, 1, 0 and stops firing. It allows you to continue firing after you lower your gun and raise it again, and also fires 0, then performs the automated GTA SA reload.

 

1 hour ago, loki2143 said:

I tested this and it works fine for me it does not let me shoot or switch until I reload(which i added) my weapon.

Maybe toggleControl is handled somewhere else than this script?

It's not anywhere else. Mind sharing your code?

Edited by klaw
Link to comment

Here u go:

function checkClip(weapon, ammo, clipammo)
    if clipammo == 1 then
        bindKey("R", "down", reload)
        toggleControl("fire", false)
        toggleControl("next_weapon", false)
        toggleControl("previous_weapon", false)
    end
end
addEventHandler("onClientPlayerWeaponFire", getRootElement(), checkClip)

function reload( )
    unbindKey("R", "down", reload)
    toggleControl("fire", true)
    toggleControl("next_weapon", true)
    toggleControl("previous_weapon", true)
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...