فاّرس Posted July 17, 2016 Posted July 17, 2016 There's many errors, line 40 replace it with : local iron = getElementData(player, "iron") or 0 and line 47 oil isn't defined, line 53 replace it with : setTimer ( createMysteryBag, 5000, 1) try now, and tell me what shows in /debugscript 3.
DonOmar Posted July 17, 2016 Author Posted July 17, 2016 OMG bro u didnt understand i mean if i had gone to take the bag i will get the stuff but the blip won't be destroyed and the bag won't spawn in another place
فاّرس Posted July 17, 2016 Posted July 17, 2016 That's what i said, try this : local spawnLocation = { {1954.70984, -1717.59546, 15.96875}, {861.59393, -1284.14832, 14.05591}, {-2037.42590, -2350.11719, 40.89063}, {-2305.93457, 150.06975, 35.31250}, {-1543.31372, 698.40350, 139.27344}, } 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 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) bagBlip = createBlipAttachedTo(bag, 37) exports.CORtexts:output("A Mystery Bag has appeared at "..area..", "..city..", go and get it!", getRootElement(), 0, 255, 0) end addEventHandler("onResourceStart", resourceRoot, 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(5, 15) randomArmour = math.random(5, 20) randomGun = math.random(22, 34) randomAmmo = math.random(100, 500) local iron = getElementData(player, "iron") or 0 local oil = getElementData(player, "oil") or 0 local randomiron = math.random(20, 100) local randomoil = math.random(20, 200) local randomoil = math.random(50, 300) exports.CORtexts:output("You have found $"..tostring(randomCash)..", "..tostring(randomArmour).."% Armour, "..tostring(randomHP).."% Health and a "..getWeaponNameFromID(randomGun).." with "..tostring(randomAmmo).." Ammo! "..tostring(randomiron).." iron "..tostring(randomoil).." oil!", player, 0, 255, 0) givePlayerMoney(player, randomCash) setElementData(player, "iron", iron+randomiron) setElementData(player, "oil", oil+randomoil) setPedArmor(player, getPedArmor(player) + randomArmour) setElementHealth(player, getElementHealth(player) + randomHP) giveWeapon(player, randomGun, randomAmmo) destroyElement( bag ) destroyElement(bagBlip) setTimer ( createMysteryBag, 5000, 1) end end end )
فاّرس Posted July 17, 2016 Posted July 17, 2016 When you get a bag wait 5000 milliseconds and see, tell me what shows in /debugscript 3 ?
DonOmar Posted July 17, 2016 Author Posted July 17, 2016 already Bag cant be spawned if i started the script and got this bug ERROR: Loading script failed: CIFmbag/mbag.slua:64:'eof>' excepted near 'end'
DonOmar Posted July 17, 2016 Author Posted July 17, 2016 np dude i fixed it by my self and ty for your code.
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