atef201080
Member
- Joined
- Aug 16, 2009
- Messages
- 26
- Solutions
- 1
- Reaction score
- 20
Hey,
This script uses OTClient V8 bot and it was tested on Gunzodus and evolunia.
or download it from OTclient V8 Wiki Casino script | OTClientV8 BOT (http://bot.************/books/scripts/page/casino-script)
This script uses OTClient V8 bot and it was tested on Gunzodus and evolunia.
Lua:
-- Casino script
--[[
Casino script for otclientv8
Edit currency id, min, max bet and payrate to fit your needs
Author: Vincent#1766 on discord
]]--
local casinoTab = addTab("Casino")
-- config
local currencyId = 3031 -- betting currency
local minBet = 5 -- minimum betting value
local maxBet = 100 -- maximum betting value
local payRate = 80 -- bet winner pay rate.
local casinoOutfitType = 128 -- change the casino outfit to this + customer colors
local casinoOutfitAddons = 0 -- casino outfit addon on customer enter
local defaultOutfit = { type = 128, head = 78, body = 69, legs = 58, feet = 76, addons = 0} -- default outfit when no customer
-- finding dp config
local counterId = 2342 -- edit this to your depot
local dpTileId = 10145
local dpTileOnStandId = 10146
-- script
local diceIds = { 5792, 5793, 5794, 5795, 5796, 5797 }
local rollingTheDice
local currentPrediction
local currentBet = 0
local previousCustomer
local currentCustomer
local customerBalance = 0
local findingDp
local payingOut = false
local currentCounterTile
local currentDpTile
addTextEdit("casinoGreetMessage", storage.casinoGreetMessage or "Welcome %s, min bet is " .. minBet .. " max bet is " .. maxBet, function(widget, text)
storage.casinoGreetMessage = text
end, casinoTab)
macro(600000, function()
local oldDir = direction()
turn((oldDir + 1) % 4)
schedule(1000, function()
turn(oldDir)
end)
end)
local casinoMacro = macro(100, "Casino", "f9", function()
if inPosition() then
customerInPosition = customer()
if customerInPosition == nil then
if currentCustomer ~= nil then
onCustomerLeave()
end
currentCustomer = nil
end
if customerInPosition ~= nil and currentCustomer == nil then
onCustomerEnter(customerInPosition)
end
else
currentCustomer = nil
if not findingDp then
findEmptyDepot()
delay(1000)
end
end
end, casinoTab)
addIcon("Casino", {item=5796,x = 0.02, y = 0.05}, casinoMacro)
addIcon("Color outfit", {outfit = defaultOutfit, x = 0.08, y = 0.05}, macro(200, "Color outfit", function(macro)
if casinoMacro.isOff() then
macro.setOff()
end
customerInPosition = customer()
if inPosition() and customerInPosition ~= nil then
currentOutfit = player:getOutfit()
outfit = customerInPosition:getOutfit()
if outfit.head ~= currentOutfit.head or outfit.body ~= currentOutfit.body or outfit.legs ~= currentOutfit.legs or outfit.feet ~= currentOutfit.feet then
outfit.type = casinoOutfitType
outfit.addons = casinoOutfitAddons
setOutfit(outfit)
end
elseif customerInPosition == nil then
currentOutfit = player:getOutfit()
if currentOutfit.type ~= defaultOutfit.type or defaultOutfit.head ~= currentOutfit.head or defaultOutfit.body ~= currentOutfit.body or defaultOutfit.legs ~= currentOutfit.legs or defaultOutfit.feet ~= currentOutfit.feet then
setOutfit(defaultOutfit)
end
end
end, casinoTab))
local yellCasinoMsg = macro(60000, "Advertise casino", function()
if inPosition() and currentCustomer == nil then
yell(storage.casinoYellMessage)
end
end, casinoTab)
addTextEdit("casinoYellMessage", storage.casinoYellMessage or "Casino, Min bet " .. minBet .. " max bet " .. maxBet .. " high/low/odd/even " .. payRate .. "%", function(widget, text)
storage.casinoYellMessage = text
end, casinoTab)
function pickUp(item)
containers = getContainers()
for i, container in pairs(containers) do
if container:getItemsCount() < container:getCapacity() or item:isStackable() then
for j, bpItem in ipairs(container:getItems()) do
if bpItem:getId() == item:getId() then
if item:isStackable() then
if bpItem:getCount() ~= 100 and (bpItem:getCount() + item:getCount()) <= 100 then
g_game.move(item, container:getSlotPosition(j - 1), item:getCount())
customerBalance = customerBalance + item:getCount()
return
end
else
g_game.move(item, container:getSlotPosition(container:getItemsCount()), item:getCount())
customerBalance = customerBalance + item:getCount()
return
end
end
end
end
end
for i, container in pairs(containers) do
if container:getItemsCount() < container:getCapacity() then -- has space
g_game.move(item, container:getSlotPosition(container:getItemsCount()), item:getCount())
customerBalance = customerBalance + item:getCount()
return
end
end
for i, container in pairs(containers) do
for j, bpItem in ipairs(container:getItems()) do
if bpItem:isContainer() then
g_game.open(bpItem, container)
schedule(100, function()
pickUp(item)
end)
return
end
end
end
end
onAddThing(function(tile, thing)
if inPosition() and casinoMacro.isOn() and not payingOut then
if tile == currentDpTile then
topThing = tile:getTopThing()
if topThing ~= nil and topThing:isItem() then
if topThing:getId() == currencyId then
if currentCustomer ~= nil then
pickUp(thing)
end
else
for _, diceId in pairs(diceIds) do
if diceId == thing:getId() or thing:getId() == 27 then
return
end
end
g_game.move(thing, pos(), thing:getCount() or 1)
end
end
end
if tile == currentCounterTile then
topThing = tile:getTopThing()
if topThing ~= nil and topThing:isItem() and topThing:getId() == currencyId then
if currentCustomer ~= nil then
pickUp(thing)
end
end
end
end
end)
onRemoveThing(function(tile, thing)
if inPosition() and casinoMacro.isOn() then
if tile == currentCounterTile then
if thing:getId() == currencyId and payingOut and customerBalance == 0 then
schedule(200, function()
payingOut = false
end)
end
end
end
end)
function freeDp(tile)
if tile ~= nil and tile:getGround() ~= nil and tile:getGround():getId() == dpTileId and tile:isWalkable() then
customerTile = g_map.getTile({ x = tile:getPosition().x + 2, y = tile:getPosition().y, z = posz() })
if customerTile ~= nil and customerTile:getGround():getId() == dpTileId and customerTile:isWalkable() then
return true
end
end
return false
end
function findEmptyDepot()
findingDp = true
tiles = g_map.getTiles(posz())
for key, tile in pairs(tiles) do
tileThings = tile:getThings()
if tileThings ~= nil then
for key, thing in pairs(tileThings) do
if thing:getId() == counterId then
futureNorthTile = g_map.getTile({ x = tile:getPosition().x - 1, y = tile:getPosition().y + 1, z = posz() }) -- north
if freeDp(futureNorthTile) then
distance = getDistanceBetween(pos(), futureNorthTile:getPosition())
if autoWalk(futureNorthTile:getPosition(), distance * 2, { ignoreNonPathable = true }) then
currentCounterTile = tile
findingDp = false
return true
end
else
futureSouthTile = g_map.getTile({ x = tile:getPosition().x - 1, y = tile:getPosition().y - 1, z = posz() }) -- south
if freeDp(futureSouthTile) then
distance = getDistanceBetween(pos(), futureSouthTile:getPosition())
if autoWalk(futureSouthTile:getPosition(), distance * 2, { ignoreNonPathable = true }) then
currentCounterTile = tile
findingDp = false
return true
end
end
end
end
end
end
end
end
onPlayerPositionChange(function(newPos, oldPos)
if casinoMacro.isOff() then
return
end
tile = g_map.getTile(newPos)
if tile ~= nil and tile:getGround():getId() == dpTileId and currentCounterTile ~= nil then
counterPos = currentCounterTile:getPosition()
dpPos = { x = counterPos.x - 1, y = counterPos.y, z = counterPos.z }
currentDpTile = g_map.getTile(dpPos)
if currentDpTile ~= nil then
containers = getContainers()
for _, container in pairs(containers) do
if container:getItemsCount() > 1 then
for _, item in ipairs(container:getItems()) do
for _, diceId in pairs(diceIds) do
if item:getId() == diceId then
g_game.move(item, dpPos, 1)
return
end
end
end
end
end
end
end
end)
function onCustomerLeave()
previousCustomer = currentCustomer
turn(0)
end
function onCustomerEnter(newCustomer)
turn(1)
currentCustomer = customerInPosition
if previousCustomer ~= customerInPosition then
customerBalance = 0
say(string.format(storage.casinoGreetMessage, newCustomer:getName()))
end
end
function payOut()
topThing = currentCounterTile:getTopThing()
if topThing ~= nil and topThing:isItem() and topThing:getId() == currencyId then
schedule(150, function()
payOut()
end)
return
end
if customerBalance > 0 then
containers = getContainers()
currency = findItem(currencyId)
if currency ~= nil then
if currency:getCount() >= customerBalance then
g_game.move(currency, currentCounterTile:getPosition(), customerBalance)
customerBalance = 0
return
else
g_game.move(currency, currentCounterTile:getPosition(), currency:getCount())
customerBalance = customerBalance - currency:getCount()
schedule(150, function()
payOut()
end)
return
end
end
for _, container in pairs(containers) do
if container:hasParent() then
g_game.openParent(container)
schedule(150, function()
payOut()
end)
else
print("no currency?" .. currentCustomer:getName() .. " " .. customerBalance)
end
end
end
end
function onCustomerMessage(msg)
if msg == "b" or msg == "balance" then
say("balance: " .. customerBalance)
return
elseif msg == ">" or msg == ">>" or msg == "pay" or msg == "payout" or msg == "give" or msg == "giveout" then
if customerBalance > 0 then
payingOut = true
payOut()
end
return
end
prediction = string.match(msg, "%a")
bet = tonumber(string.match(msg, "%d+")) or customerBalance
if prediction ~= nil and (bet ~= nil and bet >= minBet and bet <= maxBet and customerBalance >= bet and not payingOut) then
if prediction == "h" or prediction == "l" or prediction == "e" or prediction == "o" then
if rollTheDice() then
currentPrediction = prediction
currentBet = bet
end
end
end
end
function rollTheDice()
rollingTheDice = true
dice = currentDpTile:getTopUseThing()
for _, diceId in pairs(diceIds) do
if dice:getId() == diceId then
g_game.use(dice)
return true
end
end
return false
end
function onRoll(number)
won = false
if currentPrediction == "l" then
if number == 1 or number == 2 or number == 3 then
won = true
end
elseif currentPrediction == "h" then
if number == 4 or number == 5 or number == 6 then
won = true
end
elseif currentPrediction == "e" then
if number == 2 or number == 4 or number == 6 then
won = true
end
elseif currentPrediction == "o" then
if number == 1 or number == 3 or number == 5 then
won = true
end
end
if won then
winValue = math.floor(bet * payRate / 100)
say("You won! " .. customerBalance .. " + " .. winValue .. " = " .. customerBalance + winValue)
customerBalance = customerBalance + winValue
else
say(customerBalance .. " - " .. bet .. " = " .. customerBalance - bet)
customerBalance = customerBalance - bet
end
rollingTheDice = false
end
onTalk(function(name, level, mode, text, channelId, pos)
if channelId == 0 then
if currentCustomer ~= nil then
if name == player:getName() and string.match(text, player:getName() .. " rolled a") and mode == 34 and rollingTheDice then
onRoll(tonumber(string.match(text, '[0-6]')))
end
if name == currentCustomer:getName() then
onCustomerMessage(text:lower())
end
end
end
end)
function inPosition(position)
position = position or pos()
tile = g_map.getTile(position)
if tile ~= nil and tile:getGround() ~= nil and tile:getGround():getId() == dpTileOnStandId then
return true
end
return false
end
function customer(position)
position = position or pos()
position.x = position.x + 2
customerTile = g_map.getTile(position)
if customerTile ~= nil and currentCounterTile ~= nil then
return customerTile:getTopCreature()
else
return nil
end
end
or download it from OTclient V8 Wiki Casino script | OTClientV8 BOT (http://bot.************/books/scripts/page/casino-script)
Last edited: