local pressed = 0 local frame = 0 local stopped = 0 local animation = {} local first_frame = nil local last_frame = nil function animation_finder_init(e) animation[e] = 0 end function animation_finder_main(e) if PlayerLooking(e,300,15) == 1 then if g_KeyPressE == 1 and pressed == 0 then first_frame = nil last_frame = nil animation[e] = animation[e] + 1 StopAnimation(e) SetAnimationFrame(e,0) pressed = 1 elseif g_KeyPressR == 1 and pressed == 0 then first_frame = nil last_frame = nil animation[e] = animation[e] - 1 StopAnimation(e) SetAnimationFrame(e,0) pressed = 1 end if first_frame ~= nil and last_frame ~= nil then Prompt("animation number " ..animation[e]..", frame = "..GetAnimationFrame(e).." , first frame = "..first_frame.." , last frame = "..last_frame) else Prompt("animation number "..animation[e].." , no animation info") end end if g_Entity[e]['animating'] == 0 then SetAnimation(animation[e]) PlayAnimation(e) g_Entity[e]['animating'] = 2 else if first_frame == nil and GetAnimationFrame(e) > 0 then first_frame = GetAnimationFrame(e) end if last_frame == nil then if GetAnimationFrame(e) > 0 then last_frame = GetAnimationFrame(e) end elseif GetAnimationFrame(e) > last_frame then last_frame = GetAnimationFrame(e) end end if g_KeyPressE == 0 and g_KeyPressR == 0 then pressed = 0 end end function animation_finder_exit(e) end function PlayerLooking(e,dis,v) if g_Entity[e] ~= nil then if dis == nil then dis = 3000 end if v == nil then v = 0.5 end if GetPlayerDistance(e) <= dis then local destx = g_Entity[e]['x'] - g_PlayerPosX local destz = g_Entity[e]['z'] - g_PlayerPosZ local angle = math.atan2(destx,destz) angle = angle * (180.0 / math.pi) if angle <= 0 then angle = 360 + angle elseif angle > 360 then angle = angle - 360 end while g_PlayerAngY < 0 or g_PlayerAngY > 360 do if g_PlayerAngY <= 0 then g_PlayerAngY = 360 + g_PlayerAngY elseif g_PlayerAngY > 360 then g_PlayerAngY = g_PlayerAngY - 360 end end local L = angle - v local R = angle + v if L <= 0 then L = 360 + L elseif L > 360 then L = L - 360 end if R <= 0 then R = 360 + R elseif R > 360 then R = R - 360 end if (L < R and math.abs(g_PlayerAngY) > L and math.abs(g_PlayerAngY) < R) then return 1 elseif (L > R and (math.abs(g_PlayerAngY) > L or math.abs(g_PlayerAngY) < R)) then return 1 else return 0 end else return 0 end end end