Ich wollte mal nametags machen funktionieren auch aber ich will nicht das wen ich weiter weg gehe die nametags dann in die höhe gehen sondern immer auf der gleichen position über den kopf des spielers bleiben egal wie weit man weg geht mein script
Lua
dxGUI["Nametag"] = function( )
local x, y = guiGetScreenSize()
for k, v in pairs( getElementsByType("ped") ) do
local posX, posY, posZ = getElementPosition( localPlayer )
local posX1, posY1, posZ1 = getElementPosition( v )
local distance = getDistanceBetweenPoints3D( posX, posY, posZ, posX1, posY1, posZ1 )
if( isLineOfSightClear(posX1, posY1, posZ1, posX, posY, posZ, true, true, false, true)) then
if (v ~= localPlayer) then
local player_health = getElementHealth( v )
local player_armor = getPedArmor( v )
local player_x, player_y, player_z = getElementPosition( v )
local player_worldX, player_worldY = getScreenFromWorldPosition( player_x, player_y, player_z, 1000 )
local dx_health = math.floor( math.abs(player_health * 2.14) )
-- local dx_text_bright_name = dxGetTextWidth( getPlayerName(v), 1.50 )
local dx_text_bright_armor = dxGetTextWidth( "Health: "..math.floor(math.abs(getPlayerArmor( v ))), 1.10 )
local dx_text_bright_health = dxGetTextWidth( "Armor: "..math.floor(math.abs(getElementHealth( v ))), 1.10 )
if ( player_worldX and player_worldY ) then
dxDrawRectangle(player_worldX-112, player_worldY-320, 224, 42, tocolor(254, 254, 254, 65), true) -- Backround
dxDrawRectangle(player_worldX-107, player_worldY-315, (getElementHealth(v)*2.14), 15, tocolor(145, 221, 0, 255), true) -- Health Retangel
dxDrawRectangle(player_worldX-107, player_worldY-297, (getPedArmor(v)*2.14), 15, tocolor(0, 159, 199, 255), true) -- Armor Retangel
-- dxDrawText(getPlayerName(v), player_worldX-(dx_text_bright_name/2), player_worldY-340, 887, 369, tocolor(255, 255, 255, 255), 1.50, "default-bold", "left", "top", false, false, true, false, false)
dxDrawText("Health: "..math.floor(math.abs(getElementHealth(v))).."%", player_worldX-(dx_text_bright_health/2), player_worldY-315, 887, 369, tocolor(255, 255, 255, 255), 1.10, "default-bold", "left", "top", false, false, true, false, false)
dxDrawText("Armor: "..math.floor(math.abs(getPedArmor(v))).."%", player_worldX-(dx_text_bright_armor/2), player_worldY-297, 887, 369, tocolor(255, 255, 255, 255), 1.10, "default-bold", "left", "top", false, false, true, false, false)
end
end
end
end
end
addEventHandler("onClientRender", getRootElement(), dxGUI["Nametag"])
Alles anzeigen