• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[ACTION] Surprise Bag

180319

New Member
Joined
Oct 30, 2010
Messages
8
Reaction score
0
Well, i need a script like this:

TFS 0.3.6 - 8.6

When you use the item 6570 the player get a random number of these items:

ID: 6541 - number of items: 30~100
ID: 6542 - number of items: 30~100
ID: 6543 - number of items: 30~100
ID: 6544 - number of items: 30~100
ID: 6545 - number of items: 30~100

its not that hard but i tried on my own and the fucking script created a wall when i used it ;-;

sorry for my bad english :(
 
Last edited:
Code:
  backpack = {
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
  }
function onUse(cid, item, frompos, item2, topos)
        bp = doPlayerAddItem(cid, 10518, 1)
                for _, i in ipairs(backpack) do
          doAddContainerItem(bp, i.id, i.amount)
          doCreatureSay(cid, "Decorating Packdage!" ,19)
          doSendMagicEffect(getCreaturePosition(cid), 35)
        end
return doRemoveItem(item.uid)
end

Code:
<action itemid="xxxx" script="surprise.lua"/>
 
Code:
  backpack = {
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
   {id = xxxx, amount = 100},
  }
function onUse(cid, item, frompos, item2, topos)
        bp = doPlayerAddItem(cid, 10518, 1)
                for _, i in ipairs(backpack) do
          doAddContainerItem(bp, i.id, i.amount)
          doCreatureSay(cid, "Decorating Packdage!" ,19)
          doSendMagicEffect(getCreaturePosition(cid), 35)
        end
return doRemoveItem(item.uid)
end

Code:
<action itemid="xxxx" script="surprise.lua"/>
make sure the last line doesn't have a comma..
Code:
{id = xxxx, amount = 100},
{id = xxxx, amount = 100}
}
 
and u can use it too found in old scripts
Code:
local PRESENT_BLUE = {2687, 6394, 6280, 6574, 6578, 6575, 6577, 6569, 6576, 6572, 2114}
local PRESENT_RED = {2152, 2152, 2152, 2153, 5944, 2112, 6568, 6566, 2492, 2520, 2195, 2114, 2114, 2114, 6394, 6394, 6576, 6576, 6578, 6578, 6574, 6574}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local count = 1
    if(item.itemid == 6570) then
        local randomChance = math.random(1, #PRESENT_BLUE)
        if(randomChance == 1) then
            count = 10
        elseif(randomChance == 2) then
            count = 3
        end
        doPlayerAddItem(cid, PRESENT_BLUE[randomChance], count)
    elseif(item.itemid == 6571) then
        local randomChance = math.random(1, #PRESENT_RED)
        if randomChance > 0 and randomChance < 4 then
            count = 10
        end
        doPlayerAddItem(cid, PRESENT_RED[randomChance], count)
    end

    doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
    doRemoveItem(item.uid, 1)
    return true
end

Code:
<action fromid="6570" toid="6571" event="script" value="surprisebag.lua"/>
 
Back
Top