change line 10 to a smaller value
if PlayerDist < 150 and g_PlayerHealth > 0 then
to
if PlayerDist < 100 and g_PlayerHealth > 0 then
you've also added the angle check twice, it should look like this
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Collects Key
function keybesser_init(e)
end
function keybesser_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 100 and g_PlayerHealth > 0 then
if PlrFacing(e,20) then
Prompt ("Press E To pick up key")
if g_KeyPressE == 1 then
PromptDuration("Collected key",3000)
PlaySound(e,0)
Collected(e)
Destroy(e)
ActivateIfUsed(e)
end
--end
end
end
end
function PlrFacing(e,Angle)
SourceAngle = g_PlayerAngY
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 340.0 do
SourceAngle = SourceAngle - 360.0
end
tPlayerDX = (g_Entity[e]['x'] - g_PlayerPosX)
tPlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ)
DestAngle = math.atan2( tPlayerDZ , tPlayerDX )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 180 then
Result = 0
end
if Result < Angle then
return true
else return false
end
end
p.s. im 90% sure that function is actually incorrect if the value used is anything other than 20... i shall have to check it though
life\'s one big game
windows vista ultimate
i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11