Medargo
Member
- Joined
- Jun 9, 2010
- Messages
- 158
- Reaction score
- 19
Hello, I know that the item surprise bag already has a script, but I decided to improve it, how?
actions.xml
surpbag.xml
Any trouble please report me, that's all, hope it was usefull!
- You can set any messages to be shown when the bag is opened;
- You can set in the script how many presents the player can get;
- If you want to make it possible to get 1, 2 or 3 presents, depending on player's luck, you can do this, also you can set the chance. Example: Get 1 item [50%] ; Get 2 itens [35%] ; Get 3 item [15%];
- It is possible to create a list with all possible itens that the bag can give;
- Also, you can increase or decrease the chance of getting any item!
- In my opinion, script very nice to study also to confugurate!
actions.xml
XML:
<action fromid="6570" toid="6571" event="script" value="surpbag.lua"/>
surpbag.xml
Lua:
-- [ Script made by Medargo ] --
function onUse(cid, item, frompos, item2, topos)
local presentsa = presentn[math.random(1,#presentn)] -- Do not change!
local msgs = {"TUF TUF", "HO HO HO!", "HAIL", "OTLAND", "CONGRATZ"} -- Displayed messages when opening the bag..
local msg_outside = "You have to put the surprise bag in your inventory in order to use it" -- Displayed messages when bag is not on inventory..
local effs = {29, 30} -- Effects sent when opening the bag..
local presentn = {1, 1, 1, 2, 2, 3} --[[ This is the chance of getting 1, 2 or 3 itens,
more 1s means more chances of getting just
1 item, same for the other numbers, you can
insert any number if you want! --]]
local presents = {
{id = 2160, quant = 2}, -- 2 Crystal Coin
{id = 2152, quant = 30},-- 30 Platinum coin
{id = 2152, quant = 30},-- 30 Platinum coin
{id = 2152, quant = 30},-- 30 Platinum coin
{id = 2534, quant = 1}, -- 1 Vampire Shield
{id = 6132, quant = 1}} -- 1 Pair of Soft Boots
-- Please note that you can increase the chance of getting determined item by repeting it on the table (as the 30 Platinum Coins)
--------------------------------------------------- DO NOT CHANGE ANYTHING FROM THIS LINE DOWN! ---------------------------------------------------
if getPlayerItemCount(cid, item.itemid) >= 1 then
doPlayerSendTextMessage(cid, 25, "You received "..presentsa.." presents..")
doSendMagicEffect(topos, effs[math.random(1,#effs)])
doSendAnimatedText(topos, msgs[math.random(1,#msgs)], 192)
doPlayerRemoveItem(cid, item.itemid, 1)
for quant = 1, presentsa do
local rand = math.random(1,#presents)
doPlayerAddItem(cid, presents[rand].id, presents[rand].quant)
end
else
doPlayerSendTextMessage(cid, 25, msg_outside)
doSendMagicEffect(topos, 2)
end
return true
end
Any trouble please report me, that's all, hope it was usefull!