Nuevo script: 25/04/2017
Este script de nametags al estilo SA:MP cuenta con una barra de vida y barra de chaleco indicando el nivel de cada uno de los estados. Se puede modificar a vuestro gusto. Se añade el nametag únicamente si el jugador está logueado, esto se puede editar también:
SERVER-SIDE
addEventHandler( "onPlayerQuit", getRootElement( ),
function( )
triggerClientEvent( root, "nmtgs:removePlayer", root, source )
end
)
addEventHandler( "onPlayerLogout", getRootElement( ),
function( )
triggerClientEvent( root, "nmtgs:removePlayer", root, source )
end
)
addEventHandler( "onPlayerLogin", getRootElement( ),
function( )
triggerClientEvent( root, "nmtgs:addPlayer", root, source )
end
)
CLIENT-SIDE
local players = { }
addEvent( "nmtgs:addPlayer", true )
addEventHandler( "nmtgs:addPlayer", getRootElement( ),
function( player )
players[ player ] = player
end
)
addEvent( "nmtgs:removePlayer", true )
addEventHandler( "nmtgs:removePlayer", getRootElement( ),
function( player )
if players[ player ] then
players[ player ] = nil
end
end
)
addEventHandler( "onClientRender", root,
function()
local cx, cy, cz = getCameraMatrix()
local lx, ly, lz = getElementPosition( localPlayer )
local jugadores = getElementsByType( "player" )
for i=1, #jugadores do
local p = jugadores[i]
if players[ p ] then
local x, y, z = getElementPosition( p )
local dist = getDistanceBetweenPoints3D( lx, ly, lz, x, y, z )
if dist < 15 then
if isLineOfSightClear( lx, ly, lz, x, y, z, true, false, false, true, false, false, false, localPlayer ) then
local name = getPlayerName( p )
local bone = { getPedBonePosition( p, 5 ) }
local c = { getScreenFromWorldPosition( bone[1], bone[2], bone[3]+0.3 ) }
local width, health = 80, getElementHealth( p )
local armor = getPedArmor( p )
if c[1] and c[2] then
dxDrawText(name, c[1], c[2]-38, c[1], c[2], tocolor( 0, 0, 0 ), 1.5, "default-bold", "center", "center")
dxDrawText(name, c[1], c[2]-40, c[1], c[2], tocolor( 255, 255, 255 ), 1.5, "default-bold", "center", "center")
dxDrawRectangle( c[ 1 ] - ( width / 1.90 ), c[ 2 ] - 4, width+3, 11, tocolor( 0, 0, 0, 255 ) )
dxDrawRectangle( c[ 1 ] - ( width / 2 ), c[ 2 ] - 2.3, width, 8, tocolor( 150, 0, 0, 255 ) )
dxDrawRectangle( c[ 1 ] - ( width / 2 ), c[ 2 ] - 2.3, width * ( health / 100 ), 8, tocolor( 255, 0, 0, 255 ) )
if armor and tonumber( armor ) > 0 then
dxDrawRectangle( c[ 1 ] - ( width / 1.90 ), c[ 2 ] + 10, width+3, 11, tocolor( 0, 0, 0, 255 ) )
dxDrawRectangle( c[ 1 ] - ( width / 2 ), c[ 2 ] + 11.3, width, 8, tocolor( 150, 150, 150, 150 ) )
dxDrawRectangle( c[ 1 ] - ( width / 2 ), c[ 2 ] + 11.3, width * ( armor / 100 ), 8, tocolor( 255, 255, 255, 255 ) )
end
end
end
end
end
end
end
)
IMÁGENES