--[[
@author: Its Your World
@resource: iyw_gui/main_c.lua
@license: ProIT-web.pl, 2016,2017/...
Pierwotnym w?a?cicielem poni?szego kodu jest firma ProIT-web.pl. ©
Zakazuje si? edytowania lub u?ywania ca?ego lub fragment?w kodu z tego zasobu bez pisemnej zgody firmy b?dzie skutkowa?o skierowaniem wniosku do s?du w
my?l naruszenia ustawy dotycz?cej praw autorskich o kt?rych mowa w ustawie z dnia 4 lutego 1994r. o prawie autorskim i prawach pokrewnych.
]]
local utils = {nametagFont = setFont("archivo_narrow", 19), location = setFont("sign_painter", 38)}
local screenSize = Vector2(guiGetScreenSize())
local timer = false
addEventHandler("onClientMinimize", root, function()
localPlayer:setData("player:minimalized", getTickCount())
localPlayer:setData("player:tick", getTickCount())
timer = Timer(function() localPlayer:setData("player:tick", getTickCount()) end, 1000, 0)
end)
addEventHandler("onClientRestore", root, function()
localPlayer:setData("player:minimalized", false)
if timer and timer.valid then timer:destroy() end
end)
addEventHandler("onClientRender", root, function()
if not isPlayerMapVisible() and not localPlayer:getData("player:hud_visible") then
local position = {getElementPosition(localPlayer)}
local city = getZoneName(position[1], position[2], position[3], true)
local street = getZoneName(position[1], position[2], position[3], false)
if dxSetAspectRatioAdjustmentEnabled then dxSetAspectRatioAdjustmentEnabled(true) end
if city == "Unknown" then street = "" end
if city ~= street then street = " "..street.."\n"..city else street = " "..street end
if isPlayerHudComponentVisible("radar") and localPlayer.interior == 0 and localPlayer.dimension == 0 then
dxDrawText(street, (260/1280*screenSize.x)+1, (660/720*screenSize.y)+1, (399/1280*screenSize.x)+1, (670/720*screenSize.y)+1, tocolor(0, 0, 0, 255), 0.5, utils.location or "default-bold", "left", "center")
dxDrawText(street, 260/1280*screenSize.x, 660/720*screenSize.y, 399/1280*screenSize.x, 670/720*screenSize.y, tocolor(255, 255, 255, 255), 0.5, utils.location or "default-bold", "left", "center")
end
end
end)
local function checkLevel(player)
distance = 0
if player:getData("player:level") then distance = 0.62 else distance = 0.56 end
return distance
end
addEventHandler("onClientRender", root, function()
for k,v in pairs(Element.getAllByType("player")) do
if localPlayer.interior == v.interior and localPlayer.dimension == v.dimension then
local camera = {getCameraMatrix()}
local bone = {v:getBonePosition(8)}
local distance = getDistanceBetweenPoints3D(camera[1], camera[2], camera[3], bone[1], bone[2], bone[3])
if localPlayer:getData("player:hud_visible") then return false end
if distance <= 30 and v.alpha >= 230 then
local coords = {getScreenFromWorldPosition(bone[1], bone[2], bone[3]+checkLevel(v))}
if coords[1] and coords[2] then
local minimalized = ""
local minimal = v:getData("player:minimalized")
if minimal then
local tick = v:getData("player:tick")
if tick then
local tick = tick - minimal
local sekundy=math.floor(tick/1000) or 0
local godziny = string.format("%02.f", math.floor(sekundy/3600));
local minuty = string.format("%02.f", math.floor(sekundy/60 - (godziny*60)));
local secs = string.format("%02.f", math.floor(sekundy - godziny*3600 - minuty *60));
minimalized = "zminimalizowany(a) od: "..godziny.."h "..minuty.."m "..secs.."s"
end
end
local data = (v:getData("player:level") and v:getData("player:duty"))
rank = ranks[v:getData("player:level")] or ""
visualrank = v:getData("player:visualrank")
visualid = v:getData("player:visualid") or "#FFFFFF"
if v:getData("chat_typing") then chat = "#9F9F9F(...)#ffffff" else chat = "" end
if v:getData("player:muted") then prefix = "#8060FF(MUTE)" else prefix = "" end
if v:getData("player:duty") == "SAPD" then dutyf = "#0000CDSan Andreas Police Department" elseif v:getData("player:duty") == "SAMD" then dutyf = "#00A0FFSan Andreas Medical Department" elseif v:getData("player:duty") == "FDSA" then dutyf = "#FF0000Fire Department San Andreas" elseif v:getData("player:duty") == "Tuner SF" then dutyf = "Monter cz??ci samochodowych" end
statue = ""
if data and not visualrank then
dxDrawText(minimalized.."\n\n"..statue:gsub("#%x%x%x%x%x%x","").."\n"..dutyf:gsub("#%x%x%x%x%x%x","").."\n"..rank.."\n["..(v:getData("id") or 0).."] "..string.gsub(v.name, "#%x%x%x%x%x%x", "").." "..chat:gsub("#%x%x%x%x%x%x","").."\n"..prefix:gsub("#%x%x%x%x%x%x",""), coords[1]+1, coords[2]+1, coords[1]+1, coords[2]+1, tocolor(0, 0, 0, 255), 0.7-distance/45, utils.nametagFont or "default-bold", "center", "center", false, true, false, true)
dxDrawText(minimalized.."\n\n"..statue.."\n"..dutyf.."\n"..getColorWhereRank(v)..""..rank.."#FFFFFF\n["..getColorWhereRank(v)..""..(v:getData("id") or 0).."#FFFFFF] "..string.gsub(v.name, "#%x%x%x%x%x%x", "").." "..chat.."\n"..prefix, coords[1], coords[2], coords[1], coords[2], tocolor(255, 255, 255, 255), 0.7-distance/45, utils.nametagFont or "default-bold", "center", "center", false, true, false, true)
elseif data and visualrank then
dxDrawText(minimalized.."\n\n"..statue:gsub("#%x%x%x%x%x%x","").."\n"..dutyf:gsub("#%x%x%x%x%x%x","").."\n"..getColorWhereRank(v):gsub("#%x%x%x%x%x%x","")..""..visualrank:gsub("#%x%x%x%x%x%x","").."\n["..getColorWhereRank(v):gsub("#%x%x%x%x%x%x","")..""..visualid:gsub("#%x%x%x%x%x%x","")..""..(v:getData("id") or 0).."] "..string.gsub(v.name, "#%x%x%x%x%x%x", ""):gsub("#%x%x%x%x%x%x","").." "..chat.."\n"..prefix:gsub("#%x%x%x%x%x%x",""), coords[1]+1, coords[2]+1, coords[1]+1, coords[2]+1, tocolor(0, 0, 0, 255), 0.7-distance/45, utils.nametagFont or "default-bold", "center", "center", false, true, false, true)
dxDrawText(minimalized.."\n\n"..statue.."\n"..dutyf.."\n"..getColorWhereRank(v)..""..visualrank.."#FFFFFF\n["..getColorWhereRank(v)..""..visualid..""..(v:getData("id") or 0).."#FFFFFF] "..string.gsub(v.name, "#%x%x%x%x%x%x", "").." "..chat.."\n"..prefix, coords[1], coords[2], coords[1], coords[2], tocolor(255, 255, 255, 255), 0.7-distance/45, utils.nametagFont or "default-bold", "center", "center", false, true, false, true)
elseif v:getData("player:level") and not visualrank then
dxDrawText(minimalized.."\n\n"..statue:gsub("#%x%x%x%x%x%x","").."\n"..rank.."\n["..(v:getData("id") or 0).."] "..string.gsub(v.name, "#%x%x%x%x%x%x", "").." "..chat:gsub("#%x%x%x%x%x%x","").."\n"..prefix:gsub("#%x%x%x%x%x%x",""), coords[1]+1, coords[2]+1, coords[1]+1, coords[2]+1, tocolor(0, 0, 0, 255), 0.7-distance/45, utils.nametagFont or "default-bold", "center", "center", false, true, false, true)
dxDrawText(minimalized.."\n\n"..statue.."\n"..getColorWhereRank(v)..""..rank.."#FFFFFF\n["..getColorWhereRank(v)..""..(v:getData("id") or 0).."#FFFFFF] "..string.gsub(v.name, "#%x%x%x%x%x%x", "").." "..chat.."\n"..prefix, coords[1], coords[2], coords[1], coords[2], tocolor(255, 255, 255, 255), 0.7-distance/45, utils.nametagFont or "default-bold", "center", "center", false, true, false, true)
elseif v:getData("player:level") and visualrank then
dxDrawText(minimalized.."\n\n"..statue:gsub("#%x%x%x%x%x%x","").."\n"..visualrank:gsub("#%x%x%x%x%x%x","").."\n["..(v:getData("id") or 0).."] "..string.gsub(v.name, "#%x%x%x%x%x%x", "").." "..chat:gsub("#%x%x%x%x%x%x","").."\n"..prefix:gsub("#%x%x%x%x%x%x",""), coords[1]+1, coords[2]+1, coords[1]+1, coords[2]+1, tocolor(0, 0, 0, 255), 0.7-distance/45, utils.nametagFont or "default-bold", "center", "center", false, true, false, true)
dxDrawText(minimalized.."\n\n"..statue.."\n"..visualrank.."#FFFFFF\n["..visualid..""..(v:getData("id") or 0).."#FFFFFF] "..string.gsub(v.name, "#%x%x%x%x%x%x", "").." "..chat.."\n"..prefix, coords[1], coords[2], coords[1], coords[2], tocolor(255, 255, 255, 255), 0.7-distance/45, utils.nametagFont or "default-bold", "center", "center", false, true, false, true)
elseif v:getData("player:duty") then
dxDrawText(minimalized.."\n\n"..statue:gsub("#%x%x%x%x%x%x","").."\n"..dutyf:gsub("#%x%x%x%x%x%x","").."\n["..(v:getData("id") or 0).."] "..string.gsub(v.name, "#%x%x%x%x%x%x", "").." "..chat:gsub("#%x%x%x%x%x%x","").."\n"..prefix:gsub("#%x%x%x%x%x%x",""), coords[1]+1, coords[2]+1, coords[1]+1, coords[2]+1, tocolor(0, 0, 0, 255), 0.7-distance/45, utils.nametagFont or "default-bold", "center", "center", false, true, false, true)
dxDrawText(minimalized.."\n\n"..statue.."\n"..dutyf.."\n#FFFFFF["..getColorWhereRank(v)..""..(v:getData("id") or 0).."#FFFFFF] "..string.gsub(v.name, "#%x%x%x%x%x%x", "").." "..chat.."\n"..prefix, coords[1], coords[2], coords[1], coords[2], tocolor(255, 255, 255, 255), 0.7-distance/45, utils.nametagFont or "default-bold", "center", "center", false, true, false, true)
else
dxDrawText(minimalized.."\n\n"..statue:gsub("#%x%x%x%x%x%x","").."\n["..(v:getData("id") or 0).."] "..string.gsub(v.name, "#%x%x%x%x%x%x", "").." "..chat:gsub("#%x%x%x%x%x%x","").."\n"..prefix:gsub("#%x%x%x%x%x%x",""), coords[1]+1, coords[2]+1, coords[1]+1, coords[2]+1, tocolor(0, 0, 0, 255), 0.7-distance/45, utils.nametagFont or "default-bold", "center", "center", false, true, false, true)
dxDrawText(minimalized.."\n\n"..statue.."\n["..getColorWhereRank(v)..""..(v:getData("id") or 0).."#FFFFFF] "..string.gsub(v.name, "#%x%x%x%x%x%x", "").." "..chat.."\n"..prefix, coords[1], coords[2], coords[1], coords[2], tocolor(255, 255, 255, 255), 0.7-distance/45, utils.nametagFont or "default-bold", "center", "center", false, true, false, true)
end
end
end
end
end
end)
function checkPlayerChatTyping()
if isChatBoxInputActive() then
if getElementData(localPlayer, "chat_typing")==false then
setElementData(localPlayer, "chat_typing", true)
end
else
if getElementData(localPlayer, "chat_typing")==true then
setElementData(localPlayer, "chat_typing", false)
end
end
end
setTimer(checkPlayerChatTyping, 100, 0)