Maybe it will help you do first step
This code is not good but me not needed it in my projects and i don't optimize it.
coding in lua
func_mci.at_screen = function(mci)
for k,player in pairs(ginfo) do
-- coordinates in meters!
if obj == nil then
obj = {}
obj.x = -32.0
obj.y = -990.0
end
--Look at player. Comment for use coordinate of 'obj'
local username = "repeat"
if (player.uname == username) then
obj.x = tonumber(string.format("%.1f",player.x/65536))
obj.y = tonumber(string.format("%.1f",player.y/65536))
end
if (player.uname ~= username and player.plid) then
local car = {}
car.x = tonumber(string.format("%.1f",player.x/65536))
car.y = tonumber(string.format("%.1f",player.y/65536))
local h = tonumber(string.format("%.1f",player.heading/32768*180))
local v = (obj.y-car.y)/(obj.x-car.x)
local a = math.atan(v) *180/math.pi -- in degrees
local signX = math.abs(obj.x-car.x)/(obj.x-car.x)
if (signX == -1) then a = 90 + a; else a = 270 + a; end
-- correction
if (a >= 360) then a = 0; end
a = tonumber(string.format("%.1f",a))
-- изменяем предела от -180 до 180
if (h > 180) then h = h - 360; end
if (a > 180) then a = a - 360; end
v = h-a
if (v > 180) then v = v - 360
elseif (v < -180) then v = v + 360
end
distance = tonumber(string.format("%.1f",math.sqrt((obj.x-car.x)^2+(obj.y-car.y)^2)))
--local text = ginfo[k].uname.." "..distance
--luaLFS:btn(1, 255, (100+k), 0, 32+0, 0, 0, 145+k*10-(#ginfo*10), 200, 7, text)
local fov = 90
local c = (fov/2)/100
if (distance <= 250) and (v >= (-fov/2)) and (v <= (fov/2)) and (player.uname ~= username) then
local text = "^1is here"
local len = text:len()
local x = math.ceil(100+(v/c)-len)
if (player.at_screen == nil) or (x ~= player.at_screen) then
luaLFS:btn(2, player.ucid, (0), 0, 32+0, 0, x, 80, len*2, 7, text)
ginfo[k].at_screen = x
end
elseif (player.at_screen) then
luaLFS:bfn(0, player.ucid, (0), 0)
ginfo[k].at_screen = nil
end
end
end
end