Jump to content

Erro na animacao


Recommended Posts

eu realmente nao entendo algumas coisas .-.

porque a animação nao quer ser cancelada 

 

local ferro = {}

addEvent("givePlayerferro",true)
addEventHandler("givePlayerferro",getRootElement(),function(playerSource)
	if not isElement(ferro[playerSource]) then
		ferro[playerSource] = createObject(16304,0,0,0)
		setElementCollisionsEnabled(ferro[playerSource], false)
		exports.bone_attach:attachElementToBone(ferro[playerSource],playerSource,12,0,0.2,0.1,0,-90,65)
		setElementData(playerSource,"ferro",ferro[playerSource])
		setPedAnimation(playerSource, "CARRY", "crry_prtial", 0, true, false, true, true)
	end
end)

addEvent("takePlayerferro",true)
addEventHandler("takePlayerferro",getRootElement(),function(playerSource)
	if isElement(ferro[playerSource]) then
		exports.bone_attach:detachElementFromBone(ferro[playerSource])
		destroyElement(ferro[playerSource])
		ferro[playerSource] = false
		setPedAnimation(playerSource,false)
		toggleControl(playerSource,"fire", true)
		toggleControl(playerSource,"sprint", true)
		toggleControl(playerSource,"crouch", true)
		toggleControl(playerSource,"jump", true)
		setPedAnimation(playerSource,false)
	end
end)

 

Link to comment

o ultimo false desse codigo

setPedAnimation(playerSource, "CARRY", "crry_prtial", 0, true, false, true, false)

é para não freezar no ultimo frame da animação, se ficar true ele vai freezar

fonte:
 

bool setPedAnimation ( ped thePed [, string block = nil, string anim = nil, int time = -1, bool loop = true, bool updatePosition = true,
                       bool interruptable = true, bool freezeLastFrame = true, int blendTime = 250, bool restoreTaskOnAnimEnd = false ] )

 

Link to comment
  • Moderators

Pelo que entendi ele quer que pare a animação, e isso deveria acontecer no evento "takePlayerferro".

Tente assim como eu já disse @LucasMTA:

setPedAnimation(playerSource)

E remova a outra função duplicada. Quando testar deixe seu debugmode ativado e use outputs para acompanhar a execução do código e encontrar possíveis bugs.

Se não resolver, mostre seu código completo.

Link to comment

Tenta remover o elemento ferro

 

addEvent("takePlayerferro",true)
addEventHandler("takePlayerferro",getRootElement(),function(playerSource)
	if isElement(ferro[playerSource]) then
		exports.bone_attach:detachElementFromBone(ferro[playerSource])
		destroyElement(ferro[playerSource])
		ferro[playerSource] = false
		setPedAnimation(playerSource,false)
		toggleControl(playerSource,"fire", true)
		toggleControl(playerSource,"sprint", true)
		toggleControl(playerSource,"crouch", true)
		toggleControl(playerSource,"jump", true)
		removeElementData(playerSource, "Ferro")
		setPedAnimation(playerSource)
	end
end)

 

Edited by gbmv33
errei um elemento
Link to comment

creio que seja por isso porque no seu script ele seta o elemento Ferro no player que ativa a animação, mas ele não remove essa data do player para que a animação seja cancelada

tenta esse script então

 

local ferro = {}

addEvent("givePlayerferro",true)
addEventHandler("givePlayerferro",getRootElement(),function(playerSource)
	if not isElement(ferro[playerSource]) then
		ferro[playerSource] = createObject(16304,0,0,0)
		setElementCollisionsEnabled(ferro[playerSource], false)
		exports.bone_attach:attachElementToBone(ferro[playerSource],playerSource,12,0,0.2,0.1,0,-90,65)
		setElementData(playerSource,"ferro",ferro[playerSource])
		setPedAnimation(playerSource, "CARRY", "crry_prtial", 0, true, true, true, true)
	end
end)

addEvent("takePlayerferro",true)
addEventHandler("takePlayerferro",getRootElement(),function(playerSource)
	if isElement(ferro[playerSource]) then
		exports.bone_attach:detachElementFromBone(ferro[playerSource])
		destroyElement(ferro[playerSource])
		ferro[playerSource] = false
		toggleControl(playerSource,"fire", true)
		toggleControl(playerSource,"sprint", true)
		toggleControl(playerSource,"crouch", true)
		toggleControl(playerSource,"jump", true)
		removeElementData(thePlayer, "Ferro")
		setPedAnimation(playerSource)
	end
end)

 

Link to comment

agora esta dando erro na distancia dos objetos que eu crio , exemplo tem 2 objetos na lista de tabelas com 2 de distancia um da certo o outro pede pra se aproximar, mais eu ja to proximo ao objeto

Esqueci era erro meu , deu certo aqui 

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