Jump to content

set timer killtimer


manawydan

Recommended Posts

Posted

how to stop the timer, if the health of nemesis = nill?

thanks for your time.

server--

function Nemesisbymanawydan ( )   
       baz = createObject ( 360, -1935.5480957031, 665.44055175781, 48, 0, 0, 0 ) 
       nemesi = exports [ "slothBot" ]:spawnBot ( -1935.5480957031, 665.44055175781, 47.0, 90,  math.random ( 300, 303 ), 0, 0, Nemesis, 38,         "hunting", true ) 
      setElementModel ( nemesi, 107 ) 
      outputChatBox ("#9E0000Nemesis: #0D9905STARS",getRootElement(), 255, 255, 255, true ) 
      local myBlip = (createBlipAttachedTo ( nemesi, 0 )) 
      attachElements ( baz, nemesi, 0.2, 0.1, 0.5, 0, 90, 0 ) 
      triggerClientEvent ( "nsound", root )     
      triggerClientEvent ( "nemesismissel", root ) 
      setTimer( 
      function() 
      setElementHealth ( nemesi, 200 ) 
      end, 1100, 0) 
 end 
addEventHandler("onResourceStart", resourceRoot, Nemesisbymanawydan)    
  
addEvent("onBotWasted",true) 
addEventHandler("onBotWasted",getRootElement(), 
function (killer) 
if (source == nemesi) then 
givePlayerMoney(killer,math.random(4000,6000)) -- 4000, 6000 money for kill nemesis-- 
outputChatBox ( getPlayerName ( killer ) .. " #081DBFkilled Nemesis, congratulations",getRootElement(), 255, 255, 255, true ) 
setTimer(Nemesisbymanawydan, 1000, 1) -- 60000 time for nemesis respawn in milliseconds-- 
end 
end) 

client--

--- Criado por MANAWYDANbr --- 
function Skinemesis1()  
  txd = engineLoadTXD("data/107.txd", 107 ) 
  engineImportTXD(txd, 107) 
  dff = engineLoadDFF("data/107.dff", 107 ) 
  engineReplaceModel(dff, 107) 
end  
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), Skinemesis1) 
  
  
addEvent ( "nsound", true ) 
addEventHandler ( "nsound", root, 
    function ( ) 
        playSound ( "data/nemesis.mp3" ) 
    end 
) 
  
  
  
addEvent ( "nemesismissel", true ) 
addEventHandler ( "nemesismissel", root, 
    function ( ) 
        x, y, z = getElementPosition("nemesi") 
createProjectile(getLocalPlayer(), 19, x, y, z) 
setPedAnimation ( nemesi, "ROCKET", "RocketFire") 
    end 
) 
  

560x95_FFFFFF_09FF00_050505_000000.png

"Querer não é poder, mas tentar é avançar"!

Posted

server.lua

function Nemesisbymanawydan ( )   
       baz = createObject ( 360, -1935.5480957031, 665.44055175781, 48, 0, 0, 0 ) 
       nemesi = exports [ "slothBot" ]:spawnBot ( -1935.5480957031, 665.44055175781, 47.0, 90,  math.random ( 300, 303 ), 0, 0, Nemesis, 38,         "hunting", true ) 
      setElementModel ( nemesi, 107 ) 
      outputChatBox ("#9E0000Nemesis: #0D9905STARS",getRootElement(), 255, 255, 255, true ) 
      local myBlip = (createBlipAttachedTo ( nemesi, 0 )) 
      attachElements ( baz, nemesi, 0.2, 0.1, 0.5, 0, 90, 0 ) 
      triggerClientEvent ( "nsound", root )     
      triggerClientEvent ( "nemesismissel", root ) 
      healthStop = setTimer( 
      function() 
      setElementHealth ( nemesi, 200 ) 
      end, 1100, 0) 
  
      if ( getElementHealth( nemesis ) == 0 ) and ( isTimer(healthStop) ) then 
      killTimer( healthStop ) 
      end 
 end 
addEventHandler("onResourceStart", resourceRoot, Nemesisbymanawydan)   
  
addEvent("onBotWasted",true) 
addEventHandler("onBotWasted",getRootElement(), 
function (killer) 
if (source == nemesi) then 
givePlayerMoney(killer,math.random(4000,6000)) -- 4000, 6000 money for kill nemesis-- 
outputChatBox ( getPlayerName ( killer ) .. " #081DBFkilled Nemesis, congratulations",getRootElement(), 255, 255, 255, true ) 
setTimer(Nemesisbymanawydan, 1000, 1) -- 60000 time for nemesis respawn in milliseconds-- 
end 
end) 

try

Looking for tutorials or information? check out: www.simpleask.co.uk

Posted

The bot won't have 0 of health when he's created.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Kill the timer at the event "onBotWasted".

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

manve1

worked, but has a bad argument. lua:15: Bad argument 'getElementHealth' [Expected alement at argument 1, got nil]

560x95_FFFFFF_09FF00_050505_000000.png

"Querer não é poder, mas tentar é avançar"!

Posted

Because he placed 'nemesis' instead 'nemesi' in the getElementHealth function.

Please do not PM me with scripting related question nor support, use the forums instead.

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...