local GUI = {
originalRender,
originalDistance,
fontName = "Arial", -- Название шрифта
fontSize = 10 -- Размер шрифта
}
script_name("Custom NameTags")
script_author("S E V E N", "Receiver")
script_version("v 2.0")
------------------------------------------------------
string.format('PROTECTED BY GAECHKA.TM // SK-TEAM НЕ КРЯКАЙ ПЖ');
string.format('PROTECTED BY GAECHKA.TM // SK-TEAM НЕ КРЯКАЙ ПЖ');
string.format('PROTECTED BY GAECHKA.TM // SK-TEAM НЕ КРЯКАЙ ПЖ');
string.format('ВСТУПАЙ В РЯДЫ SL-TEAM! // https://vk.me/join/AJQ1d1trChcDUANqaNztevR2');
string.format('ВСТУПАЙ В РЯДЫ SL-TEAM! // https://vk.me/join/AJQ1d1trChcDUANqaNztevR2');
string.format('ВСТУПАЙ В РЯДЫ SL-TEAM! // https://vk.me/join/AJQ1d1trChcDUANqaNztevR2');
string.format('PROTECTED BY GAECHKA.TM // SK-TEAM НЕ КРЯКАЙ ПЖ');
string.format('PROTECTED BY GAECHKA.TM // SK-TEAM НЕ КРЯКАЙ ПЖ');
string.format('PROTECTED BY GAECHKA.TM // SK-TEAM НЕ КРЯКАЙ ПЖ');
string.format('ВСТУПАЙ В РЯДЫ SL-TEAM! // https://vk.me/join/AJQ1d1trChcDUANqaNztevR2');
string.format('ВСТУПАЙ В РЯДЫ SL-TEAM! // https://vk.me/join/AJQ1d1trChcDUANqaNztevR2');
string.format('ВСТУПАЙ В РЯДЫ SL-TEAM! // https://vk.me/join/AJQ1d1trChcDUANqaNztevR2');
string.format('PROTECTED BY GAECHKA.TM // SK-TEAM НЕ КРЯКАЙ ПЖ');
string.format('PROTECTED BY GAECHKA.TM // SK-TEAM НЕ КРЯКАЙ ПЖ');
string.format('PROTECTED BY GAECHKA.TM // SK-TEAM НЕ КРЯКАЙ ПЖ');
------------------------------------------------------
local ffi = require "ffi"
local getBonePosition = ffi.cast("int (__thiscall*)(void*, float*, int, bool)", 0x5E4280)
local ev = require "samp.events"
------------------------------------------------------
function explode_argb(argb)
local a = bit.band(bit.rshift(argb, 24), 0xFF)
local r = bit.band(bit.rshift(argb, 16), 0xFF)
local g = bit.band(bit.rshift(argb, 8), 0xFF)
local b = bit.band(argb, 0xFF)
return a, r, g, b
end
function join_argb(a, r, g, b)
local argb = b -- b
argb = bit.bor(argb, bit.lshift(g, 8)) -- g
argb = bit.bor(argb, bit.lshift(r, 16)) -- r
argb = bit.bor(argb, bit.lshift(a, 24)) -- a
return argb
end
function getBodyPartCoordinates(id, handle)
local pedptr = getCharPointer(handle)
local vec = ffi.new("float[3]")
getBonePosition(ffi.cast("void*", pedptr), vec, id, true)
return vec[0], vec[1], vec[2]
end
------------------------------------------------------
------------------------------------------------------
local memory = require "memory"
nameTags = {
getDistance = function()
return memory.getfloat(serverPtr + 39, 1)
end,
getState = function()
return memory.getint8(serverPtr + 56, 1)
end,
setState = function(state)
memory.setint8(serverPtr + 56, state)
end
};
------------------------------------------------------
function main()
repeat wait(0) until isSampAvailable()
sampAddChatMessage("» CNT: {ffffff}Loaded. Waiting connect to the server...", 0xffe3fc03)
repeat wait(0) until sampGetGamestate() == 3
sampAddChatMessage("» CNT: {ffffff}Connected. Authors: " .. table.concat(thisScript().authors, ", "), 0xffe3fc03)
renderFont = renderCreateFont(GUI.fontName, GUI.fontSize, 0x1 + 0x8)
serverPtr = sampGetServerSettingsPtr()
GUI.originalRender = nameTags.getState()
GUI.originalDistance = nameTags.getDistance() -- return original server render distanсe
if not GUI.originalRender then error("ACCESS DENIED") end
while true do
nameTagDraw()
wait(0)
end
end
function onExitScript(quit)
if not quit then
nameTags.setState(true) -- enable nametags render.
renderReleaseFont(renderFont)
end
end
chatBubbles = chatBubbles or {};
function ev.onPlayerChatBubble(playerId, color, dist, time, text)
-- Удаляем предыдущий чат-бабл
for k, v in pairs(chatBubbles) do
if v["playerid"] == playerId then
table.remove(chatBubbles, k);
break;
end
end
-- Создаём новый чат-бабл
local tbl = {
["playerid"] = playerId,
["color"] = color,
["dist"] = dist,
["time"] = os.time() + time / 1000,
["text"] = text
}
table.insert(chatBubbles, tbl);
return false
end
function nameTagDraw()
if nameTags.getState() then
nameTags.setState(false) -- disable nametags render.
end
for i = 0, sampGetMaxPlayerId() do
local getted, remotePlayer = sampGetCharHandleBySampPlayerId(i)
if getted then
local remotePlayerX, remotePlayerY, remotePlayerZ = getBodyPartCoordinates(8, remotePlayer);
local myPosX, myPosY, myPosZ = getCharCoordinates(playerPed)
local dist = getDistanceBetweenCoords3d(remotePlayerX, remotePlayerY, remotePlayerZ, myPosX, myPosY, myPosZ)
if dist <= GUI.originalDistance then
if isCharOnScreen(remotePlayer) then
local camX, camY, camZ = getActiveCameraCoordinates()
local wposX, wposY = convert3DCoordsToScreen(remotePlayerX, remotePlayerY, remotePlayerZ + 0.4 + (dist * 0.05))
local result, colPoint = processLineOfSight(camX, camY, camZ, remotePlayerX, remotePlayerY, remotePlayerZ, true, false, false, true, false, false, false, true)
if not result then
local color = sampGetPlayerColor(i)
local aa, rr, gg, bb = explode_argb(color)
color = join_argb(255, rr, gg, bb)
local text = string.format("%s (%d)", sampGetPlayerNickname(i), i)
local afkState = sampIsPlayerPaused(i)
if afkState then
text = "[AFK] " .. text;
end
renderFontDrawText(renderFont, text, wposX - renderGetFontDrawTextLength(renderFont, text) / 2, wposY, color)
renderDrawBoxWithBorder(wposX - 24, wposY + renderGetFontDrawHeight(renderFont) + 4, 100 / 2, 6, 0xFF000000, 1, 0xFF000000)
renderDrawBoxWithBorder(wposX - 24, wposY + renderGetFontDrawHeight(renderFont) + 4, sampGetPlayerHealth(i) / 2, 6, 0xFFFF0000, 1, 0x00000000)
if sampGetPlayerArmor(i) > 1 then
renderDrawBoxWithBorder(wposX - 24, wposY + renderGetFontDrawHeight(renderFont) + 12, 100 / 2, 6, 0xFF000000, 1, 0xFF000000)
renderDrawBoxWithBorder(wposX - 24, wposY + renderGetFontDrawHeight(renderFont) + 12, sampGetPlayerArmor(i) / 2, 6, 0xFFFFFFFF, 1, 0x00000000)
end
end
end
end
end
end
for k, v in pairs(chatBubbles) do
-- seven-eXe: хочеца секса
if os.time() > v["time"] then
table.remove(chatBubbles, i);
else
local getted, remotePlayer = sampGetCharHandleBySampPlayerId(v["playerid"])
if getted then
local remotePlayerX, remotePlayerY, remotePlayerZ = getBodyPartCoordinates(8, remotePlayer);
local myPosX, myPosY, myPosZ = getCharCoordinates(playerPed)
local dist = getDistanceBetweenCoords3d(remotePlayerX, remotePlayerY, remotePlayerZ, myPosX, myPosY, myPosZ)
if dist <= v["dist"] then
if isCharOnScreen(remotePlayer) then
local camX, camY, camZ = getActiveCameraCoordinates()
local wposX, wposY = convert3DCoordsToScreen(remotePlayerX, remotePlayerY, remotePlayerZ + 0.4 + (dist * 0.05))
local result, colPoint = processLineOfSight(camX, camY, camZ, remotePlayerX, remotePlayerY, remotePlayerZ, true, false, false, true, false, false, false, true)
if not result then
local aa, rr, gg, bb = explode_argb(v["color"])
v["color"] = join_argb(255, rr, gg, bb)
renderFontDrawText(renderFont, v["text"], wposX - renderGetFontDrawTextLength(renderFont, v["text"]) / 2, wposY - renderGetFontDrawHeight(renderFont) - 2, v["color"])
end
end
end
end
end
end
end