• 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!

Lua Gambling Problems

Powtreeman

Member
Joined
Sep 26, 2011
Messages
400
Reaction score
6
Location
USA
I am trying the script from http://otland.net/threads/casino-slot-machine.114783/
I am using 1.0

And I have my place set up but the levers used in it wont even move. So I figured it might just be a problem with this specific lever.
The same lever without an action id or a unique id wont move either. So how do I fix levers to get them to flip when I use them?
 
and also can someone tell me if i set this up right?
Code:
--[[
  Advanced Slot Machine
  by Cybermaster (cbrm)
]]--

if not isNumeric then
  isNumeric = function(str)
  return tonumber(str) ~= nil
  end
end

if not Position then
  Position = function(x, y, z, stackpos)
  local position = {x = x, y = y, z = z}
  if(isNumeric(stackpos)) then
  position.stackpos = stackpos
  end
  return position
  end
end

if not choose then
  choose = function(...)
  local arg, ret = {...}
  if type(arg[1]) == 'table' then
  ret = arg[1][math.random(#arg[1])]
  else
  ret = arg[math.random(#arg)]
  end
  return ret
  end
end


SETUP = {
  MONEY = 1000, --REQUIRED MONEY(gp) TO PLAY SLOT MACHINE
  TIME = 200,
  LIMIT = 30, --ITERATOR TIME TO STOP CHANGING FRUIT IF PLAYER DOESN'T (30 is like 7 seconds)
  FRUIT = {2674, 2675, 2676, 2679, 2680, 2682, 2683, 5097, 8841}, --FRUITS THAT WILL RANDOMLY APPEAR AND SWITCH
  WIN = {
  -- [{FRUIT.1,FRUIT.2,FRUIT.3} = {PRIZE,#PRIZE}]
  --MIXED COMBOS
  [{2679,2683,2679}] = {2160,2},  -- cherry-pumpkin-cherry
  [{8841,2682,8841}] = {2160,1},  -- lemon-melon-lemon
  --TRIPLE COMBOS
  [{2680,2680,2680}] = {2152,80}, -- triple strawberry
  [{5097,5097,5097}] = {2152,60}, -- triple mango
  [{2683,2683,2683}] = {2152,80}, -- triple pumpkin
  [{2682,2682,2682}] = {2152,50}, -- triple melon
  [{2676,2676,2676}] = {2152,40}, -- triple banana
  [{8841,8841,8841}] = {2152,25}, -- triple lemon
  [{2679,2679,2679}] = {2152,20}, -- triple cherry
  [{2675,2675,2675}] = {2152,30}, -- triple orange
  [{2674,2674,2674}] = {2152,10}, -- triple apple
  --ANY COMBOS
  [{ANY,2683,2683}] = {2152,5}, -- double pumpkin right
  [{2683,2683,ANY}] = {2152,5}, -- double pumpkin left
  [{2683,ANY,2683}] = {2152,10}, -- pumpkin sides combo
  [{ANY,2679,2679}] = {2152,4}, -- double cherry right
  [{2679,2679,ANY}] = {2152,4}, -- double cherry left
  [{2679,ANY,2679}] = {2152,8}, -- cherry sides combo
  [{ANY,8841,8841}] = {2152,5}, -- double lemon right
  [{8841,8841,ANY}] = {2152,5}, -- double lemon left
  [{8841,ANY,8841}] = {2152,5}, -- lemon sides combo
  },
  MSG = {'Bingo!','Lucky!','Jackpot!','Win!'},
  --FRUITS ROWS
  POS = {  --[LEVER.UNIQUEID]
  [6297] = {x = 1000, y = 973, z = 7}, --JUST PUT THE INITIAL ROW POS FROM LEFT, SECOND & THIRD WILL BE AUTOM. GENERATED
  [6298] = {x = 1004, y = 973, z = 7},
  },
}

for i = 1, 3 do --UNIQUEID.LEVER, {POS FROM TILE OF LEFT}
  table.insert(SETUP.POS[6297], i, Position(1000+(i-1), 971, 7))
  table.insert(SETUP.POS[6298], i, Position(1004+(i-1), 971, 7))
end

function getTopItem(p) --Darkhaos's arena
  p.stackpos = 1
  local v = getThingFromPos(p)
  repeat
  p.stackpos = p.stackpos + 1
  v = getThingFromPos(p)
  until v.itemid == 0
  p.stackpos = p.stackpos - 1
  return getThingFromPos(p)
end

function verifyRow(cid, array, pos)
  local result, prize = false, ''

  for a, b in pairs(SETUP.WIN) do
  if (getTileItemById(pos[1], a[1]).uid > 0) or (a[1] == ANY) then
  if (getTileItemById(pos[2], a[2]).uid > 0) or (a[2] == ANY) then
  if (getTileItemById(pos[3], a[3]).uid > 0) or (a[3] == ANY) then
  doPlayerAddItem(cid, b[1], b[2] or 1, true)
  doSendAnimatedText(getThingPos(cid), choose(SETUP.MSG), 66)
  result, prize, amount = true, b[1], b[2]
  break
  end
  end
  end
  end
 
  for i = 1, 3 do
  doSendMagicEffect(pos[i], result and CONST_ME_GIFT_WRAPS or CONST_ME_EXPLOSIONHIT)
  doRemoveItem(getTopItem(pos[i]).uid)
  end  

  if result then
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Congratulations!! You won ' .. amount .. ' ' .. getItemPluralNameById(prize) ..'!')
  else
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You have lost in the Slot Machine :( Try again')
  end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)

  local function doFruit(pos, id, limit)
  if not isPlayer(cid) then
  doItemEraseAttribute(item.uid, 'aid')
  for i = 1, 3 do
  if getTopItem(pos[i]).uid > 0 then
  doRemoveItem(getTopItem(pos[i]).uid)
  end
  end
  return true
  end
  if getTopItem(pos[id]).itemid < 1 then
  doSendMagicEffect(pos[id], CONST_ME_POFF)
  doCreateItem(choose(SETUP.FRUIT), 1, pos[id])
  else
  doTransformItem(getTopItem(pos[id]).uid, choose(SETUP.FRUIT))
  end
  if limit < 1 then
  doSendMagicEffect(pos[id], math.random(28, 30))
  doTransformItem(getTopItem(pos[id]).uid, choose(SETUP.FRUIT))
  doItemSetAttribute(getTopItem(fromPosition).uid, 'aid', getTopItem(fromPosition).actionid+1)
  doTransformItem(getTopItem(fromPosition).uid, getTopItem(fromPosition).itemid == 9826 and 9825 or 9826)
  elseif getTopItem(fromPosition).actionid > id then
  doSendMagicEffect(pos[id], math.random(28, 30))
  doTransformItem(getTopItem(pos[id]).uid, choose(SETUP.FRUIT))
  else
  addEvent(doFruit, SETUP.TIME, pos, id, SETUP.LIMIT-1)
  end
  end
 
  if item.actionid == 0 then
  if not doPlayerRemoveMoney(cid, SETUP.MONEY) then
  return doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You need ' .. SETUP.MONEY ..' gps to play Slot Machine.')
  end
  doItemSetAttribute(item.uid, 'aid', 1)
  doCreatureSetNoMove(cid, true)
  doTransformItem(item.uid, item.itemid == 9826 and 9825 or 9826)
  doSendAnimatedText(getThingPos(cid), '-$' .. SETUP.MONEY, 180)
  for i = 1, 3 do
  doFruit(SETUP.POS[item.uid], i, i*SETUP.LIMIT)
  end
  elseif isInArray({1,2,3}, item.actionid) then
  doItemSetAttribute(item.uid, 'aid', item.actionid+1)
  doTransformItem(item.uid, item.itemid == 9826 and 9825 or 9826)
  elseif item.actionid == 4 then
  doCreatureSetNoMove(cid, false)
  doItemEraseAttribute(item.uid, 'aid')
  doTransformItem(item.uid, item.itemid == 9826 and 9825 or 9826)
  verifyRow(cid, SETUP.WIN, SETUP.POS[item.uid])
  end   
  return true
end
 
Back
Top