Jump to content

toggleControl help


Recommended Posts

hello guys, i was trying to make spawn protection like when player die and respawn in hospital cant use weapons then after the respawn time finish can use it again its works fine but the problem when player respawn in hospital can use weapons without waiting the time 

sorry for bad english

function setPlayerSpawnProtected(player, time)
	if isElement(player) and getElementType(player) == "player" then
		setElementAlpha(player, 100)
		setElementData(player, "SpawnProtected", true)
		toggleControl(player, "fire", false)
		rsp[player] = setTimer(function ()
			setElementData(player, "SpawnProtected", false)
			setElementAlpha(player, 255)
			toggleControl(player, "fire", true)
		end, time*1000, 1)
		return true
	else
		return false
	end
end

 

Link to comment
  • Moderators
50 minutes ago, jakson said:

nope i didnt

It might be possible that either by default or by another script the control is enabled.

 

 

I recommend to use event "onPlayerSpawn"

 

+

 

Put the addEventHandler priority to low. (which is for the onPlayerSpawn event)

 

 

This will make sure that the control settings are not being overwritten by anything else at serverside.

 

 

 

  • Like 1
Link to comment
2 hours ago, IIYAMA said:

It might be possible that either by default or by another script the control is enabled.

 

 

I recommend to use event "onPlayerSpawn"

 

+

 

Put the addEventHandler priority to low. (which is for the onPlayerSpawn event)

 

 

This will make sure that the control settings are not being overwritten by anything else at serverside.

 

 

 

still same

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