В .client
local All3DText = {}
for _, source in ipairs(getElementsByType("pickup", true)) do -- Этот участок кода необходим если планируешь перезапускать текущий ресурс
local text = getElementData(source, "3DText")
if(text) then
All3DText[source] = text
end
end
addEventHandler("onClientElementStreamIn", getRootElement(),
function()
if getElementType(source) == "pickup" then
local text = getElementData(source, "3DText")
if(text) then
All3DText[source] = text
end
end
end
);
addEventHandler("onClientElementStreamOut", getRootElement(),
function()
if getElementType(source) == "pickup" then
local text = getElementData(source, "3DText")
if(text) then
All3DText[source] = nil
end
end
end
);
function dxDrawBorderedText(text,left,top,right,bottom,color,scale,outlinesize,font,alignX,alignY,clip,wordBreak,postGUI,colorCoded)
local outlinesize = math.min(scale,outlinesize)
if outlinesize > 0 then
for offsetX=-outlinesize,outlinesize,outlinesize do
for offsetY=-outlinesize,outlinesize,outlinesize do
if not (offsetX == 0 and offsetY == 0) then
dxDrawText(text:gsub("#%x%x%x%x%x%x",""), left+offsetX, top+offsetY, right+offsetX, bottom+offsetY, tocolor(0, 0, 0, 255), scale, font, alignX, alignY, clip, wordBreak, postGUI)
end
end
end
end
dxDrawText(text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded)
end
function nameText()
local cx,cy,cz = getCameraMatrix()
for pickup, text in pairs(All3DText) do
local px,py,pz = getElementPosition(pickup)
local distance = getDistanceBetweenPoints3D(cx,cy,cz,px,py,pz)
local posx,posy = getScreenFromWorldPosition(px,py,pz+0.025*distance+0.40)
if posx and distance <= 15 then
dxDrawBorderedText(text,posx,posy,posx,posy,tocolor(255,175,0,255),1,1,"default-bold","center","top",false,false,false)
end
end
end
addEventHandler("onClientHUDRender",root,nameText)
В .server
setElementData(housePickup, "3DText", "Мой 3D текст")