Jump to content

Lifebar, name Bot


Lalalu

Recommended Posts

Posted (edited)

Buenas, el motivo de este post es el siguiente:

Quisiera saber como podría añadirle una barra de vida y un determinado nombre a un bot, estuve investigando en la comunidad para ver si podía conseguir scripts similares a lo que quiero y así poder usarlos, pero fracasé en el intento, espero que por favor puedan guiarme en cuanto a las funciones que debería usar

function makeAPed2 ( )
    SuperBoss = exports.slothbot:spawnBot ( 607.00031, 857.02875, -42.95893, 0,  101 , 0, 0, asd, 38, "fire", true )
	local LifeBoss = exports.extra_health:setElementExtraHealth ( SuperBoss, 5000 )
	outputChatBox ("#ff0000<Alerta> El Jefe <The Gleam Eyes> ha aparecido en el piso 01 de Aincrad!",getRootElement(), 255, 255, 255, true )
end
addEventHandler ( "onResourceStart", resourceRoot, makeAPed2)
 
    addEvent("onBotWasted", true)
    addEventHandler("onBotWasted", root, function(attacker, weapon, bodypart)
        if source == SuperBoss then
        givePlayerMoney ( SuperBoss, 50000 )
        outputChatBox ("<Felicidades> El jugador "..getPlayerName ( SuperBoss )..", #ffff00acabó con el jefe #ff0000<The Gleam Eyes> #ffff00y obtuvo una recompensa de +¥50000",getRootElement(), 255, 255, 255, true )
        setTimer(makeAPed2, 15*60000, 1)
        end
    end)

 

Edited by Lalalu
Posted
-- SERVER 

function makeAPed2 ( )
    SuperBoss = exports.slothbot:spawnBot ( 607.00031, 857.02875, -42.95893, 0,  101 , 0, 0, asd, 0, "fire", true )
	local LifeBoss = exports.extra_health:setElementExtraHealth ( SuperBoss, health )
	outputChatBox ("#ff0000<Alerta> El Jefe <The Gleam Eyes> ha aparecido en el piso 01 de Aincrad!",getRootElement(), 255, 255, 255, true )
    triggerClientEvent("clientp", root, SuperBoss, health, "The Gleam Eyes")
end
addCommandHandler("mak", makeAPed2)

 
    addEvent("onBotWasted", true)
    addEventHandler("onBotWasted", root, function(attacker, weapon, bodypart)
        if source == SuperBoss then
        givePlayerMoney ( attacker, 50000 )
        outputChatBox ("<Felicidades> El jugador "..getPlayerName ( attacker )..", #ffff00acabó con el jefe #ff0000<The Gleam Eyes> #ffff00y obtuvo una recompensa de +¥50000",getRootElement(), 255, 255, 255, true )
        setTimer(makeAPed2, 15*60000, 1)
        end
    end)

-- CLIENT 

addEvent("clientp", true)
addEventHandler("clientp", localPlayer, 
  function(ped, health, name)
    gleam = ped 
    hp = health 
    nick = name
    addEventHandler("onClientRender", root, drawHPBar)
  end 
)

function drawHPBar()
	local gx, gy, gz = getCameraMatrix()
	if isElement( gleam ) then 
	    local px, py, pz = getElementPosition( gleam ) 
	    local bx, by, bz = getPedBonePosition( gleam, 6 )
	    if ( getDistanceBetweenPoints3D( gx, gy, gz, px, py, pz ) < 60 ) then
	        local zx, zy = getScreenFromWorldPosition(bx,by,bz+0.3)
	        local pHealth = exports.extra_health:getElementExtraHealth( gleam )
	        local bossHealth = getElementHealth( gleam ) + pHealth
	        if (zx and isPedDead( gleam ) == false ) then 
	           dxDrawText( nick, zx+5, zy )
	           dxDrawRectangle( zx+5, zy+15, 90, 12, tocolor( 0, 0, 0, 255 ))
	           dxDrawRectangle( zx+5, zy+15, 90*(bossHealth/hp), 12)
	        end
	    end
	end
end

Si no entiendes algo me avisas.

Posted (edited)

muchas gracias, tengo una duda, osea como se toma la posición de la pantalla o mejor dicho la posición donde aparece la barra de vida y el nombre?, el getScreenFromWorldPosition es el que hace posible eso? o la barra y el nombre solo toman la posicón de la parte del cuerpo y ahí es donde aparece?

Edited by Lalalu
Posted

El getScreenFromWorldPosition es lo que hace que se vea en 3d, el grtPedBonePosition es solo para sacar la posición de algún hueso(en este caso la cabeza). 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...