DarkByte Posted August 10, 2016 Share Posted August 10, 2016 (edited) *Cut;)* Edited August 11, 2016 by Guest Link to comment
DarkByte Posted August 10, 2016 Author Share Posted August 10, 2016 local spawnLocation = { {1963.396, -1724.033, 15.969}, } last_i = 0 function createMysteryBag () local i = math.random ( #spawnLocation ) if ( i == last_i ) then while ( i == last_i ) do i = math.random ( #spawnLocation ) end end local x,y,z = getElementPosition(source) local locData = spawnLocation[i] local area = getZoneName(locData[1], locData[2], locData[3]) local city = getZoneName(locData[1], locData[2], locData[3], true) bag = createPickup(locData[1], locData[2], locData[3], 3, 1550) -- local c = createColCuboid (locData[1], locData[2], locData[3], 40, 20, 100) local shape = createColSphere(locData[1],locData[2],locData[3],100) outputChatBox("A Mystery Bag has appeared at "..area..", "..city..", go and get it!", getRootElement(), 0, 255, 0) end addEventHandler("onResourceStart", resourceRoot, createMysteryBag) addCommandHandler("bag",createMysteryBag) addEventHandler("onPickupHit", root, function(player) if source == bag then if getElementType(player) == "player" then if isPedInVehicle(player) then return end randomCash = math.random(1000, 100000) randomHP = math.random(10, 50) randomArmour = math.random(5, 20) randomGun = math.random(22, 38) randomAmmo = math.random(100, 500) outputChatBox("You have found $"..tostring(randomCash)..", "..tostring(randomArmour).."% Armour, "..tostring(randomHP).."% Health and a "..getWeaponNameFromID(randomGun).." with "..tostring(randomAmmo).." Ammo!", player, 0, 255, 0) givePlayerMoney(player, randomCash) setPedArmor(player, getPedArmor(player) + randomArmour) setElementHealth(player, getElementHealth(player) + randomHP) giveWeapon(player, randomGun, randomAmmo) destroyElement( bag ) setTimer ( createMysteryBag, 10000, 1) destroyElement(shape) end end end ) function resetGreenzoneData() for _,p in ipairs (getElementsByType("player")) do if isElement(p) then removeElementData (p, "ticket") end end end addEventHandler ("onResourceStop", resourceRoot, resetGreenzoneData) Link to comment
DarkByte Posted August 10, 2016 Author Share Posted August 10, 2016 (edited) *Cut * Edited August 10, 2016 by Guest Link to comment
Captain Cody Posted August 10, 2016 Share Posted August 10, 2016 Remove the local from shape. Link to comment
EstrategiaGTA Posted August 10, 2016 Share Posted August 10, 2016 local spawnLocation = { {1963.396, -1724.033, 15.969}, } last_i = 0 function createMysteryBag () local i = math.random ( #spawnLocation ) if ( i == last_i ) then while ( i == last_i ) do i = math.random ( #spawnLocation ) end end local x,y,z = getElementPosition(source) local locData = spawnLocation[i] local area = getZoneName(locData[1], locData[2], locData[3]) local city = getZoneName(locData[1], locData[2], locData[3], true) bag = createPickup(locData[1], locData[2], locData[3], 3, 1550) -- local c = createColCuboid (locData[1], locData[2], locData[3], 40, 20, 100) shape = createColSphere(locData[1],locData[2],locData[3],100) outputChatBox("A Mystery Bag has appeared at "..area..", "..city..", go and get it!", getRootElement(), 0, 255, 0) end addEventHandler("onResourceStart", resourceRoot, createMysteryBag) addCommandHandler("bag",createMysteryBag) addEventHandler("onPickupHit", root, function(player) if source == bag then if getElementType(player) == "player" then if isPedInVehicle(player) then return end randomCash = math.random(1000, 100000) randomHP = math.random(10, 50) randomArmour = math.random(5, 20) randomGun = math.random(22, 38) randomAmmo = math.random(100, 500) outputChatBox("You have found $"..tostring(randomCash)..", "..tostring(randomArmour).."% Armour, "..tostring(randomHP).."% Health and a "..getWeaponNameFromID(randomGun).." with "..tostring(randomAmmo).." Ammo!", player, 0, 255, 0) givePlayerMoney(player, randomCash) setPedArmor(player, getPedArmor(player) + randomArmour) setElementHealth(player, getElementHealth(player) + randomHP) giveWeapon(player, randomGun, randomAmmo) destroyElement( bag ) setTimer ( createMysteryBag, 10000, 1) destroyElement(shape) end end end ) function resetGreenzoneData() for _,p in ipairs (getElementsByType("player")) do if isElement(p) then removeElementData (p, "ticket") end end end addEventHandler ("onResourceStop", resourceRoot, resetGreenzoneData) There you have. For your further scripts keep in mind that "local" only applies to your block code, so you should destroy that variable inside it. Else, just don't use "local". 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