-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Player Collects Health state = {} local respawn_delay = 25 --time in seconds to wait before being respawned pressed = 0 function health_with_respawn_timer_init(e) state[e] = "spawned" end function health_with_respawn_timer_main(e) if state[e] == "spawned" then if PlayerLooking(e,120,30) == 1 and g_PlayerHealth > 0 then PromptLocal(e,"Press E to restore health") if g_KeyPressE == 1 and pressed == 0 then pressed = 1 PromptDuration("Collected health",3000) PlaySound(e,0) AddPlayerHealth(e) ActivateIfUsed(e) state[e] = "waiting" Hide(e) CollisionOff(e) StartTimer(e) end end elseif state[e] == "waiting" then if GetTimer(e) > respawn_delay*1000 then Show(e) CollisionOn(e) state[e] = "spawned" end end if g_KeyPressE == 0 then pressed = 0 end 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