Jump to content

Weapon and fire question


Recommended Posts

How can i disable weapon use (shooting) while player is on fire (for example because players threw her molotov)? 

Because GTA SA have a worrying bug with which you can shoot indefinitely with desert eagle while you burn, so i want to fix that somehow

Link to post
1 hour ago, Patrick said:

You can disable shooting with toggleControl.


toggleControl("fire", false)

 

umm i tried this way, but if player does not on fire still cannot shoot with weapon

function teszt()
   local wep = getPedWeapon(source)
   if isPedOnFire (source) and wep == 24 then 
      toggleControl(source,"fire", false)
   else 
      toggleControl(source,"fire", true)
   end
end

addEventHandler("onPlayerWeaponFire",root,teszt)

 

Link to post

You can set a timer after some time to enable the fire control.

For example:

function teszt()
	local wep = getPedWeapon(source)
	if isPedOnFire(source) and wep == 24 then 
		toggleControl(source, "fire", false)
		setTimer(function()
			toggleControl(source, "fire", true)
		end, 5000, 1)
	end
end
addEventHandler("onPlayerWeaponFire",root,teszt)

 

Edited by SpecT
Link to post
7 minutes ago, SpecT said:

You can set a timer after some time to enable the fire control.

For example:


function teszt()
	local wep = getPedWeapon(source)
	if isPedOnFire(source) and wep == 24 then 
		toggleControl(source, "fire", false)
		setTimer(function()
			toggleControl(source, "fire", true)
		end, 5000, 1)
	end
end
addEventHandler("onPlayerWeaponFire",root,teszt)

 

i tried this way too, but does not working the timer "Expected player at argument 1, got nil"

Link to post

Well you need to store the player in a variable.
 

function teszt()
	local wep = getPedWeapon(source)
	local targetPlayer = source
	if isPedOnFire(source) and wep == 24 then 
		toggleControl(source, "fire", false)
		setTimer(function()
			toggleControl(targetPlayer, "fire", true)
		end, 5000, 1)
	end
end
addEventHandler("onPlayerWeaponFire",root,teszt)

Now it should work fine.

Edited by SpecT
  • Thanks 1
Link to post
6 minutes ago, SpecT said:

Well you need to store the player in a variable.
 


function teszt()
	local wep = getPedWeapon(source)
	local targetPlayer = source
	if isPedOnFire(source) and wep == 24 then 
		toggleControl(source, "fire", false)
		setTimer(function()
			toggleControl(targetPlayer, "fire", true)
		end, 5000, 1)
	end
end
addEventHandler("onPlayerWeaponFire",root,teszt)

Now it should work fine.

Thank you so much!! :D

  • Like 1
Link to post

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