Ruffly tested and it works =)
--[[
"The One Armed Bandit"
*Created by: FlipDeluXe (May 10 2003)
Bought back to life for API 2 by C??o?y?? (08/12/2007)
]]--
bot = "One_Armed_Bandit"
A=5
credit=0
function OnStartup()
OnOrOff = false
end
function ChatArrival(user,data)
data=string.sub(data,1,string.len(data)-1)
local _,_,cmd = data:find("%b<>%s(%S+)")
if cmd == "!insert" and OnOrOff == false then
OnOrOff = true
A=3
player=user.sNick
local msg = "\r\n\r\n"
msg = msg.." One_Armed_Bandit started by "..player.." with "..A.." credits\r\n"
msg = msg.." Pull with >> !hit << in Main Chat!\r\n"
Core.SendToAll("<"..bot.."> "..msg)
return true
else
Core.SendToAll("<"..bot.."> dear "..user.sNick.." , "..player.." has started playing allready")
end
if cmd == "!hit" then
if A ~= 0 then
if OnOrOff == true then
if player == user.sNick then
DoSpin(user,data)
else
Core.SendToAll("<"..bot.."> *** Sorry "..user.sNick.." you must wait until "..player.." is done with his round.")
end
else
Core.SendToAll("<"..bot.."> *** Outta credits, insert coin!")
end
else
OnOrOff = false
Core.SendToAll("<"..bot.."> *** Outta credits, insert coin.")
end
return true
end
end
function DoSpin(user,data)
local first = math.random(1,8)
local second = math.random(1,8)
local third = math.random(1,8)
A=A-1
Core.SendToAll(player.."'s credits left: "..A)
local msg = "\r\n\r\n"
msg = msg.." >>>> "..first.." - "..second.." - "..third.." <<<< \r\n\r\n"
if first == 1 and second == first and third == first then
msg = msg.." *** Cool " ..user.sNick.. ", you just won 10 bucks!\r\n"
credit=credit+10
elseif first == 2 and second == 2 and third == 2 then
msg = msg.." *** Great!! " ..user.sNick.." 20 bucks for you!\r\n"
credit=credit+20
elseif first == 3 and second == 3 and third == 3 then
msg = msg.." *** "..user.sNick..", just won 30 bucks...\r\n"
credit=credit+30
elseif first == 4 and second == 4 and third == 4 then
msg = msg.." *** Wow! "..user.sNick.." it must be your lucky day, 40 bucks!!\r\n"
credit=credit+40
elseif first == 5 and second == 5 and third == 5 then
msg = msg.." *** yeah!! " ..user.sNick.." cha-ching 50 bucks!!!\r\n"
credit=credit+50
elseif first == 6 and second == 6 and third == 6 then
msg = msg.." *** Woohoo!! " ..user.sNick.." You're on a winning spree!! 70 bucks!!!\r\n"
credit=credit+70
elseif first == 7 and second == 7 and third == 7 then
msg = msg.." *** Wow, you won 90 bucks " ..user.sNick.."!!\r\n"
credit=credit+90
elseif first == 8 and second == 8 and third == 8 then
msg = msg.." *** Awesome!! " ..user.sNick.." You just hit the jackpot! cha-ching 100 bucks!!!\r\n"
credit=credit+100
elseif first == 1 and second == 1 and third ~= 1 or
first == 2 and second == 2 and third ~= 2 or
first == 3 and second == 3 and third ~= 3 or
first == 4 and second == 4 and third ~= 4 or
first == 5 and second == 5 and third ~= 5 or
first == 6 and second == 6 and third ~= 6 or
first == 7 and second == 7 and third ~= 7 or
first == 8 and second == 8 and third ~= 8 or
first ~= 1 and second == 1 and third == 1 or
first ~= 2 and second == 2 and third == 2 or
first ~= 3 and second == 3 and third == 3 or
first ~= 4 and second == 4 and third == 4 or
first ~= 5 and second == 5 and third == 5 or
first ~= 6 and second == 6 and third == 6 or
first ~= 7 and second == 7 and third == 7 or
first ~= 8 and second == 8 and third == 8 or
first == 1 and second ~= 1 and third == 1 or
first == 2 and second ~= 2 and third == 2 or
first == 3 and second ~= 3 and third == 3 or
first == 4 and second ~= 4 and third == 4 or
first == 5 and second ~= 5 and third == 5 or
first == 6 and second ~= 6 and third == 6 or
first == 7 and second ~= 7 and third == 7 or
first == 8 and second ~= 8 and third == 8 then
msg = msg.." *** Great!! " ..user.sNick.." a buck for you!\r\n"
credit=credit+1
elseif first ~= second and first ~= third then
msg = msg.." *** Ahhh, too bad "..user.sNick.." you won nothing...\r\n"
end
Core.SendToAll(msg)
if A == 0 then
OnOrOff=false
Core.SendToAll("<"..bot.."> *** Outta credits, insert coin.")
end
if (credit~=0) and (OnOrOff==false) then
tmp = {user.sNick == credit}
Core.SendToAll("<"..bot.."> *** "..user.sNick.." won "..credit.." Bucks ;)")
credit=0
end
if (A==0) and (OnOrOff==false) then
end
return true
end