cavazospedro
Member
can you ppost the script?work 100% tfs 1.3
can you ppost the script?work 100% tfs 1.3
I don't know if anyone cares but to solve this you need to change this:For some reason not working for me, i just edit the positions from left to right, but items appears in first and last tile only.
View attachment 57655
for i = 1, maxslot do
addEvent(delay, 1*1*60, slots[i], i)
end
for i = maxslot, 1, -1 do
addEvent(delay, 1*1*60, slots[i], i)
end
local tiles = {
Position(1008, 1002, 7),
Position(1008, 1003, 7),
Position(1008, 1004, 7),
Position(1008, 1005, 7), -- Center Tile is winning Tile --
Position(1008, 1006, 7),
Position(1008, 1007, 7),
Position(1008, 1008, 7)
}
local items = {
-- Chance Win / itemid / amount / chance amount (out of 100000)
[{1, 10001}] = {itemid = 2148, amount = 5, amountChance = 80000}, -- 1, 10001 = 10000 (100000/10000 = 10% chance to win) [100000 / 80000 = 80% chance for amount to increase]
[{10002, 15002}] = {itemid = 2152, amount = 5, amountChance = 50000},
[{15003, 18003}] = {itemid = 2160, amount = 5, amountChance = 25000}
}
-- local items = {
-- -- Chance Win / itemid / amount / chance amount (out of 100000)
-- [{1, 80001}] = {itemid = 2148, amount = 5, amountChance = 80000}, -- 1, 10001 = 10000 (100000/10000 = 10% chance to win) [100000 / 80000 = 80% chance for amount to increase]
-- [{80002, 85002}] = {itemid = 2152, amount = 5, amountChance = 50000},
-- [{85003, 88003}] = {itemid = 2160, amount = 5, amountChance = 25000}
-- }
local itemsList = {2148, 2152, 2160}
local canGetNoItem = false -- If true players can get nothing at all. --
local autoWin = {itemid = 2148, amount = 5, amountChance = 80000} -- Item that is always won if they have to get something. --
local leverAID = 1000 -- AID in map for item that is used to roll --
local leverItemID = 1945 -- itemid for item that is used to roll --
-- Item required to spin activate roulette --
local itemRequired = 2160
local itemAmount = 1
local roulette = Action()
function roulette.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not player:removeItem(itemRequired, itemAmount) then
return player:sendCancelMessage("You do not have "..itemAmount.." "..ItemType(itemRequired):getName()..".")
end
local rand = math.random(100000)
local win = false
for i, v in pairs(items) do
if rand >= i[1] and rand <= i[2] then
win = items[i]
break
end
end
if not canGetNoItem and not win then
win = autoWin
end
local winAmount = 0
if win then
for i = 1, win.amount do
local rand = math.random(100000)
if rand <= win.amountChance then
winAmount = winAmount + 1
end
end
end
rollItems(win, winAmount, 30, player:getName())
return true
end
function rollItems(winTable, winAmount, spins, name)
moveItems()
if spins == 3 then
if not winTable then
spins = spins - 1
addEvent(rollItems, 200, winTable, winAmount, spins, name)
return true
end
Game.createItem(winTable.itemid, winAmount, tiles[1])
spins = spins - 1
addEvent(rollItems, 200, winTable, winAmount, spins, name)
return true
end
if spins >= 1 and spins ~= 3 then
local randEmpty = math.random(6)
if randEmpty == 1 then
spins = spins - 1
addEvent(rollItems, 200, winTable, winAmount, spins, name)
return true
end
local randomItem = itemsList[math.random(#itemsList)]
local itemType = ItemType(randomItem)
if itemType:isStackable() then
Game.createItem(randomItem, math.random(5), tiles[1])
else
Game.createItem(randomItem, 1, tiles[1])
end
spins = spins - 1
addEvent(rollItems, 200, winTable, winAmount, spins, name)
return true
end
if spins == 0 then
giveReward(winTable, winAmount, name)
end
end
function moveItems()
local tileItems = {}
for i = 1, #tiles do
local tile = Tile(tiles[i])
if tile and tile:getTopDownItem() then
tileItems[i] = tile:getTopDownItem()
elseif tile and not tile:getTopDownItem() then
tileItems[i] = false
end
end
for i = 1, #tileItems do
if i == 7 and tileItems[i] ~= false then
tileItems[i]:remove()
return true
elseif tileItems[i] ~= false then
tileItems[i]:moveTo(tiles[i + 1])
end
end
end
function giveReward(winTable, winAmount, name)
local player = Player(name)
if not player then return true end
if not winTable then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You didn't win anything.")
return true
end
player:addItem(winTable.itemid, winAmount)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You won "..winAmount.." "..ItemType(winTable.itemid):getName()..".")
end
roulette:id(leverItemID)
roulette:register()
Not sure how this script works, sometimes it lands in the middle. Sometimes right next to it (Left) and it does not give out the reward/the amount it lands on eitherRevscript version. Pretty configurable.
Lua:local tiles = { Position(1008, 1002, 7), Position(1008, 1003, 7), Position(1008, 1004, 7), Position(1008, 1005, 7), -- Center Tile is winning Tile -- Position(1008, 1006, 7), Position(1008, 1007, 7), Position(1008, 1008, 7) } local items = { -- Chance Win / itemid / amount / chance amount (out of 100000) [{1, 10001}] = {itemid = 2148, amount = 5, amountChance = 80000}, -- 1, 10001 = 10000 (100000/10000 = 10% chance to win) [100000 / 80000 = 80% chance for amount to increase] [{10002, 15002}] = {itemid = 2152, amount = 5, amountChance = 50000}, [{15003, 18003}] = {itemid = 2160, amount = 5, amountChance = 25000} } -- local items = { -- -- Chance Win / itemid / amount / chance amount (out of 100000) -- [{1, 80001}] = {itemid = 2148, amount = 5, amountChance = 80000}, -- 1, 10001 = 10000 (100000/10000 = 10% chance to win) [100000 / 80000 = 80% chance for amount to increase] -- [{80002, 85002}] = {itemid = 2152, amount = 5, amountChance = 50000}, -- [{85003, 88003}] = {itemid = 2160, amount = 5, amountChance = 25000} -- } local itemsList = {2148, 2152, 2160} local canGetNoItem = false -- If true players can get nothing at all. -- local autoWin = {itemid = 2148, amount = 5, amountChance = 80000} -- Item that is always won if they have to get something. -- local leverAID = 1000 -- AID in map for item that is used to roll -- local leverItemID = 1945 -- itemid for item that is used to roll -- -- Item required to spin activate roulette -- local itemRequired = 2160 local itemAmount = 1 local roulette = Action() function roulette.onUse(player, item, fromPosition, target, toPosition, isHotkey) if not player:removeItem(itemRequired, itemAmount) then return player:sendCancelMessage("You do not have "..itemAmount.." "..ItemType(itemRequired):getName()..".") end local rand = math.random(100000) local win = false for i, v in pairs(items) do if rand >= i[1] and rand <= i[2] then win = items[i] break end end if not canGetNoItem and not win then win = autoWin end local winAmount = 0 if win then for i = 1, win.amount do local rand = math.random(100000) if rand <= win.amountChance then winAmount = winAmount + 1 end end end rollItems(win, winAmount, 30, player:getName()) return true end function rollItems(winTable, winAmount, spins, name) moveItems() if spins == 3 then if not winTable then spins = spins - 1 addEvent(rollItems, 200, winTable, winAmount, spins, name) return true end Game.createItem(winTable.itemid, winAmount, tiles[1]) spins = spins - 1 addEvent(rollItems, 200, winTable, winAmount, spins, name) return true end if spins >= 1 and spins ~= 3 then local randEmpty = math.random(6) if randEmpty == 1 then spins = spins - 1 addEvent(rollItems, 200, winTable, winAmount, spins, name) return true end local randomItem = itemsList[math.random(#itemsList)] local itemType = ItemType(randomItem) if itemType:isStackable() then Game.createItem(randomItem, math.random(5), tiles[1]) else Game.createItem(randomItem, 1, tiles[1]) end spins = spins - 1 addEvent(rollItems, 200, winTable, winAmount, spins, name) return true end if spins == 0 then giveReward(winTable, winAmount, name) end end function moveItems() local tileItems = {} for i = 1, #tiles do local tile = Tile(tiles[i]) if tile and tile:getTopDownItem() then tileItems[i] = tile:getTopDownItem() elseif tile and not tile:getTopDownItem() then tileItems[i] = false end end for i = 1, #tileItems do if i == 7 and tileItems[i] ~= false then tileItems[i]:remove() return true elseif tileItems[i] ~= false then tileItems[i]:moveTo(tiles[i + 1]) end end end function giveReward(winTable, winAmount, name) local player = Player(name) if not player then return true end if not winTable then player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You didn't win anything.") return true end player:addItem(winTable.itemid, winAmount) player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You won "..winAmount.." "..ItemType(winTable.itemid):getName()..".") end roulette:id(leverItemID) roulette:register()
Will this work on tfs 1.4? tibia 772 ??Revscript version. Pretty configurable.
Lua:local tiles = { Position(1008, 1002, 7), Position(1008, 1003, 7), Position(1008, 1004, 7), Position(1008, 1005, 7), -- Center Tile is winning Tile -- Position(1008, 1006, 7), Position(1008, 1007, 7), Position(1008, 1008, 7) } local items = { -- Chance Win / itemid / amount / chance amount (out of 100000) [{1, 10001}] = {itemid = 2148, amount = 5, amountChance = 80000}, -- 1, 10001 = 10000 (100000/10000 = 10% chance to win) [100000 / 80000 = 80% chance for amount to increase] [{10002, 15002}] = {itemid = 2152, amount = 5, amountChance = 50000}, [{15003, 18003}] = {itemid = 2160, amount = 5, amountChance = 25000} } -- local items = { -- -- Chance Win / itemid / amount / chance amount (out of 100000) -- [{1, 80001}] = {itemid = 2148, amount = 5, amountChance = 80000}, -- 1, 10001 = 10000 (100000/10000 = 10% chance to win) [100000 / 80000 = 80% chance for amount to increase] -- [{80002, 85002}] = {itemid = 2152, amount = 5, amountChance = 50000}, -- [{85003, 88003}] = {itemid = 2160, amount = 5, amountChance = 25000} -- } local itemsList = {2148, 2152, 2160} local canGetNoItem = false -- If true players can get nothing at all. -- local autoWin = {itemid = 2148, amount = 5, amountChance = 80000} -- Item that is always won if they have to get something. -- local leverAID = 1000 -- AID in map for item that is used to roll -- local leverItemID = 1945 -- itemid for item that is used to roll -- -- Item required to spin activate roulette -- local itemRequired = 2160 local itemAmount = 1 local roulette = Action() function roulette.onUse(player, item, fromPosition, target, toPosition, isHotkey) if not player:removeItem(itemRequired, itemAmount) then return player:sendCancelMessage("You do not have "..itemAmount.." "..ItemType(itemRequired):getName()..".") end local rand = math.random(100000) local win = false for i, v in pairs(items) do if rand >= i[1] and rand <= i[2] then win = items[i] break end end if not canGetNoItem and not win then win = autoWin end local winAmount = 0 if win then for i = 1, win.amount do local rand = math.random(100000) if rand <= win.amountChance then winAmount = winAmount + 1 end end end rollItems(win, winAmount, 30, player:getName()) return true end function rollItems(winTable, winAmount, spins, name) moveItems() if spins == 3 then if not winTable then spins = spins - 1 addEvent(rollItems, 200, winTable, winAmount, spins, name) return true end Game.createItem(winTable.itemid, winAmount, tiles[1]) spins = spins - 1 addEvent(rollItems, 200, winTable, winAmount, spins, name) return true end if spins >= 1 and spins ~= 3 then local randEmpty = math.random(6) if randEmpty == 1 then spins = spins - 1 addEvent(rollItems, 200, winTable, winAmount, spins, name) return true end local randomItem = itemsList[math.random(#itemsList)] local itemType = ItemType(randomItem) if itemType:isStackable() then Game.createItem(randomItem, math.random(5), tiles[1]) else Game.createItem(randomItem, 1, tiles[1]) end spins = spins - 1 addEvent(rollItems, 200, winTable, winAmount, spins, name) return true end if spins == 0 then giveReward(winTable, winAmount, name) end end function moveItems() local tileItems = {} for i = 1, #tiles do local tile = Tile(tiles[i]) if tile and tile:getTopDownItem() then tileItems[i] = tile:getTopDownItem() elseif tile and not tile:getTopDownItem() then tileItems[i] = false end end for i = 1, #tileItems do if i == 7 and tileItems[i] ~= false then tileItems[i]:remove() return true elseif tileItems[i] ~= false then tileItems[i]:moveTo(tiles[i + 1]) end end end function giveReward(winTable, winAmount, name) local player = Player(name) if not player then return true end if not winTable then player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You didn't win anything.") return true end player:addItem(winTable.itemid, winAmount) player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You won "..winAmount.." "..ItemType(winTable.itemid):getName()..".") end roulette:id(leverItemID) roulette:register()
[Erro - Interface de ação]
data/actions/scripts/newlottery.luanUse
Descrição:
data/actions/scripts/newlottery.lua:101: tentativa de chamar o método 'removeItem' (um valor nulo)
rastreamento de pilha:
data/actions/scripts/newlottery.lua:101: na função <data/actions/scripts/newlottery.lua:96>