Jump to content

need some help in this


ali

Recommended Posts

table1 =    { 
                {-2124.66235, -1957.51196, 242.68094}, 
                {-2432.49658, -1620.10706, 526.82495}, 
                {-2297.62671, -1110.15125, 96.6019}, 
            } 
             
 randomX, randomY, randomZ = unpack(table1[math.random(#table1)]) 
             pickup3 = createPickup (randomX, randomY, randomZ,3,1279) 
blip1 = createBlipAttachedTo(pickup3,37,0,0,0,0,255,0,99999.0, teamClimb) 
  

then when this pickup is clicked then

destroyElement(pickup3) 
destroyElement(blip1) 

then one a marker is hit and once again

 pickup3 = createPickup(randomX, randomY, randomZ,3,1279) 
 blip1 = createBlipAttachedTo(pickup3,37,0) 

but then i want the cycle to continue but it doesnt

Link to comment
  • Moderators
Ps: i have already done the things like "when this pick up is hit" etc what i want is how to make the cycle repeat

Just by using functions of course:

table1 = { 
    {-2124.66235, -1957.51196, 242.68094}, 
    {-2432.49658, -1620.10706, 526.82495}, 
    {-2297.62671, -1110.15125, 96.6019} 
} 
  
function spawnRandomPickup() 
    local randomX, randomY, randomZ = unpack(table1[math.random(#table1)]) 
    local pickup = createPickup (randomX, randomY, randomZ,3,1279) 
    local blip = createBlipAttachedTo(pickup,37,0,0,0,0,255,0,99999.0, teamClimb) 
    setElementData(pickup, "blip", blip) 
    addEventHandler("onPickupHit", pickup, randomPickupHitted) 
end 
  
function randomPickupHitted() 
    local blip = getElementData(source, "blip") --try to get the blip 
    if blip then --if we got it 
        destroyElement(blip) --delete the blip 
    end 
    destroyElement(source) --delete the pickup (maybe this line is enough to delete the pickup AND the blip) 
  
    local marker = createMarker(0, 0, 1) --marker to spawn another random pickup 
    addEventHandler("onMarkerHit", marker, spawnRandomPickup) --when hitted, execute spawnRandomPickup again 
end 
  
--adding a command to let you try it: (it will start the cycle you wanted) 
addCommandHandler("startcycle", spawnRandomPickup, false, false) 

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