will work just like GetPlayerDistance(e) except you need to call both entities (as it doesn't include the player),
i.e. you need to know the entity number of the target to check (you can still use e for the object running the script)
the second function call ignores any height differences
function GetDistance(e,v)
if g_Entity[e] ~= nil and g_Entity[e] ~= 0 and g_Entity[v] ~= nil and g_Entity[v] ~= 0 then
local disx = g_Entity[e]['x'] - g_Entity[v]['x']
local disz = g_Entity[e]['z'] - g_Entity[v]['z']
local disy = g_Entity[e]['y'] - g_Entity[v]['y']
return math.sqrt(disx^2 + disz^2 + disy^2)
end
end
function GetFlatDistance(e,v)
if g_Entity[e] ~= nil and g_Entity[v] ~= nil then
local distDX = g_Entity[e]['x'] - g_Entity[v]['x']
local distDZ = g_Entity[e]['z'] - g_Entity[v]['z']
return math.sqrt((distDX*distDX)+(distDZ*distDZ));
end
end
life\'s one big game
windows vista ultimate
i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11