Jump to content

Nothin'


DarkByte

Recommended Posts

Posted (edited)

*Cut;)*

Edited by Guest

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted
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) 

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted (edited)

*Cut ;)*

Edited by Guest

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

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

Posted

Thanks, works :D

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

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