Jump to content

[ Help ] destroyElement and respawn


Cocodrilo

Recommended Posts

Hi everyone, i got a little problem .. i will be very grateful if you show me a way to solve it :cry:

I want to do two things:

1.- onClientMarkerHit - destroy: 'neumatico' and 'neumaticoMarker' i had hit

i use destroyElement but it only destroys the marker. So, how to destroy the pickup too?

2.- I want to respawn 'neumatico' and 'neumaticoMarker' every 20 seconds if these elements are not.

I tried to add setTimer function but doesn't worked.

  
llantas = { 
  
 {1665.1064453125, -2113.4404296875, 13.546875,0,0} 
  
} 
  
addEventHandler ("onClientResourceStart",getResourceRootElement(getThisResource()), 
function iniciar() 
  
  for i,v in ipairs (llantas) do 
    local neumatico = createPickup (v[1],v[2],v[3],3,2768,100)   
    local neumaticoMarker = createMarker (v[1],v[2],v[3],"corona",1,143,143,17,80) 
     
    setElementData (neumaticoMarker,"Neumatico!!", true) 
    setElementInterior (neumaticoMarker,v[4]) 
    setElementInterior (neumatico,v[4]) 
    setElementDimension(neumatico,tonumber(v[5])) 
    setElementDimension(neumaticoMarker,tonumber(v[5])) 
   end 
end) 
  
addEventHandler ("onClientMarkerHit",getRootElement(), 
function(hitEle,dim) 
  if (getLocalPlayer() == hitEle) and (getElementData (source,"Neumatico!!") == true) and (dim) then 
     triggerServerEvent("addAcountNeumatico",getLocalPlayer(),getLocalPlayer(),1) 
      outputChatBox ("+ 1 Neumático",0,255,0,false)    
       --destroyElement(source)      
    end 
  end 
) 
  
  

Link to comment
  
llantas = { 
  
 {1665.1064453125, -2113.4404296875, 13.546875,0,0} 
  
} 
  
addEventHandler ("onClientResourceStart",getResourceRootElement(getThisResource()), 
function() 
  
  for i,v in ipairs (llantas) do 
    neumatico = createPickup (v[1],v[2],v[3],3,2768,100)  
    neumaticoMarker = createMarker (v[1],v[2],v[3],"corona",1,143,143,17,80) 
    
    setElementData (neumaticoMarker,"Neumatico!!", true) 
    setElementInterior (neumaticoMarker,v[4]) 
    setElementInterior (neumatico,v[4]) 
    setElementDimension(neumatico,v[5]) 
    setElementDimension(neumaticoMarker,v[5]) 
   end 
end) 
  
addEventHandler ("onClientMarkerHit",getRootElement(), 
function(hitEle,dim) 
    if (getLocalPlayer() == hitEle) and (getElementData (source,"Neumatico!!") == true) and (dim) then 
        triggerServerEvent("addAcountNeumatico",getLocalPlayer(),getLocalPlayer(),1) 
        outputChatBox ("+ 1 Neumático",0,255,0)   
        destroyElement(source) 
        destroyElement(neumatico) 
        setTimer( function() 
            for i,v in ipairs (llantas) do 
                neumatico = createPickup (v[1],v[2],v[3],3,2768,100)  
                neumaticoMarker = createMarker (v[1],v[2],v[3],"corona",1,143,143,17,80) 
            end 
        end, 20000, 1 ) 
    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...