Deniel Posted February 9, 2020 Share Posted February 9, 2020 local aberto = false local phone = {} local animTimer = {} function abrircelular () if aberto == false then aberto = true setPedAnimation (localPlayer, "ped","phone_in", 1000, false, false, false, true) --/> Puxar Celular setPedAnimationProgress(player, "phone_in", 0.8) setPedWeaponSlot(localPlayer, 0) phone[localPlayer] = createObject(330, 0, 0, 0, 0, 0, 0) exports.bone_attach:attachElementToBone(phone[localPlayer], localPlayer, 12, 0, 0.01, 0.03, -15, 270, -15) setElementDimension(phone[localPlayer], getElementDimension(localPlayer)) setElementInterior(phone[localPlayer], getElementInterior(localPlayer)) animTimer[localPlayer] = setTimer(function(player) if ( isElement(player) ) then setPedAnimationProgress(player, "phone_in", 0.8) end end, 500, 0, localPlayer) elseif aberto == true then setPedAnimation (localPlayer, "ped", "phone_out", 50, false, false, false, false) --/> Guardar Celular aberto = false end end bindKey ( "F1", "down", abrircelular) addCommandHandler ( "celular", abrircelular) addEvent("remover_celular", true) addEventHandler("remover_celular", root, function() removePhone(localPlayer) setPedAnimation (localPlayer, "ped", "phone_out", 50, false, false, false, false) end) Bom, praticamente essa é uma animação que estou montando onde o player abre o celular e fica olhando pra ele, porém tem 2 coisas que estou apanhando. 1. A animação por algum motivo esta bugando, quando eu abro o celular pela segunda vez a animação fica ''flicando'' como se ele estivesse tentando fechar o celular e abrir ao mesmo tempo. 2. Não sei por que mais o addEvent também não está indo. Que praticamente as ultimas 4 linhas eu tinha uma intenção de quando ele ''guardar'' o celular com a animação ''phone_out'', o event remover o celular da mão dele. Link to comment
beast99 Posted February 9, 2020 Share Posted February 9, 2020 9 hours ago, Deniel said: local aberto = false local phone = {} local animTimer = {} function abrircelular () if aberto == false then aberto = true setPedAnimation (localPlayer, "ped","phone_in", 1000, false, false, false, true) --/> Puxar Celular setPedAnimationProgress(player, "phone_in", 0.8) setPedWeaponSlot(localPlayer, 0) phone[localPlayer] = createObject(330, 0, 0, 0, 0, 0, 0) exports.bone_attach:attachElementToBone(phone[localPlayer], localPlayer, 12, 0, 0.01, 0.03, -15, 270, -15) setElementDimension(phone[localPlayer], getElementDimension(localPlayer)) setElementInterior(phone[localPlayer], getElementInterior(localPlayer)) animTimer[localPlayer] = setTimer(function(player) if ( isElement(player) ) then setPedAnimationProgress(player, "phone_in", 0.8) end end, 500, 0, localPlayer) elseif aberto == true then setPedAnimation (localPlayer, "ped", "phone_out", 50, false, false, false, false) --/> Guardar Celular aberto = false end end bindKey ( "F1", "down", abrircelular) addCommandHandler ( "celular", abrircelular) addEvent("remover_celular", true) addEventHandler("remover_celular", root, function() removePhone(localPlayer) setPedAnimation (localPlayer, "ped", "phone_out", 50, false, false, false, false) end) Bom, praticamente essa é uma animação que estou montando onde o player abre o celular e fica olhando pra ele, porém tem 2 coisas que estou apanhando. 1. A animação por algum motivo esta bugando, quando eu abro o celular pela segunda vez a animação fica ''flicando'' como se ele estivesse tentando fechar o celular e abrir ao mesmo tempo. 2. Não sei por que mais o addEvent também não está indo. Que praticamente as ultimas 4 linhas eu tinha uma intenção de quando ele ''guardar'' o celular com a animação ''phone_out'', o event remover o celular da mão dele. Poste o /debugscript 3 Link to comment
Deniel Posted February 9, 2020 Author Share Posted February 9, 2020 3 hours ago, MesaDowN said: Poste o /debugscript 3 /debugscript está limpo o script não está dando erro. Link to comment
Angelo Pereira Posted February 10, 2020 Share Posted February 10, 2020 Bom, muitas coisas eu não entendi no seu script, são elas : Tabelas para timer + createObjeto. 1 timer de 0,5s executando infinitas repetições Dei uma arrumada no código : local aberto = false -- local phone = {} Não é necessário usar uma tabela para criar um objeto no client nesta ocasião. -- local animTimer = {} Não é necessário usar uma tabela para um timer no client nesta ocasião. function abrircelular () if aberto == false then aberto = true setPedAnimation (localPlayer, "ped","phone_in", 1000, false, false, false, true) setPedAnimationProgress(localPlayer, "phone_in", 0.8) setPedWeaponSlot(localPlayer, 0) phone = createObject(330, 0, 0, 0, 0, 0, 0) exports.bone_attach:attachElementToBone(phone, localPlayer, 12, 0, 0.01, 0.03, -15, 270, -15) setElementDimension(phone, getElementDimension(localPlayer)) setElementInterior(phone, getElementInterior(localPlayer)) animTimer = setTimer(function() --/> Não entendi a funcionalidade disto. setPedAnimationProgress(localPlayer, "phone_in", 0.8) end, 500, 0) else removePhone() end end bindKey ( "F1", "down", abrircelular) addCommandHandler ( "celular", abrircelular) function removePhone () if aberto == true then if isElement(phone) then destroyElement(phone) end if isTimer(animTimer) then killTimer(animTimer) end aberto = false setPedAnimation (localPlayer, "ped", "phone_out", 50, false, false, false, false) end end addEvent("remover_celular", true) addEventHandler("remover_celular", getRootElement(), removePhone ) 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now