Karofel
New Member
- Joined
- Apr 12, 2017
- Messages
- 10
- Solutions
- 1
- Reaction score
- 2
Hello, I wrote that script and now want to extend it, but i need to create so much tables etc for that. So there is someone who have idea how to optimize that?
Lua:
local chance1 = 1
local chance2 = 5
local chancerare = 20
local itemstodestroy = {25522, 2494, 25523}
local mats = {5887, 5888}
local raremats = {6500, 12505}
local count = 1
function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)
local it = itemEx:getId()
local name = itemEx:getName()
if isInArray(itemstodestroy, it) then
count = 5
if math.random(1, chance1) == 1 then
player:addItem(mats[math.random(1, #mats)], (math.random(1, count)))
player:sendTextMessage(MESSAGE_INFO_DESCR, "You succesfull disassembled "..name..".")
itemEx:remove(1)
if math.random(1, chance2) == 1 then
player:addItem(mats[math.random(1, #mats)], (math.random(1, count)))
elseif math.random(1, chancerare) == 1 then
player:addItem(raremats[math.random(1, #raremats)], (math.random(1, count)))
player:sendTextMessage(MESSAGE_INFO_DESCR, "... and get rare mats!")
end
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "You failed on disassembling "..name.."...")
itemEx:remove(1)
end
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "You cannot disassemble "..name..".")
end
return true
end