Jump to content

Weapon and fire question


Turbesz

Recommended Posts

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 comment

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

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