require "lib.moonloader"
showNick = false
local radius = 100
function main()
sampRegisterChatCommand("snick", function() showNick = not showNick end)
if not isSampfuncsLoaded() or not isSampLoaded() then return end
local font = renderCreateFont("Arial", 8, 15)
while not isSampAvailable() do wait(100) end
while true do
wait(0)
if showNick then
local playerPed = playerPed
local mX, mY, mZ = getCharCoordinates(playerPed)
for a = 0, 1000 do
local result, charhandle = sampGetCharHandleBySampPlayerId(a)
if result then
local lvl = sampGetPlayerScore(a)
local X, Y, Z = getOffsetFromCharInWorldCoords(charhandle, 0.0, 0.0, 1.0)
local distance = calculateDistance(mX, mY, mZ, X, Y, Z)
if distance <= radius then
local cposX, cposY = convert3DCoordsToScreen(X, Y, Z)
if isPointOnScreen(X, Y, Z, 0) then
renderFontDrawText(font, string.format(sampGetPlayerNickname(a)), cposX, cposY, 0xffffffff)
end
end
end
end
end
end
end
function calculateDistance(x1, y1, z1, x2, y2, z2)
return math.sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2)
end