On the similar topic, I'm trying to create a single variable i could use that contains numerous operations. For instance PlayerDistance im trying to make an equivalent Entity Distance from another Entity.
I've got this working with
g_Entity[2]['x'] > g_Entity[e]['x']-90 and g_Entity[2]['x'] < g_Entity[e]['x']+90 and g_Entity[2]['y'] > g_Entity[e]['z']-90 and g_Entity[2]['z'] < g_Entity[e]['z']+90 then
But am curious how i could go about making this easier to use elsewhere. Similar to:
if GetPlayerDistance(e) < 90 then
. I would like something similar as its much easier to compare to later with greater or lesser checks.
From what i understand is GetPlayerDistance(e) is created with:
function GetPlayerDistance( e )
local Ent = g_Entity[ e ]
local PDX, PDY, PDZ = Ent.x - g_PlayerPosX,
Ent.y - g_PlayerPosY,
Ent.z - g_PlayerPosZ;
if abs( PDY ) > 100 then PDY = PDY * 4 end
return sqrt( PDX*PDX + PDY*PDY + PDZ*PDZ )
end
Would I have to create something similar to this for entities? I'm trying to understand the math
EDIT: ah solved my own problem
tpDX = g_Entity[e]['x'] - thex
tpDY = g_Entity[e]['y'] - they
tpDZ = g_Entity[e]['z'] - thez
tpDist = math.sqrt(math.abs(tpDX*tpDX)+math.abs(tpDY*tpDY)+math.abs(tpDZ*tpDZ));
end
Store Assets -
Store Link
i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce GTX 960