ali Posted April 18, 2014 Share Posted April 18, 2014 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
ali Posted April 18, 2014 Author Share Posted April 18, 2014 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 Link to comment
tosfera Posted April 18, 2014 Share Posted April 18, 2014 If you want to replace the random pickup once in a time, use a timer. If that's what you mean... Link to comment
Moderators Citizen Posted April 18, 2014 Moderators Share Posted April 18, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now