Hi i have problem with doorlegacy script
https://www.youtube.com/watch?v=pPiVGi5gwJA
Object sometimes rotating after player press e and animation for open door end.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- safe Prompts 'Closed' can be opened with entity collected specified by 'USE KEY'
-- state to ensure user must release E key before can open/close again
safe_pressed = 0
safelegacy = {}
function safelegacy_init(e)
-- set entity for manual frame control
CharacterControlLimbo(e)
safelegacy[e] = 0
end
function safelegacy_main(e)
PlayerDist = GetPlayerDistance(e)
if (PlayerDist < 100 ) and g_PlayerHealth > 0 then
if 1 then
if g_Entity[e]['activated'] == 0 then
if g_Entity[e]['haskey'] == -1 then
SetActivated(e,1)
else
if g_Entity[e]['plrvisible'] == 1 then
if g_Entity[e]['haskey'] == 1 then
if GetGamePlayerStateXBOX() == 1 then
Prompt("The safe is locked. Press Y button to unlock safe")
else
Prompt("The safe is locked. Press E key to unlock safe")
end
if g_KeyPressE == 1 then
SetActivated(e,1)
end
else
Prompt("The safe is locked. Find a key to unlock safe")
end
end
end
else
if g_Entity[e]['activated'] == 1 then
-- safe is unlocked and closed
if GetGamePlayerStateXBOX() == 1 then
Prompt("Press Y button to open safe")
else
Prompt("Press E to open safe")
end
if g_KeyPressE == 1 and safe_pressed == 0 then
safelegacy[e] = 0
SetAnimationFrame(e,safelegacy[e])
SetActivated(e,2)
PlaySound(e,0)
StartTimer(e)
safe_pressed = 1
end
else
if g_Entity[e]['activated'] == 3 then
-- safe is open
if GetGamePlayerStateXBOX() == 1 then
Prompt("Press Y button to close safe")
else
Prompt("Press E to close safe")
end
if g_KeyPressE == 1 and safe_pressed == 0 then
SetActivated(e,4)
PlaySound(e,1)
CollisionOn(e)
safe_pressed = 1
end
end
end
end
end
end
if g_Entity[e]['activated'] == 2 then
safelegacy[e] = safelegacy[e] + 0.1
if GetAnimationFrame(e)>GetEntityAnimationFinish(e,0) then
safelegacy[e] = GetEntityAnimationFinish(e,0)
CollisionOff(e)
SetActivated(e,3)
end
SetAnimationFrame(e,safelegacy[e])
end
-- handle safe closing frame animation
if g_Entity[e]['activated'] == 4 then
safelegacy[e] = safelegacy[e] - 0.1
if GetAnimationFrame(e)<GetEntityAnimationStart(e,0) then
safelegacy[e] = GetEntityAnimationStart(e,0)
SetActivated(e,1)
end
SetAnimationFrame(e,safelegacy[e])
end
if g_KeyPressE == 0 then
safe_pressed = 0
end
end
The author of this post has marked a post as an answer.
Go to answer