Slammer Posted August 24, 2013 Share Posted August 24, 2013 How to make this script give you random ammo? -- You can add more locations -- {x, y, z} local mbag = { {2422.3,-2261.6,16}, {1758.9,-2767.9,1.7}, {2493.3,-951.8,82.25}, {815.7,-1108.2,25.8}, {390.9,-2054.3,13.8}, {-719.05,-1938.8,8.35}, {-625.7,-2249.5,23.05}, {-1812.3,-168.5,18.2}, {-2659.5,1528.05,54.79}, {-1733.76,194.75,3.6}, {-2535.5,40.15,8.5}, {-1804.85,558.45,35.15}, {-752.6,-131.6,65.8}, } function createBag() local random = math.random ( #mbag ) local x, y, z = mbag[random][1], mbag[random][2], mbag[random][3] bag = createPickup( x, y, z, 3, 1550 ) setElementCollisionsEnabled( bag, false ) bl = createBlipAttachedTo(bag,37) outputChatBox( "A Mystery Bag has Spawned get it First", root, 0, 255, 0 ) end addEventHandler("onResourceStart", resourceRoot,createBag) addEventHandler("onPickupHit",root, function ( player ) if ( source ~= bag ) then return end if ( isPedInVehicle( player ) ) then return end destroyElement( bag ) destroyElement( bl ) randomMoney = math.random ( 10000, 100000 ) randomArmor = math.random( 100, 100 ) givePlayerMoney(player,randomMoney) setPedArmor ( player, getPedArmor(player) + randomArmor ) outputChatBox("You find $" .. tostring(randomMoney) .." and ".. tostring(randomArmor) .."% Armor", player, 0, 250, 0) setTimer( createBag, 90000, 1 ) end ) Link to comment
xXMADEXx Posted August 24, 2013 Share Posted August 24, 2013 Try this: -- You can add more locations -- {x, y, z} local mbag = { {2422.3,-2261.6,16}, {1758.9,-2767.9,1.7}, {2493.3,-951.8,82.25}, {815.7,-1108.2,25.8}, {390.9,-2054.3,13.8}, {-719.05,-1938.8,8.35}, {-625.7,-2249.5,23.05}, {-1812.3,-168.5,18.2}, {-2659.5,1528.05,54.79}, {-1733.76,194.75,3.6}, {-2535.5,40.15,8.5}, {-1804.85,558.45,35.15}, {-752.6,-131.6,65.8}, } function createBag() local random = math.random ( #mbag ) local x, y, z = mbag[random][1], mbag[random][2], mbag[random][3] bag = createPickup( x, y, z, 3, 1550 ) setElementCollisionsEnabled( bag, false ) bl = createBlipAttachedTo(bag,37) outputChatBox( "A Mystery Bag has Spawned get it First", root, 0, 255, 0 ) end addEventHandler("onResourceStart", resourceRoot,createBag) addEventHandler("onPickupHit",root, function ( player ) if ( source ~= bag ) then return end if ( isPedInVehicle( player ) ) then return end destroyElement( bag ) destroyElement( bl ) local randomMoney = math.random ( 10000, 100000 ) local randomArmor = math.random( 100, 100 ) local ammo = math.random ( 100, 150 ) givePlayerMoney(player,randomMoney) setPedArmor ( player, getPedArmor(player) + randomArmor ) giveWeapon ( player, 27, ammo ) outputChatBox("You found $" .. tostring(randomMoney) ..", ".. tostring(randomArmor) .."% Armor, and "..tostring ( ammo ).." Shotgun Ammo!", player, 0, 250, 0) setTimer( createBag, 90000, 1 ) end ) Link to comment
Slammer Posted August 24, 2013 Author Share Posted August 24, 2013 Thanks very much worked perfectly 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