Jump to content

[Ayuda]Script Fail


Hathazen

Recommended Posts

Posted

Hola, Soy nuevo en esto de los Scripts y espero tener algo de esperanza en esto.. logré crear y editar varios resources sin problema hasta que me topé con este.

La idea es implementar un Boss (Némesis) en un servidor DayZ, me pareció una floja idea pedir que lo hagan por mi, así que buscando de post en post y con ayuda del manual de Scripting hice lo siguiente; el problema es que el cuando el Boss spawnea y ataca, no hace ningún daño, y cuando lo mato cae un 'Clon' al piso mientras que el original sigue disparando, alguna idea.. ?

-Server

  
local hillRadar = createRadarArea ( 93, 1800, 200, 200, 181, 0, 0, 200 ) 
  
 function BossDayZ ( )   
  
 nemesi = exports [ "slothBot" ]:spawnBot ( 259.837890625, 1816.2080078125, 1.0078125, 90, 33, 0, 0, Nemesis, 38, "hunting", true ) 
  
 setElementData( nemesi, "blood", 9999999999 )     
  
end 
  
 addEventHandler("onResourceStart", resourceRoot, BossDayZ )   
  
  
  
 function onPedAttack ( attacker ) 
  
local id2 = getElementModel ( attacker ) 
  
  if (id2 == 33)  then 
  setElementData( source,"blood" - 400) 
  setElementData ( source, getElementData(source, "blood") - 6000) 
  setElementData ( ptarget, source, "blood" - 2000) 
  
   end 
    
   end 
    
   addEventHandler("onPlayerDamage", getRootElement(), OnPedAttack) 
     setElementData( source,"blood" - 400) 
  setElementData ( source, getElementData(source, "blood") - 6000) 
  setElementData ( ptarget, source, "blood" - 2000) 
  
addEvent ( "getBloodBoss", true ) 
function getBloodBoss( nemesi ) 
killPed ( nemesi ) 
destroyElement ( nemesi ) 
end 
addEventHandler ( "getBloodBoss", getRootElement(), getBloodBoss ) 
  
  
  

-Client

  
function Skinemesis1() 
  txd = engineLoadTXD("data/107.txd", 93 ) 
  engineImportTXD(txd, 93) 
  dff = engineLoadDFF("data/107.dff", 93) 
  engineReplaceModel(dff, 93) 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), Skinemesis1) 
  
  
addEvent ( "nsound", true ) 
addEventHandler ( "nsound", root, 
    function ( ) 
        playSound ( "data/nemesis.mp3" ) 
    end 
     
     
) 
  
  
function getBloodBoss() 
local blood = getElementData( nemesi, "blood") 
if blood < 1 then 
triggerServerEvent ( "getBloodBoss", nemesi ) 
end 
end 
  

Posted

No tengo errores en el debug, pero luego de matarlo me sale < a nill value > Tal como dice Gaberiel.. debería cambiar el valor "Nemesis" por "nemesi" ?

Posted

Espero que esto te sea util, no pude probarlo pero igual te podria dar una idea en caso de no servirte. :P

-- Server Side.

local hillRadar = createRadarArea ( 93, 1800, 200, 200, 181, 0, 0, 200 ) 
  
function BossDayZ ( )  
    nemesi = exports [ "slothBot" ]:spawnBot ( 259.837890625, 1816.2080078125, 1.0078125, 90, 33, 0, 0, Nemesis, 38, "hunting", true ) 
    setElementData( nemesi, "blood", 9999999999 ) 
    triggerClientEvent ( "nsound", root ) 
end 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), BossDayZ )   
  
function onPedAttack ( attacker )  
    if ( isElement ( attacker ) == true ) then      -- Comprueba si existe el atacante antes de proceder. 
        if ( getElementModel ( attacker ) == 33)  then 
            setElementData ( source, getElementData(source, "blood") - 400) 
            setElementData ( ptarget, source, "blood" - 2000) 
        end 
    end 
end 
addEventHandler( "onPlayerDamage", getRootElement ( ), OnPedAttack ) 
  
addEvent ( "getBloodBoss", true ) 
function getBloodBoss( nemesi ) 
    if ( isElement ( nemesi ) ) then 
        killPed ( nemesi ) 
        destroyElement ( nemesi ) 
    end 
end 
addEventHandler ( "getBloodBoss", getRootElement(), getBloodBoss ) 

-- Client Side.

function Skinemesis1() 
    engineImportTXD( engineLoadTXD ("data/107.txd", 93 ), 93) 
    engineReplaceModel( engineLoadDFF ("data/107.dff", 93), 93) 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), Skinemesis1 ) 
  
addEvent ( "nsound", true ) 
addEventHandler ( "nsound", root, function ( ) 
    playSound ( "data/nemesis.mp3" ) 
end) 
  
function getBloodBoss ( attacker, weapon, bodypart ) 
    if ( isElement ( attacker ) ) then      -- Comprueba si existe el atacante antes de proceder. 
        if ( getElementModel ( source == 33 ) ) then        -- Ahora revisa si es nemesis el ped que es atacado. 
            setElementData ( source, getElementData(source, "blood") - 6000) 
            if ( getElementData( source, "blood") < 1 ) then    -- Al mismo tiempo comprueba si le queda poca vida para asi destruir al ped. 
                triggerServerEvent ( "getBloodBoss", root ) 
            end 
        end 
    end 
end 
addEventHandler ( "onClientPedDamage", root, getBloodBoss ) 

  • 4 weeks later...
Posted

Gracias por el aporte Razor, lo probé pero no funciona, sigue con el mismo bug del "clon en el piso" , tambièn intenté usando el ejemplo de Gabriel y tampoco, este script me está volviendo loco hace tiempo y sigo sin solucionarlo T.T ya revisé cada pieza del script pero no encuentro ninguna falla, debería de morir como un ped normal pero no lo hace y no tengo errores en el debug :S

  • Recently Browsing   0 members

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