Jump to content

Ajuda ElementFrozen


Recommended Posts

SpawnM = createMarker(-2396.8295898438,-617.03546142578,131.75123596191, "cylinder",1.5, 255, 255, 255, 50)

function msg(player)
	outputChatBox("Você foi congelado até iniciar o Round!!", player, 255, 255, 255,true)
end
addEventHandler("onMarkerHit", SpawnM, msg)

function frozen(source)
	if isElementWithinMarker(source, SpawnM) then
	setElementFrozen(source, true)
end
end
addEventHandler("onMarkerHit",root,frozen)

Então até ai tá ok. Gostaria só de saber como faço pra quando o mod for desativado o player que esta freezado ser desfreezado.

Link to comment
  • Other Languages Moderators

Não seria melhor ter feito tudo junto?

SpawnM = createMarker (-2396.8295898438, -617.03546142578, 131.75123596191, "cylinder", 1.5, 255, 255, 255, 50)

function msg (player)
	if (player) and (getElementType (player) == "player") then
		outputChatBox ("Você foi congelado até iniciar o Round!!", player, 255, 255, 255)
		setElementFrozen (player, true)
	end
end
addEventHandler ("onMarkerHit", SpawnM, msg)

 

  • Thanks 1
Link to comment

Coloque isto no seu código:


local frozenPlayers = {}

addEventHandler( "onResourceStop", resourceRoot, function()
	for thePlayer in pairs(frozenPlayers) do
	
		setElementFrozen( thePlayer, false )
	end
end )

local SetElementFrozen = setElementFrozen
function setElementFrozen( elem, bool )
	if not isElement(elem) then return false end
	
	if getElementType(elem) == "player" then
	
		bool = bool and true or nil
		frozenPlayers[ elem ] = bool
	end
	
	return SetElementFrozen( elem, bool )
end

addEventHandler( "onPlayerQuit", root, function()
	if frozenPlayers[ source ] then
		frozenPlayers[ source ] = nil
	end
end )

(não-testado)

Link to comment

É por causa da linha 17.

Aqui está o código corrigido:

Spoiler


local frozenPlayers = {}

addEventHandler( "onResourceStop", resourceRoot, function()
	for thePlayer in pairs(frozenPlayers) do

		setElementFrozen( thePlayer, false )
	end
end )

local SetElementFrozen = setElementFrozen
function setElementFrozen( elem, bool )
	if not isElement(elem) then return false end
	
	if getElementType(elem) == "player" then

		frozenPlayers[ elem ] = bool and true or nil
	end
	return SetElementFrozen( elem, bool )
end

addEventHandler( "onPlayerQuit", root, function()
	if frozenPlayers[ source ] then
		frozenPlayers[ source ] = nil
	end
end )

 

 

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