Jump to content

[HELP]Delay something


Recommended Posts

Well, im trying to make, when you stay in a marker for 2 minutes, the timer called timer gives to you "drugs",

and when you stay in the marker along two minutes does not give the drug

    function SpawnPicks ( ) 
        if ( not marker ) then 
            marker = createMarker ( -1438.2526855469, 1490.6701660156, 1.8671875-0.5, "cylinder", 1.5, 255, 255, 0, 170  ) 
            addEventHandler ( "onMarkerHit", Marker, onMarkerHit ) 
            addEventHandler( "onMarkerLeave", Marker, markerLeave ) 
            outputChatBox("#FF0000[ALERTA]#FFFFFFTraficantes avistados en "..getElementZoneName(marker).."",root, 0,0,0, true) 
            blip = createBlipAttachedTo ( marker, 19 ) 
            --Bots load 
            bot1 = exports [ "slothbot" ]:spawnBot (-1451.6501464844, 1498.3551025391, 11.8046875, 0, 28, 0, 0, teamLV, 29, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot1, teamLV) 
             
            bot2 = exports [ "slothbot" ]:spawnBot (-1454.3022460938, 1485.8472900391, 11.8046875, 0, 43, 0, 0, teamLV, 31, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot2, teamLV) 
             
            bot3 = exports [ "slothbot" ]:spawnBot (-1460.1511230469, 1498.7517089844, 8.2578125, 0, 73, 0, 0, teamLV, 31, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot3, teamLV) 
             
            bot4 = exports [ "slothbot" ]:spawnBot ( -1447.7530517578, 1490.2437744141, 7.1015625, 0, 100, 0, 0, teamLV, 4, "waiting", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot4, teamLV) 
             
            bot5 = exports [ "slothbot" ]:spawnBot ( -1400.6428222656, 1488.1295166016, 7.1015625, 0, 102, 0, 0, teamLV, 27, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot5, teamLV) 
             
            bot6 = exports [ "slothbot" ]:spawnBot ( -1399.9071044922, 1489.8024902344, 7.1015625, 0, 103, 0, 0, teamLV, 31, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot6, teamLV) 
             
            bot7 = exports [ "slothbot" ]:spawnBot (  -1399.6480712891, 1492.4254150391, 7.1015625, 0, 104, 0, 0, teamLV, 27, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot7, teamLV) 
                 
            bot8 = exports [ "slothbot" ]:spawnBot ( -1385.8913574219, 1489.462890625, 13.84375, 0, 28, 0, 0, teamLV, 31, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot8, teamLV)    
             
            bot9 = exports [ "slothbot" ]:spawnBot ( -1375.5046386719, 1488.4661865234, 11.203125, 0, 29, 0, 0, teamLV, 4, "waiting", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot9, teamLV)    
             
            bot10 = exports [ "slothbot" ]:spawnBot ( -1383.7861328125, 1494.6298828125, 8.90625, 0, 102, 0, 0, teamLV, 27, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot10, teamLV) 
              
            bot11 = exports [ "slothbot" ]:spawnBot ( -1370.4478759766, 1494.6135253906, 1.8515625, 0, 100, 0, 0, teamLV, 27, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot11, teamLV) 
             
            bot12 = exports [ "slothbot" ]:spawnBot ( -1372.8487548828, 1495.0855712891, 1.8515625, 0, 103, 0, 0, teamLV, 22, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot12, teamLV) 
             
            bot13 = exports [ "slothbot" ]:spawnBot ( -1399.1472167969, 1496.5262451172, 1.8671875, 0, 104, 0, 0, teamLV, 27, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot13, teamLV) 
             
            bot14 = exports [ "slothbot" ]:spawnBot ( -1398.8568115234, 1483.0720214844, 1.8671875, 0, 28, 0, 0, teamLV, 31, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot14, teamLV) 
             
            bot15 = exports [ "slothbot" ]:spawnBot ( -1391.5030517578, 1485.5445556641, 1.8671875, 0, 29, 0, 0, teamLV, 9, "waiting", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot15, teamLV) 
             
            bot16 = exports [ "slothbot" ]:spawnBot ( -1422.9012451172, 1492.8765869141, 1.8671875, 0, 100, 0, 0, teamLV, 9, "waiting", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot16, teamLV) 
             
            bot17 = exports [ "slothbot" ]:spawnBot ( -1436.3575439453, 1493.6381835938, 1.8671875, 0, 33, 0, 0, teamLV, 9, "waiting", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot17, teamLV) 
              
               
        end 
    end 
    addEventHandler ( "onResourceStart", resourceRoot, SpawnPicks ) 
    setTimer ( SpawnPicks, 1200000, 0 ) 
     
    function onMarkerHit (player) 
         if ( not isTimer(timer) ) then 
--Here 
           timer = setTimer ( function() 
                local acc = getPlayerAccount ( player )  
                outputChatBox(getPlayerName(player).." Ha robado la droga!") 
                setElementData(player,"Weed",getElementData(player,"Weed")+math.random(1,30)) 
                setAccountData(acc,"Weed",getElementData(player,"Weed")) 
                setElementData(player,"God",getElementData(player,"God")+math.random(1,30)) 
                setAccountData(acc,"God",getElementData(player,"God")) 
                setElementData(player,"Speed",getElementData(player,"Speed")+math.random(1,30)) 
                setAccountData(acc,"Speed",getElementData(player,"Speed")) 
                setElementData(player,"Lsd",getElementData(player,"Lsd")+math.random(1,30)) 
                setAccountData(acc,"Lsd",getElementData(player,"Lsd")) 
                setElementData(player,"Steroids",getElementData(player,"Steroids")+math.random(1,30)) 
                setAccountData(acc,"Steroids",getElementData(player,"Steroids")) 
                setElementData(player,"Heroin",getElementData(player,"Heroin")+math.random(1,30)) 
                setAccountData(acc,"Heroin",getElementData(player,"Heroin")) 
                destroyElement(bot1)  
                destroyElement(bot2)  
                destroyElement(bot3)  
                destroyElement(bot4)  
                destroyElement(bot5)  
                destroyElement(bot6)  
                destroyElement(bot7)  
                destroyElement(bot8)  
                destroyElement(bot9)  
                destroyElement(bot10)  
                destroyElement(bot11)  
                destroyElement(bot12)  
                destroyElement(bot13)  
                destroyElement(bot14)  
                destroyElement(bot15)  
                destroyElement(bot16)  
                destroyElement(bot17)  
              
  
                end, 120000, 1) 
            
  
            
            
            
            
            
  
            
            killTimer(timer) 
            destroyElement ( marker ) 
            destroyElement ( blip ) 
      
        pickup = nil 
  
    end 
    end 
     
function markerLeave( ) 
        if isTimer( timer ) then  
        killTimer (timer) 
        end 
end 
  

Edited by Guest
Link to comment
Well, that's obvious, you are killing the timer (line 113) just after you set it.

Doesnt work bro see

function onMarkerHit (player) 
     if ( not isTimer (timer) ) then 
           timer = setTimer ( function() 
                local acc = getPlayerAccount ( player )  
                outputChatBox(getPlayerName(player).." Ha robado la droga!") 
                setElementData(player,"Weed",getElementData(player,"Weed")+math.random(1,30)) 
                setAccountData(acc,"Weed",getElementData(player,"Weed")) 
                setElementData(player,"God",getElementData(player,"God")+math.random(1,30)) 
                setAccountData(acc,"God",getElementData(player,"God")) 
                setElementData(player,"Speed",getElementData(player,"Speed")+math.random(1,30)) 
                setAccountData(acc,"Speed",getElementData(player,"Speed")) 
                setElementData(player,"Lsd",getElementData(player,"Lsd")+math.random(1,30)) 
                setAccountData(acc,"Lsd",getElementData(player,"Lsd")) 
                setElementData(player,"Steroids",getElementData(player,"Steroids")+math.random(1,30)) 
                setAccountData(acc,"Steroids",getElementData(player,"Steroids")) 
                setElementData(player,"Heroin",getElementData(player,"Heroin")+math.random(1,30)) 
                setAccountData(acc,"Heroin",getElementData(player,"Heroin")) 
                destroyElement(bot1)  
                destroyElement(bot2)  
                destroyElement(bot3)  
                destroyElement(bot4)  
                destroyElement(bot5)  
                destroyElement(bot6)  
                destroyElement(bot7)  
                destroyElement(bot8)  
                destroyElement(bot9)  
                destroyElement(bot10)  
                destroyElement(bot11)  
                destroyElement(bot12)  
                destroyElement(bot13)  
                destroyElement(bot14)  
                destroyElement(bot15)  
                destroyElement(bot16)  
                destroyElement(bot17)  
  
  
                end, 5000, 1) 
            
end 
            
            
            
            
            
  
            
            destroyElement ( marker ) 
            destroyElement ( blip ) 
      
        marker = nil 
  
end 

Link to comment
function onMarkerHit (player) 
     if ( not isTimer (timer) ) then 
           timer = setTimer ( function(player) 
                local acc = getPlayerAccount ( player )  
                outputChatBox(getPlayerName(player).." Ha robado la droga!") 
                setElementData(player,"Weed",getElementData(player,"Weed")+math.random(1,30)) 
                setAccountData(acc,"Weed",getElementData(player,"Weed")) 
                setElementData(player,"God",getElementData(player,"God")+math.random(1,30)) 
                setAccountData(acc,"God",getElementData(player,"God")) 
                setElementData(player,"Speed",getElementData(player,"Speed")+math.random(1,30)) 
                setAccountData(acc,"Speed",getElementData(player,"Speed")) 
                setElementData(player,"Lsd",getElementData(player,"Lsd")+math.random(1,30)) 
                setAccountData(acc,"Lsd",getElementData(player,"Lsd")) 
                setElementData(player,"Steroids",getElementData(player,"Steroids")+math.random(1,30)) 
                setAccountData(acc,"Steroids",getElementData(player,"Steroids")) 
                setElementData(player,"Heroin",getElementData(player,"Heroin")+math.random(1,30)) 
                setAccountData(acc,"Heroin",getElementData(player,"Heroin")) 
                destroyElement(bot1) 
                destroyElement(bot2) 
                destroyElement(bot3) 
                destroyElement(bot4) 
                destroyElement(bot5) 
                destroyElement(bot6) 
                destroyElement(bot7) 
                destroyElement(bot8) 
                destroyElement(bot9) 
                destroyElement(bot10) 
                destroyElement(bot11) 
                destroyElement(bot12) 
                destroyElement(bot13) 
                destroyElement(bot14) 
                destroyElement(bot15) 
                destroyElement(bot16) 
                destroyElement(bot17) 
  
  
                end, 5000, 1, player) 
            
end 
            
            
            
            
            
  
            
            destroyElement ( marker ) 
            destroyElement ( blip ) 
      
        marker = nil 
  
end 

Try that.

Link to comment
function onMarkerHit (player) 
     if ( not isTimer (timer) ) then 
           timer = setTimer ( function(player) 
                local acc = getPlayerAccount ( player )  
                outputChatBox(getPlayerName(player).." Ha robado la droga!") 
                setElementData(player,"Weed",getElementData(player,"Weed")+math.random(1,30)) 
                setAccountData(acc,"Weed",getElementData(player,"Weed")) 
                setElementData(player,"God",getElementData(player,"God")+math.random(1,30)) 
                setAccountData(acc,"God",getElementData(player,"God")) 
                setElementData(player,"Speed",getElementData(player,"Speed")+math.random(1,30)) 
                setAccountData(acc,"Speed",getElementData(player,"Speed")) 
                setElementData(player,"Lsd",getElementData(player,"Lsd")+math.random(1,30)) 
                setAccountData(acc,"Lsd",getElementData(player,"Lsd")) 
                setElementData(player,"Steroids",getElementData(player,"Steroids")+math.random(1,30)) 
                setAccountData(acc,"Steroids",getElementData(player,"Steroids")) 
                setElementData(player,"Heroin",getElementData(player,"Heroin")+math.random(1,30)) 
                setAccountData(acc,"Heroin",getElementData(player,"Heroin")) 
                destroyElement(bot1) 
                destroyElement(bot2) 
                destroyElement(bot3) 
                destroyElement(bot4) 
                destroyElement(bot5) 
                destroyElement(bot6) 
                destroyElement(bot7) 
                destroyElement(bot8) 
                destroyElement(bot9) 
                destroyElement(bot10) 
                destroyElement(bot11) 
                destroyElement(bot12) 
                destroyElement(bot13) 
                destroyElement(bot14) 
                destroyElement(bot15) 
                destroyElement(bot16) 
                destroyElement(bot17) 
  
  
                end, 5000, 1, player) 
            
end 
            
            
            
            
            
  
            
            destroyElement ( marker ) 
            destroyElement ( blip ) 
      
        marker = nil 
  
end 

Try that.

Doesnt work bro 0_o

Link to comment
Post the code you are currently using.
function SpawnPicks ( ) 
        if ( not Marker ) then 
            Marker = createMarker ( -1438.2526855469, 1490.6701660156, 1.8671875-0.5, "cylinder", 1.5, 255, 255, 0, 170  ) 
            addEventHandler ( "onMarkerHit", Marker, onMarkerHit ) 
            addEventHandler( "onMarkerLeave", Marker, markerLeave ) 
            outputChatBox("#FF0000[ALERTA]#FFFFFFTraficantes avistados en "..getElementZoneName(Marker).."",root, 0,0,0, true) 
            blip = createBlipAttachedTo ( Marker, 19 ) 
            --Bots load 
            bot1 = exports [ "slothbot" ]:spawnBot (-1451.6501464844, 1498.3551025391, 11.8046875, 0, 28, 0, 0, teamLV, 29, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot1, teamLV) 
            
            bot2 = exports [ "slothbot" ]:spawnBot (-1454.3022460938, 1485.8472900391, 11.8046875, 0, 43, 0, 0, teamLV, 31, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot2, teamLV) 
            
            bot3 = exports [ "slothbot" ]:spawnBot (-1460.1511230469, 1498.7517089844, 8.2578125, 0, 73, 0, 0, teamLV, 31, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot3, teamLV) 
            
            bot4 = exports [ "slothbot" ]:spawnBot ( -1447.7530517578, 1490.2437744141, 7.1015625, 0, 100, 0, 0, teamLV, 4, "waiting", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot4, teamLV) 
            
            bot5 = exports [ "slothbot" ]:spawnBot ( -1400.6428222656, 1488.1295166016, 7.1015625, 0, 102, 0, 0, teamLV, 27, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot5, teamLV) 
            
            bot6 = exports [ "slothbot" ]:spawnBot ( -1399.9071044922, 1489.8024902344, 7.1015625, 0, 103, 0, 0, teamLV, 31, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot6, teamLV) 
            
            bot7 = exports [ "slothbot" ]:spawnBot (  -1399.6480712891, 1492.4254150391, 7.1015625, 0, 104, 0, 0, teamLV, 27, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot7, teamLV) 
                
            bot8 = exports [ "slothbot" ]:spawnBot ( -1385.8913574219, 1489.462890625, 13.84375, 0, 28, 0, 0, teamLV, 31, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot8, teamLV)    
            
            bot9 = exports [ "slothbot" ]:spawnBot ( -1375.5046386719, 1488.4661865234, 11.203125, 0, 29, 0, 0, teamLV, 4, "waiting", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot9, teamLV)    
            
            bot10 = exports [ "slothbot" ]:spawnBot ( -1383.7861328125, 1494.6298828125, 8.90625, 0, 102, 0, 0, teamLV, 27, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot10, teamLV) 
              
            bot11 = exports [ "slothbot" ]:spawnBot ( -1370.4478759766, 1494.6135253906, 1.8515625, 0, 100, 0, 0, teamLV, 27, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot11, teamLV) 
            
            bot12 = exports [ "slothbot" ]:spawnBot ( -1372.8487548828, 1495.0855712891, 1.8515625, 0, 103, 0, 0, teamLV, 22, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot12, teamLV) 
            
            bot13 = exports [ "slothbot" ]:spawnBot ( -1399.1472167969, 1496.5262451172, 1.8671875, 0, 104, 0, 0, teamLV, 27, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot13, teamLV) 
            
            bot14 = exports [ "slothbot" ]:spawnBot ( -1398.8568115234, 1483.0720214844, 1.8671875, 0, 28, 0, 0, teamLV, 31, "guarding", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot14, teamLV) 
            
            bot15 = exports [ "slothbot" ]:spawnBot ( -1391.5030517578, 1485.5445556641, 1.8671875, 0, 29, 0, 0, teamLV, 9, "waiting", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot15, teamLV) 
            
            bot16 = exports [ "slothbot" ]:spawnBot ( -1422.9012451172, 1492.8765869141, 1.8671875, 0, 100, 0, 0, teamLV, 9, "waiting", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot16, teamLV) 
            
            bot17 = exports [ "slothbot" ]:spawnBot ( -1436.3575439453, 1493.6381835938, 1.8671875, 0, 33, 0, 0, teamLV, 9, "waiting", true ) 
            exports [ "slothbot" ]:setBotTeam ( bot17, teamLV) 
              
              
        end 
    end 
    addEventHandler ( "onResourceStart", resourceRoot, SpawnPicks ) 
    setTimer ( SpawnPicks, 1200000, 0 ) 
    
    function onMarkerHit (player) 
         if ( not isTimer (timer) ) then 
               timer = setTimer ( function(player) 
                    local acc = getPlayerAccount ( player ) 
                    outputChatBox(getPlayerName(player).." Ha robado la droga!") 
                    setElementData(player,"Weed",getElementData(player,"Weed")+math.random(1,30)) 
                    setAccountData(acc,"Weed",getElementData(player,"Weed")) 
                    setElementData(player,"God",getElementData(player,"God")+math.random(1,30)) 
                    setAccountData(acc,"God",getElementData(player,"God")) 
                    setElementData(player,"Speed",getElementData(player,"Speed")+math.random(1,30)) 
                    setAccountData(acc,"Speed",getElementData(player,"Speed")) 
                    setElementData(player,"Lsd",getElementData(player,"Lsd")+math.random(1,30)) 
                    setAccountData(acc,"Lsd",getElementData(player,"Lsd")) 
                    setElementData(player,"Steroids",getElementData(player,"Steroids")+math.random(1,30)) 
                    setAccountData(acc,"Steroids",getElementData(player,"Steroids")) 
                    setElementData(player,"Heroin",getElementData(player,"Heroin")+math.random(1,30)) 
                    setAccountData(acc,"Heroin",getElementData(player,"Heroin")) 
                    destroyElement(bot1) 
                    destroyElement(bot2) 
                    destroyElement(bot3) 
                    destroyElement(bot4) 
                    destroyElement(bot5) 
                    destroyElement(bot6) 
                    destroyElement(bot7) 
                    destroyElement(bot8) 
                    destroyElement(bot9) 
                    destroyElement(bot10) 
                    destroyElement(bot11) 
                    destroyElement(bot12) 
                    destroyElement(bot13) 
                    destroyElement(bot14) 
                    destroyElement(bot15) 
                    destroyElement(bot16) 
                    destroyElement(bot17) 
                 destroyElement ( Marker ) 
                destroyElement ( blip ) 
          
            marker = nil 
      
      
      
                    end, 12000, 1, player) 
                
    end 
                
                
                
                
                
    end 
    
function markerLeave( ) 
        if isTimer( timer ) then 
        killTimer (timer) 
        end 
end 

Link to comment

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