Here you go Gubby, here's an add life kit script for the guy you were helping on steam.
local addalife = 0
local use_range = 100
local use_angle = 15
function addlifekit_init(e)
end
function addlifekit_main(e)
if PlayerLooking(e,use_range,use_angle) == 1 then
PromptLocal(e,"Press E to take the First Aid Kit")
end
if PlayerLooking(e,use_range,use_angle) == 1 and g_KeyPressE == 1 then
local addalife = g_PlayerLives + 1
SetPlayerLives(addalife)
PromptDuration("You used a First Aid Kit.", 3000)
Destroy(e)
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
Haven't tested it yet, but it should work, it's just an adaptation of my first aid kit script. With this one be aware that it works on angles and distances so to pick up the entity you need to be in range and actually looking directly at the entity, range and angle can be changed by changing the variables at the top of the script (credit for that part goes to smallg for showing me how to do that).
Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.
Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.
Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.