• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Bronze,Silver,Gold,Magic Chest for players!

Mariuskens

Sword Art Online 2D-MMORPG
Joined
Nov 21, 2008
Messages
1,009
Reaction score
119
Location
Spain
GitHub
Olimpotibia
Hello im looking some help to do chests like Clash Royale ( Click chest some times and he gives random items finaly dissapear)

Thnx for look this :D

TIBIA
849590c172390b33ecaeafcf95afbaf8.png


CLASH ROYALE
2016-03-24-17-05-39-cofres.jpg

 
local bronze = {7463, 7464, 7457, 3973, 7458, 7342, 9811, 9817, 9810, 9822} --items that randomly generated--
local silver = {2358, 7730, 2656, 2663, 10521, 2542, 9811, 9817, 9810, 9822}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local count = 1
if item.itemid == 1987 then --item of the bronze chest you want to use--
local randomChance = math.random(1, 10)
doPlayerAddItem(cid, bronze[randomChance], 1)
elseif item.itemid == 1996 then --item of the silver chest you want to use--
local randomChance = math.random(1, 10)
doPlayerAddItem(cid, silver[randomChance], 1)
end
doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
doRemoveItem(item.uid, 1)
return TRUE
end



it a single use random item generator you can edit the items in the above local by using the different IDS for the items you want if the items are less than ten
local randomChance = math.random(1, 10) change the number ten to the appropriate number
ex: i use 6 items
the code would look like
local randomChance = math.random(1, 6)

<action actionid="6570" script="other/tiereqbags.lua"/>

you put the action id on the chest that you would like to use in remers it the same action for all the chest
 
Code:
local randomChance = math.random(1, 10)
doPlayerAddItem(cid, bronze[randomChance], 1)
change this to
Code:
doPlayerAddItem(cid, bronze[math.random(#bronze)], 1)
and second to
doPlayerAddItem(cid, silver[math.random(#silver)], 1)
so you dont have to change everything if you change the rewards
 
if you change rewards you have to change numbers, which is pointless and can be avoided by doing it that way
also saving a variable with the random from size of table and then using it once is pointless
 
those arent the actual rewards he wants those are the rewards i used for testing he would have to change the rewards for the certain items that he wants.
 
Back
Top