Narutimmy Posted June 4, 2013 Posted June 4, 2013 Tengo este codigo que edite para crear una barra de vida encima de un slotbot.. pero nose que pasa que no funciona ---BOSS Vida local maxDist = 60 function BossNameTag() local witchs = getElementsByType ( "ped",getRootElement(),true ) local Px,Py,Pz = getCameraMatrix( ) for theKey,theWitch in ipairs(witchs) do if (isElement(theWitch)) then local Zx,Zy,Zz = getElementPosition( slothbot1 ) local zhx,zhy,zhz = getPedBonePosition(slothbot1,6) if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < maxDist ) then if (getElementData (slothbot1, "slothbot1") == true) then local sxx,syy = getScreenFromWorldPosition(zhx,zhy,zhz+0.3) local currentDistance = getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) local maxHP = exports.extra_health:getElementExtraHealth(slothbot1) local currentHealth = getElementData(slothbot1, "currenthealth") if sxx and getElementHealth(slothbot1) > 0 then sx,sy = sxx-60,syy-10 dxDrawRectangle(sx+5,sy+25,131.0/maxHP*currentHealth,12.0,tocolor(255,0,0,200),false) -- health dxDrawRectangle(sx,sy,146.0,46.0,tocolor(0,0,0,0),false) -- background dxDrawRectangle(sx+5,sy+25,131.0,12.0,tocolor(0,0,0,100),false) -- bg health dxDrawText("BOSS",sx+26,sy,596.0,236.0,tocolor(255,0,0,255),1.0,"default","left","top",false,false,false) -- z name end end end end end end addEventHandler("onBotSpawned", root, BossNameTag)
Plate Posted June 4, 2013 Posted June 4, 2013 Ese es mi code y no te recomiendoe editarlo asi simplemente hace esto agregale a tu boss esto setElementData(slothbot1, "Witch", true)
Narutimmy Posted June 4, 2013 Author Posted June 4, 2013 Ese es mi code y no te recomiendoe editarlo asi simplemente hace estoagregale a tu boss esto setElementData(slothbot1, "Witch", true) el codigo lo saque del scrip que subieron de la witch
Narutimmy Posted June 5, 2013 Author Posted June 5, 2013 Ese es mi code y no te recomiendoe editarlo asi simplemente hace estoagregale a tu boss esto setElementData(slothbot1, "Witch", true) ya lo intente de diferentes maneras pero no me funciona ... como puedo hacerlo para un slotbot?
Plate Posted June 5, 2013 Posted June 5, 2013 No hagas doble post simplemente editalo Usa el codigo sin modificar y ponele a tu slothbot setElementData(tu variable del slothbot, "Witch, "true) y te va a funcionar EDIT: Tambien tenes que ponerle esto setElementData(tu variable del slothbot, "currenthealth", exports.extra_health:getElementExtraHealth(tu variable del slothbot))
Narutimmy Posted June 5, 2013 Author Posted June 5, 2013 No hagas doble post simplemente editaloUsa el codigo sin modificar y ponele a tu slothbot setElementData(tu variable del slothbot, "Witch, "true) y te va a funcionar EDIT: Tambien tenes que ponerle esto setElementData(tu variable del slothbot, "currenthealth", exports.extra_health:getElementExtraHealth(tu variable del slothbot)) Pues ya lo intente pero no, lo que pasa creo es porque mis slotbot no spawnea al iniciar el recurso, sino a un determinado tiempo. Sv: function zona (attacker, weapon, bodypart) if ( isElementWithinColShape ( source, colshape ) ) then zombiesMatados = ( zombiesMatados + 1 ) if ( zombiesMatados == 5 ) then --Numero de Zombis por Matar if ( not isElement ( slothbot1 ) ) then local x, y, z = getElementPosition(attacker) local skin = math.random ( 33, 36 ) slothbot1 = exports [ "slothbot" ]:spawnBot ( x+10, y, z+3, 90, skin, 0, 0, false, weapons [ skin ] or 0, "hunting" ) myBlip = createBlipAttachedTo ( slothbot1, 23 ) setElementData(slothbot1, "Witch", true) setElementData(slothbot1, "currenthealth", exports.extra_health:getElementExtraHealth(slothbot1)) local id = getElementModel ( slothbot1 ) if id == 33 then exports.extra_health:setElementExtraHealth(slothbot1, 30000) outputChatBox ( "#ff0000Nemesis: #eeff00S.T.A.R.S!!!", getRootElement(), 255, 255, 255, true) elseif id == 34 then exports.extra_health:setElementExtraHealth(slothbot1, 100000) setElementData(slothbot1, "Witch", true) outputChatBox ( "#ff0000Tyrant a Spawneado, Corre!", getRootElement(), 255, 255, 255, true) elseif id == 35 then exports.extra_health:setElementExtraHealth(slothbot1, 15000) outputChatBox("[bOSS]:Boss low spawned", getRootElement(), 155, 155, 155, false) elseif id == 36 then exports.extra_health:setElementExtraHealth(slothbot1, 400000) outputChatBox("Lincker a Spawneado...", getRootElement(), 155, 155, 155, false) end end end end end addEventHandler ( "onZombieWasted", getRootElement(), zona ) cl: ---- local maxDist = 60 function witchNameTag() local witchs = getElementsByType ( "ped",getRootElement(),true ) local Px,Py,Pz = getCameraMatrix( ) for theKey,theWitch in ipairs(witchs) do if (isElement(theWitch)) then local Zx,Zy,Zz = getElementPosition( theWitch ) local zhx,zhy,zhz = getPedBonePosition(theWitch,6) if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < maxDist ) then if (getElementData (theWitch, "Witch") == true) then local sxx,syy = getScreenFromWorldPosition(zhx,zhy,zhz+0.3) local currentDistance = getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) --local zombieHealth = getElementHealth(theWitch) local maxHP = exports.extra_health:getElementExtraHealth(theWitch) local currentHealth = getElementData(theWitch, "currenthealth") if sxx and getElementHealth(theWitch) > 0 then sx,sy = sxx-60,syy-10 dxDrawRectangle(sx+5,sy+25,131.0/maxHP*currentHealth,12.0,tocolor(255,0,0,200),false) -- health dxDrawRectangle(sx,sy,146.0,46.0,tocolor(0,0,0,0),false) -- background dxDrawRectangle(sx+5,sy+25,131.0,12.0,tocolor(0,0,0,100),false) -- bg health dxDrawText("Witch",sx+26,sy,596.0,236.0,tocolor(255,0,0,255),1.0,"default","left","top",false,false,false) -- z name end end end end end end addEventHandler("onClientRender", root, witchNameTag)
Plate Posted June 5, 2013 Posted June 5, 2013 Ah me abia olvidado de eso pone un triggerClientEvent y tambien removeEventHandler
Narutimmy Posted June 6, 2013 Author Posted June 6, 2013 Ah me abia olvidado de eso pone un triggerClientEvent y tambien removeEventHandler no te entendi :I
Plate Posted June 6, 2013 Posted June 6, 2013 function zona (attacker, weapon, bodypart) if ( isElementWithinColShape ( source, colshape ) ) then zombiesMatados = ( zombiesMatados + 1 ) if ( zombiesMatados == 5 ) then --Numero de Zombis por Matar if ( not isElement ( slothbot1 ) ) then local x, y, z = getElementPosition(attacker) local skin = math.random ( 33, 36 ) if slothbot1 = exports [ "slothbot" ]:spawnBot ( x+10, y, z+3, 90, skin, 0, 0, false, weapons [ skin ] or 0, "hunting" ) then triggerClientEvent("spawneo". getRootElement()) myBlip = createBlipAttachedTo ( slothbot1, 23 ) setElementData(slothbot1, "Witch", true) setElementData(slothbot1, "currenthealth", exports.extra_health:getElementExtraHealth(slothbot1)) local id = getElementModel ( slothbot1 ) if id == 33 then exports.extra_health:setElementExtraHealth(slothbot1, 30000) outputChatBox ( "#ff0000Nemesis: #eeff00S.T.A.R.S!!!", getRootElement(), 255, 255, 255, true) elseif id == 34 then exports.extra_health:setElementExtraHealth(slothbot1, 100000) setElementData(slothbot1, "Witch", true) outputChatBox ( "#ff0000Tyrant a Spawneado, Corre!", getRootElement(), 255, 255, 255, true) elseif id == 35 then exports.extra_health:setElementExtraHealth(slothbot1, 15000) outputChatBox("[bOSS]:Boss low spawned", getRootElement(), 155, 155, 155, false) elseif id == 36 then exports.extra_health:setElementExtraHealth(slothbot1, 400000) outputChatBox("Lincker a Spawneado...", getRootElement(), 155, 155, 155, false) end end end end end end addEventHandler ( "onZombieWasted", getRootElement(), zona ) local maxDist = 60 function witchNameTag() local witchs = getElementsByType ( "ped",getRootElement(),true ) local Px,Py,Pz = getCameraMatrix( ) for theKey,theWitch in ipairs(witchs) do if (isElement(theWitch)) then local Zx,Zy,Zz = getElementPosition( theWitch ) local zhx,zhy,zhz = getPedBonePosition(theWitch,6) if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < maxDist ) then if (getElementData (theWitch, "Witch") == true) then local sxx,syy = getScreenFromWorldPosition(zhx,zhy,zhz+0.3) local currentDistance = getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) local maxHP = exports.extra_health:getElementExtraHealth(theWitch) local currentHealth = getElementData(theWitch, "currenthealth") if sxx and getElementHealth(theWitch) > 0 then sx,sy = sxx-60,syy-10 dxDrawRectangle(sx+5,sy+25,131.0/maxHP*currentHealth,12.0,tocolor(255,0,0,200),false) dxDrawRectangle(sx,sy,146.0,46.0,tocolor(0,0,0,0),false) dxDrawRectangle(sx+5,sy+25,131.0,12.0,tocolor(0,0,0,100),false) dxDrawText("Witch",sx+26,sy,596.0,236.0,tocolor(255,0,0,255),1.0,"default","left","top",false,false,false) end end end end end end addEvent("spawneo", true) addeventHandler("spawneo", getRootElement(), witchNameTag) addEventHandler( "onClientRender", root, witchNameTag ) setTimer( function () removeEventHandler("spawneo", root, witchNameTag) end , 1000, 1 ) creo que esta mal pero probalo jaja
Narutimmy Posted June 6, 2013 Author Posted June 6, 2013 function zona (attacker, weapon, bodypart) if ( isElementWithinColShape ( source, colshape ) ) then zombiesMatados = ( zombiesMatados + 1 ) if ( zombiesMatados == 5 ) then --Numero de Zombis por Matar if ( not isElement ( slothbot1 ) ) then local x, y, z = getElementPosition(attacker) local skin = math.random ( 33, 36 ) if slothbot1 = exports [ "slothbot" ]:spawnBot ( x+10, y, z+3, 90, skin, 0, 0, false, weapons [ skin ] or 0, "hunting" ) then triggerClientEvent("spawneo". getRootElement()) myBlip = createBlipAttachedTo ( slothbot1, 23 ) setElementData(slothbot1, "Witch", true) setElementData(slothbot1, "currenthealth", exports.extra_health:getElementExtraHealth(slothbot1)) local id = getElementModel ( slothbot1 ) if id == 33 then exports.extra_health:setElementExtraHealth(slothbot1, 30000) outputChatBox ( "#ff0000Nemesis: #eeff00S.T.A.R.S!!!", getRootElement(), 255, 255, 255, true) elseif id == 34 then exports.extra_health:setElementExtraHealth(slothbot1, 100000) setElementData(slothbot1, "Witch", true) outputChatBox ( "#ff0000Tyrant a Spawneado, Corre!", getRootElement(), 255, 255, 255, true) elseif id == 35 then exports.extra_health:setElementExtraHealth(slothbot1, 15000) outputChatBox("[bOSS]:Boss low spawned", getRootElement(), 155, 155, 155, false) elseif id == 36 then exports.extra_health:setElementExtraHealth(slothbot1, 400000) outputChatBox("Lincker a Spawneado...", getRootElement(), 155, 155, 155, false) end end end end end end addEventHandler ( "onZombieWasted", getRootElement(), zona ) local maxDist = 60 function witchNameTag() local witchs = getElementsByType ( "ped",getRootElement(),true ) local Px,Py,Pz = getCameraMatrix( ) for theKey,theWitch in ipairs(witchs) do if (isElement(theWitch)) then local Zx,Zy,Zz = getElementPosition( theWitch ) local zhx,zhy,zhz = getPedBonePosition(theWitch,6) if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < maxDist ) then if (getElementData (theWitch, "Witch") == true) then local sxx,syy = getScreenFromWorldPosition(zhx,zhy,zhz+0.3) local currentDistance = getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) local maxHP = exports.extra_health:getElementExtraHealth(theWitch) local currentHealth = getElementData(theWitch, "currenthealth") if sxx and getElementHealth(theWitch) > 0 then sx,sy = sxx-60,syy-10 dxDrawRectangle(sx+5,sy+25,131.0/maxHP*currentHealth,12.0,tocolor(255,0,0,200),false) dxDrawRectangle(sx,sy,146.0,46.0,tocolor(0,0,0,0),false) dxDrawRectangle(sx+5,sy+25,131.0,12.0,tocolor(0,0,0,100),false) dxDrawText("Witch",sx+26,sy,596.0,236.0,tocolor(255,0,0,255),1.0,"default","left","top",false,false,false) end end end end end end addEvent("spawneo", true) addeventHandler("spawneo", getRootElement(), witchNameTag) addEventHandler( "onClientRender", root, witchNameTag ) setTimer( function () removeEventHandler("spawneo", root, witchNameTag) end , 1000, 1 ) creo que esta mal pero probalo jaja lo probe y no funciono me tiraba error en el if y esto, ademas del evento tambien if slothbot1 = exports [ "slothbot" ]:spawnBot ( x+10, y, z+3, 90, skin, 0, 0, false, weapons [ skin ] or 0, "hunting" ) then triggerClientEvent("spawneo". getRootElement())
Sasu Posted June 6, 2013 Posted June 6, 2013 slothbot1 = exports [ "slothbot" ]:spawnBot ( x+10, y, z+3, 90, skin, 0, 0, false, weapons [ skin ] or 0, "hunting" ) if slothbot1 then triggerClientEvent("spawneo", getRootElement())
Narutimmy Posted June 6, 2013 Author Posted June 6, 2013 slothbot1 = exports [ "slothbot" ]:spawnBot ( x+10, y, z+3, 90, skin, 0, 0, false, weapons [ skin ] or 0, "hunting" ) if slothbot1 then triggerClientEvent("spawneo", getRootElement()) me sale este error: EDIT: El problema era que estaba una letra en minusculas pero ahora me sale este error:
Castillo Posted June 6, 2013 Posted June 6, 2013 Cuando estas poniendo la element data: "currentHealth"?
Narutimmy Posted June 6, 2013 Author Posted June 6, 2013 Cuando estas poniendo la element data: "currentHealth"? if slothbot1 then triggerClientEvent("spawneo", getRootElement()) myBlip = createBlipAttachedTo ( slothbot1, 23 ) setElementData(slothbot1, "Witch", true) setElementData(localPed, "currenthealth", exports.extra_health:getElementExtraHealth(slothbot1)) local id = getElementModel ( slothbot1 ) en el Server. intente en el client cambiando local currentHealth = exports.extra_health:getElementExtraHealth(slothbot1) y aparece la barra llena pero no disminuye.. eo Slot muere y la barra sigue igual.
Plate Posted June 6, 2013 Posted June 6, 2013 Cuando estas poniendo la element data: "currentHealth"? if slothbot1 then triggerClientEvent("spawneo", getRootElement()) myBlip = createBlipAttachedTo ( slothbot1, 23 ) setElementData(slothbot1, "Witch", true) setElementData(localPed, "currenthealth", exports.extra_health:getElementExtraHealth(slothbot1)) local id = getElementModel ( slothbot1 ) en el Server. intente en el client cambiando local currentHealth = exports.extra_health:getElementExtraHealth(slothbot1) y aparece la barra llena pero no disminuye.. eo Slot muere y la barra sigue igual. No Lees lo que digo te dije que pongas el code sin modificar setElementData(slothbot1, "currenthealth", exports.extra_health:getElementExtraHealth(slothbot1)) local currentHealth = getElementData(theWitch, "currenthealth") creo que tendrias que empesar a scriptear
Narutimmy Posted June 6, 2013 Author Posted June 6, 2013 Cuando estas poniendo la element data: "currentHealth"? if slothbot1 then triggerClientEvent("spawneo", getRootElement()) myBlip = createBlipAttachedTo ( slothbot1, 23 ) setElementData(slothbot1, "Witch", true) setElementData(localPed, "currenthealth", exports.extra_health:getElementExtraHealth(slothbot1)) local id = getElementModel ( slothbot1 ) en el Server. intente en el client cambiando local currentHealth = exports.extra_health:getElementExtraHealth(slothbot1) y aparece la barra llena pero no disminuye.. eo Slot muere y la barra sigue igual. No Lees lo que digo te dije que pongas el code sin modificar setElementData(slothbot1, "currenthealth", exports.extra_health:getElementExtraHealth(slothbot1)) local currentHealth = getElementData(theWitch, "currenthealth") creo que tendrias que empesar a scriptear El escrip sin modificar es este: sv- function Boss () blip = {} marker = {} local localPed = createPed( 33, -175.610, 57.66, 3.2 ) local health = exports.extra_health:setElementExtraHealth ( localPed, 1000 ) setElementModel ( localPed, 33 ) setPedAnimation(localPed, "ped", "cower", -1, true, true, false) setElementData(localPed, "type", "RealWitch") setPedStat(localPed, 24, 1000) RealWitch = localPed blip[1] = (createBlipAttachedTo ( localPed, 0 )) triggerClientEvent ( "witchsound", root ) setElementData(localPed, "currenthealth", exports.extra_health:getElementExtraHealth(RealWitch)) setElementData(localPed, "Witch", true) end addEventHandler("onResourceStart", resourceRoot, Boss) addEvent("onWitchReady", true) cl- local maxDist = 60 function witchNameTag() local witchs = getElementsByType ( "ped",getRootElement(),true ) local Px,Py,Pz = getCameraMatrix( ) for theKey,theWitch in ipairs(witchs) do if (isElement(theWitch)) then local Zx,Zy,Zz = getElementPosition( theWitch ) local zhx,zhy,zhz = getPedBonePosition(theWitch,6) if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < maxDist ) then if (getElementData (theWitch, "Witch") == true) then local sxx,syy = getScreenFromWorldPosition(zhx,zhy,zhz+0.3) local currentDistance = getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) --local zombieHealth = getElementHealth(theWitch) local maxHP = exports.extra_health:getElementExtraHealth(theWitch) local currentHealth = getElementData(theWitch, "currenthealth") if sxx and getElementHealth(theWitch) > 0 then sx,sy = sxx-60,syy-10 dxDrawRectangle(sx+5,sy+25,131.0/maxHP*currentHealth,12.0,tocolor(255,0,0,200),false) -- health dxDrawRectangle(sx,sy,146.0,46.0,tocolor(0,0,0,0),false) -- background dxDrawRectangle(sx+5,sy+25,131.0,12.0,tocolor(0,0,0,100),false) -- bg health dxDrawText("Witch",sx+26,sy,596.0,236.0,tocolor(255,0,0,255),1.0,"default","left","top",false,false,false) -- z name end end end end end end addEventHandler("onClientRender", root, witchNameTag) y al mio solo le agregue lo que dijistes pero no funciona, como lo piblique arrivva si funciona pero tira ese error del currenthealth
Plate Posted June 7, 2013 Posted June 7, 2013 Leistes lo que cambie en el element data me referia en el client :facepalm:
Narutimmy Posted June 7, 2013 Author Posted June 7, 2013 Leistes lo que cambie en el element data me referia en el client :facepalm: La Verdad ya no te entendi nada ... igual gracias por la Ayuda, seguire buscando.
Sensacion Posted June 7, 2013 Posted June 7, 2013 Server: function zona ( attacker, weapon, bodypart ) if ( isElementWithinColShape ( source, colshape ) ) then zombiesMatados = ( zombiesMatados + 1 ) if ( zombiesMatados == 5 ) then --Numero de Zombis por Matar if ( not isElement ( slothbot1 ) ) then local x, y, z = getElementPosition(attacker) local skin = math.random ( 33, 36 ) slothbot1 = exports [ "slothbot" ]:spawnBot ( -175.610, 57.66, 3.2, 0, skin, 0, 0, _, _, "hunting" ) myBlip = createBlipAttachedTo ( slothbot1, 23 ) setElementData(slothbot1, "Witch", true) local id = getElementModel ( slothbot1 ) if id == 33 then exports.extra_health:setElementExtraHealth(slothbot1, 30000) outputChatBox ( "#ff0000Nemesis: #eeff00S.T.A.R.S!!!", getRootElement(), 255, 255, 255, true) elseif id == 34 then exports.extra_health:setElementExtraHealth(slothbot1, 100000) outputChatBox ( "#ff0000Tyrant a Spawneado, Corre!", getRootElement(), 255, 255, 255, true) elseif id == 35 then exports.extra_health:setElementExtraHealth(slothbot1, 15000) outputChatBox("[bOSS]:Boss low spawned", getRootElement(), 155, 155, 155, false) elseif id == 36 then exports.extra_health:setElementExtraHealth(slothbot1, 400000) outputChatBox("Lincker a Spawneado...", getRootElement(), 155, 155, 155, false) end setElementData( slothbot1, "currenthealth", exports.extra_health:getElementExtraHealth( slothbot1 ) ) end end end end addEventHandler ( "onZombieWasted", getRootElement(), zona ) Client: local maxDist = 60 function witchNameTag() local witchs = getElementsByType ( "ped",getRootElement(),true ) local Px,Py,Pz = getCameraMatrix( ) for theKey,theWitch in ipairs(witchs) do if ( isElement( theWitch ) ) then local Zx,Zy,Zz = getElementPosition( theWitch ) local zhx,zhy,zhz = getPedBonePosition( theWitch,6 ) if (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz ) < maxDist ) then if ( getElementData (theWitch, "Witch") == true) then local sxx,syy = getScreenFromWorldPosition(zhx,zhy,zhz+0.3) local currentDistance = getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) --local zombieHealth = getElementHealth(theWitch) local maxHP = exports.extra_health:getElementExtraHealth(theWitch) local currentHealth = getElementData(theWitch, "currenthealth") if sxx and getElementHealth(theWitch) > 0 then sx,sy = sxx-60,syy-10 dxDrawRectangle(sx+5,sy+25,131.0/maxHP*currentHealth,12.0,tocolor(255,0,0,200),false) -- health dxDrawRectangle(sx,sy,146.0,46.0,tocolor(0,0,0,0),false) -- background dxDrawRectangle(sx+5,sy+25,131.0,12.0,tocolor(0,0,0,100),false) -- bg health dxDrawText("Witch",sx+26,sy,596.0,236.0,tocolor(255,0,0,255),1.0,"default","left","top",false,false,false) -- z name end end end end end end addEventHandler( "onClientRender", root, witchNameTag )
Narutimmy Posted June 7, 2013 Author Posted June 7, 2013 Bueno creo el error solo era la Ubicacion de la setElementData( slothbot1, "currenthealth", exports.extra_health:getElementExtraHealth( slothbot1 ) ) ya todo bien, el problema es que la barra en lugar de hacerse mas pequeña al bajarle vida el Slotbot.... se ase mas y mas grande
Recommended Posts