The One Armed Bandit lua 5
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

The One Armed Bandit lua 5

Started by TiMeTrAVelleR, 04 April, 2005, 20:45:19

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TiMeTrAVelleR

--------------------------------------------- 
-- -- -- -- 
-- "The One Armed Bandit" -- 
-- Created by: FlipDeluXe -- 
-- Date: May 10 2003 -- 
-- Converted to lua 5 by TiMeTrAVelleR
-- -- -- -- 
--------------------------------------------- 
botName="?1-Armed Bandit?" 
wins="bandit_wins.txt"
plays="bandit_plays.txt" 
A=5 
credit=0 
player="foo" 
function Main() OnOrOff="off" end function ChatArrival(user, data) 
if( string.sub(data, 1, 1) == "<" ) then 
-- remove end pipe 
data=string.sub(data,1,string.len(data)-1) 
-- parse the command 
s,e,cmd = string.find( data, "%b<>%s+(%S+)" )
if (cmd=="!insert") and (OnOrOff=="off") then 
OnOrOff="on" 
A=6 
player=user.sName 
SendToAll(botName, "Yeah!! "..player.." just threw in a buck!") 
SendToAll(botName, "started. Pull with >> !hit << in Main Chat!") 
SendToAll("credits left:",A) 
elseif (cmd=="!hit") and A == 0 then 
OnOrOff="off" 
SendToAll(botName, "Outta credits, insert coin.") 
elseif (cmd=="!hit") and (OnOrOff=="off") then 
SendToAll(botName, "Outta credits, insert coin!") 
elseif (cmd=="!hit") and (OnOrOff=="on") and (player~=user.sName) then 
SendToAll(botName, "Sorry "..user.sName.." you must wait until "..player.." is done with his round.") 
elseif (cmd=="!hit") and (OnOrOff=="on") and (player==user.sName) then 
local first=math.random(1,8) 
local second=math.random(1,8) 

local third=math.random(1,8) 
local rollone="@" 
local rolltwo="@" 
local rollthree="@" 
A=A-1 
SendToAll("credits left:",A) 
if first == 1 and second == 1 and third == 1 then 
SendToAll(botName, "Cool " ..user.sName.. ", you just won 10 bucks!") 
credit=credit+10 
elseif first == 2 and second == 2 and third == 2 then 
SendToAll(botName, "Great!! " ..user.sName.." 20 bucks for you!") 
credit=credit+20 
elseif first == 3 and second == 3 and third == 3 then 
SendToAll(botName, user.sName..", just won 30 bucks...") 
credit=credit+30 
elseif first == 4 and second == 4 and third == 4 then 
SendToAll(botName, "Wow! "..user.sName.." it must be your lucky day, 40 bucks!!") 
credit=credit+40 
elseif first == 5 and second == 5 and third == 5 then 
SendToAll(botName, "yeah!! " ..user.sName.." cha-ching 50 bucks!!!") 
credit=credit+50 
elseif first == 6 and second == 6 and third == 6 then 
SendToAll(botName, "Woohoo!! " ..user.sName.." You're on a winning spree!! 70 bucks!!!") 
credit=credit+70 

elseif first == 7 and second == 7 and third == 7 then 
SendToAll(botName, "Wow, you won 90 bucks " ..user.sName.."!!") 
credit=credit+90 

elseif first == 8 and second == 8 and third == 8 then 
SendToAll(botName, "Awesome!! " ..user.sName.." You just hit the jackpot! cha-ching 100 bucks!!!") 
credit=credit+100 
elseif first == 1 and second == 1 and third ~= 1 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first == 2 and second == 2 and third ~= 2 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first == 3 and second == 3 and third ~= 3 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first == 4 and second == 4 and third ~= 4 then
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first == 5 and second == 5 and third ~= 5 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first == 6 and second == 6 and third ~= 6 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!")
credit=credit+1 
elseif first == 7 and second == 7 and third ~= 7 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first == 8 and second == 8 and third ~= 8 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first ~= 1 and second == 1 and third == 1 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first ~= 2 and second == 2 and third == 2 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first ~= 3 and second == 3 and third == 3 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first ~= 4 and second == 4 and third == 4 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first ~= 5 and second == 5 and third == 5 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first ~= 6 and second == 6 and third == 6 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first ~= 7 and second == 7 and third == 7 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first ~= 8 and second == 8 and third == 8 then
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first == 1 and second ~= 1 and third == 1 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!")
credit=credit+1 
elseif first == 2 and second ~= 2 and third == 2 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first == 3 and second ~= 3 and third == 3 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first == 4 and second ~= 4 and third == 4 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first == 5 and second ~= 5 and third == 5 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first == 6 and second ~= 6 and third == 6 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first == 7 and second ~= 7 and third == 7 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first == 8 and second ~= 8 and third == 8 then 
SendToAll(botName, "Great!! " ..user.sName.." a buck for you!") 
credit=credit+1 
elseif first ~= second and first ~= third then 
SendToAll(botName,"Ahhh, too bad "..user.sName.." you won nothing...") 
return 1
end 
if first == 1 then 
rollone="@" 
elseif first == 2 then 
rollone="$" 
elseif first == 3 then 
rollone="#" 
elseif first == 4 then 
rollone="&" 
elseif first == 5 then 
rollone="B" 
elseif first == 6 then 
rollone="O" 
elseif first == 7 then 
rollone="%" 
elseif first == 8 then 
rollone="?"
end 
if second == 1 then 
rolltwo="@" 
elseif second == 2 then 
rolltwo="$" 
elseif second == 3 then 
rolltwo="#" 
elseif second == 4 then 
rolltwo="&" 
elseif second == 5 then 
rolltwo="B" 
elseif second == 6 then 
rolltwo="O" 
elseif second == 7 then 
rolltwo="%" 
elseif second == 8 then 
rolltwo="?" 
end 
if third == 1 then 
rollthree="@" 
elseif third == 2 then 
rollthree="$" 
elseif third == 3 then 
rollthree="#" 
elseif third == 4 then 
rollthree="&" 
elseif third == 5 then 
rollthree="B" 
elseif third == 6 then 
rollthree="O" 
elseif third == 7 then 
rollthree="%" 
elseif third == 8 then 
rollthree="?" 
end 
SendToAll(" ----------------------------------") 
SendToAll(" One-Armed-Bandit \r\n") 
SendToAll(" >>>> "..rollone.." - "..rolltwo.." - "..rollthree.." <<<< \r") 
--SendToAll(" "..first.." "..second.." "..third.." \r\n") 
SendToAll(" ----------------------------------") 
if A == 0 then 
OnOrOff="off" 
SendToAll(botName, "Outta credits, insert coin.") 
end 
if (credit~=0) and (OnOrOff=="off") then 
appendto(wins) 
write("\t"," "..user.sName.." won "..credit.." Bucks \r\n") 
writeto() 
credit=0 
end 
if (A==0) and (OnOrOff=="off") then 
appendto(plays) 
write("",""..player.." \r\n") 
writeto() 
return 1
end 
end 
end 
end

greetzzz TT

Herodes

I thought you'd like to see this ..
--- begin " RW?One-ArmedBandit.lua "
-------------------------------------------------------------------------------
--- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ---
--- "The One Armed Bandit" 					   ---
--- Created by: FlipDeluXe 					   ---
--- Date: May 10 2003 						   ---
--- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ---
--- touched by Herodes' one arm :)			   ---
--- Date: July 27 2004						   ---
--- RW in the title of the script is for : ReWrite	   ---
--- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ---
-------------------------------------------------------------------------------
--- there is !insert to start the game...   ( FlipDeluxe )
--- Pull the arm with !hit ...   ( FlipDeluxe )
--- At any point there is !oknow to take your bucks and go .. :) ( Herodes )
------------------------------------------------------------------ 18/4 - 2005
--- Lua 5 conversion ( Herodes )
--- some small optimisations ..  ( Herodes )
-------------------------------------------------------------------------------

----------------- edit this at will ...
Bot="Bandit"

----------------- pls dont touch below here ..
----------------- or if you touch dont blame either of the authors .. :)

function Main()
	bSwitch, sPlayer, iTriesLeft = false, "", 5
end


function ChatArrival( user, data )
	local data=string.sub(data,1,-2)
	s,e,cmd = string.find( data, "%b<>%s+(%S+)" )
	if cmd then
		local t = {

		["!insert"] = function ( user, data )
			if not bSwitch then
				sStart, iCredit, bSwitch, iTriesLeft, sPlayer = os.date("%X"), 0, true, 5, user.sName
				SendToAll( Bot, "Alright!, "..sPlayer.." just threw in a buck! Let's see what he can do ..." )
				SendToAll( Bot, "Credits left : "..iTriesLeft )
				user:SendData( Bot, "started. Pull with !hit in Main Chat!" )
			end
		end,

		["!hit"] = function ( user, data )
			if sPlayer ~= user.sName then SendToAll(Bot, "Sorry "..user.sName.." you must wait until "..sPlayer.." is done with his round."); return 1; end
			if ( (iTriesLeft == 0) or (not bSwitch) ) then bSwitch = false;SendToAll( Bot, "Better insert a coin if you wanna play with me ..." ); return 1; end
			-- checks done carry on playing
			local iFirst, iSecond, iThird = math.random( 1, 8 ), math.random( 1, 8 ), math.random( 1, 8 )
			-- one try less left
			iTriesLeft = iTriesLeft - 1
			local tFruits = { "@", "$", "#","&", "?","O","%","?" }
			sFirst, sSecond, sThird = tFruits[iFirst], tFruits[iSecond], tFruits[iThird]
			SendToAll("\t...----------------o-0-o----------------...")
			SendToAll("\t?        One-Armed-Bandit        ?")
			SendToAll("\t?      >>>  "..sFirst.."  -  "..sSecond.."  -  "..sThird.."  <<<      ?")
			--SendToAll("\t"..iFirst.." "..iSecond.." "..iThird)
			SendToAll("\t```----------------o-0-o----------------```" )

			local Reward = {
				{ "Cool " ..user.sName.. ", you just won 10 bucks!", 10 },
				{ "Great!! " ..user.sName.." 20 bucks for you!", 20},
				{ user.sName..", just won 30 bucks...", 30},
				{ "Wow! "..user.sName.." it must be your lucky day, 40 bucks!!", 40},
				{ "yeah!! " ..user.sName.." cha-ching 50 bucks!!!", 50},
				{ "Woohoo!! " ..user.sName.." You're on a winning spree!! 70 bucks!!!", 70},
				{ "Wow, you won 90 bucks " ..user.sName.."!!", 90},
				{ "Awesome!! " ..user.sName.." You just hit the jackpot! cha-ching 100 bucks!!!", 100},
				{ "Great!! " ..user.sName.." a buck for you!", 1},
			}

			for i, v in Reward do
				failed = nil
				if (iFirst == i) then
					if (iSecond == i) then
						if (iThird == i) then
							SendToAll( Bot, Reward[i][1] ) ; iTriesLeft = iTriesLeft + Reward[i][2] ; iCredit = iCredit + Reward[i][2]
							SendToAll("A : credit is "..iCredit.." because I added "..Reward[i][2])
							break
						else
							SendToAll( Bot, Reward[9][1] ) ; iTriesLeft = iTriesLeft + Reward[9][2] ; iCredit = iCredit + Reward[9][2]
							SendToAll("B : credit is "..iCredit.." because I added "..Reward[9][2])
							break
						end
					else
						if (iThird == i) then
							SendToAll( Bot, Reward[9][1] ) ; iTriesLeft = iTriesLeft + Reward[9][2] ; iCredit = iCredit + Reward[9][2]
							SendToAll("C : credit is "..iCredit.." because I added "..Reward[9][2])
							break
						else
							failed = true
						end
					end
				else
					if ( iSecond == i ) then
						if ( iThird == i ) then
							SendToAll( Bot, Reward[9][1] ) ; iTriesLeft = iTriesLeft + Reward[9][2] ; iCredit = iCredit + Reward[9][2]
							SendToAll("D : credit is "..iCredit.." because I added "..Reward[9][2])
							break
						else
							failed = true
						end
					else
						failed = true
					end
				end
			end
			if failed then SendToAll(Bot, "Ahhh, too bad "..user.sName.." you won nothing..."); end
			SendToAll("Credits left : "..iTriesLeft)
			if ( iTriesLeft == 0) then
				bSwitch = false
				SendToAll( Bot, "Outta credits, insert coin.")
			end
			if (not bSwitch) then IQuit( user, sStart, iTriesLeft ) end
		end,

		["!oknow"] = function ( user, data )
			if bSwitch then
				bSwitch = false
				if (iCredit > 0) then
					SendToAll(Bot , user.sName.." has taken the money... He dont wanna play with me ...")
				else
					SendToAll(Bot, user.sName.." is a quiter ...")
				end
				IQuit( user, sStart, iTriesLeft, true )
			end
		end,
		}
		if t[cmd] then return t[cmd]( user, data ) end
	end
end

function IQuit( user, sStart, iTriesLeft, bQuit )
	if (iCredit > 0) then
		local f = io.open( "bandit_wins.txt", "a+" )
		local m = "\n - ? -"..user.sName.." won "..iCredit.." bucks - started playing at "..sStart.." ended at "..os.date("%X ? on %d/%m-%Y")
		if bQuit then m = m.." ? * quiter *";end;
		f:write( m );f:close();iCredit = 0
	end
	local f = io.open( "bandit_plays.txt", "a+" )
	local m = "\n - ? -"..sPlayer.." - started playing at "..sStart.." ended at "..os.date("%X ? on %d/%m-%Y")
	if bQuit then m = m.." ? * quiter *"; end;
	f:write( m ); f:close()
end

TiMeTrAVelleR

nice one   1 thing  it shows command in main   like this

Alright!, -T??--T?M??r?V?ll?R just threw in a buck! Let's see what he can do ...
[19:50:39] Credits left : 5
[19:50:39] started. Pull with !hit in Main Chat!
[19:50:39] <-T??--T?M??r?V?ll?R> !insert


greetzz TT

Herodes

QuoteOriginally posted by T?M??r?V?ll?R
nice one   1 thing  it shows command in main   like this

Alright!, -T??--T?M??r?V?ll?R just threw in a buck! Let's see what he can do ...
[19:50:39] Credits left : 5
[19:50:39] started. Pull with !hit in Main Chat!
[19:50:39] <-T??--T?M??r?V?ll?R> !insert


greetzz TT
yep,... left it on purpose so ppl can see who is playing ...

TiMeTrAVelleR

could you tel me to get it away ;)

greetzz TT

Herodes

QuoteOriginally posted by T?M??r?V?ll?R
could you tel me to get it away ;)

greetzz TT
in ChatArrival there is a table that includes the commands like :
["!cmd"] = function ( user, data )
-- do smth
end,
["!cmd2"] = function (user, data)
-- do smth else
end,

you'll need to insert a 'return 1' before the end of each function... like :
["!cmd"] = function ( user, data )
-- do smth
return 1
end,
["!cmd2"] = function (user, data)
-- do smth else
return 1
end,
good luck TT ;)

TiMeTrAVelleR

#6
--- begin " RW?One-ArmedBandit.lua "
-------------------------------------------------------------------------------
--- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ---
--- "The One Armed Bandit" 					   ---
--- Created by: FlipDeluXe 					   ---
--- Date: May 10 2003 						   ---
--- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ---
--- touched by Herodes' one arm :)			   ---
--- Date: July 27 2004						   ---
--- RW in the title of the script is for : ReWrite	   ---
--- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ---
-------------------------------------------------------------------------------
--- there is !insert to start the game...   ( FlipDeluxe )
--- Pull the arm with !hit ...   ( FlipDeluxe )
--- At any point there is !oknow to take your bucks and go .. :) ( Herodes )
------------------------------------------------------------------ 18/4 - 2005
--- Lua 5 conversion ( Herodes )
--- some small optimisations ..  ( Herodes )
-------------------------------------------------------------------------------

----------------- edit this at will ...
Bot="Bandit"
SendComm = 1		-- Send user command [right click] "1"=yes "0"=no

SetTo = {
 [0] = 1,   -- Masters
 [1] = 1,   -- Operators
 [2] = 1,   -- Vips
 [3] = 1,   -- Regs
 [4] = 1,   -- Moderator
 [5] = 1,   -- NetFounder
 [-1] = 0,  -- Users
}
----------------- pls dont touch below here ..
----------------- or if you touch dont blame either of the authors .. :)

function NewUserConnected(user)
	if SendComm == 1 and SetTo[user.iProfile] == 1 then 
	if user.bUserCommand then -- Is new function to check if client has UserCommand support.
		user:SendData("$UserCommand 0 3")
		user:SendData("$UserCommand 1 3 -=( The One Armed Bandit )=-\\Insert Coin $<%[mynick]> !insert||")
		user:SendData("$UserCommand 1 3 -=( The One Armed Bandit )=-\\Hit Arm$<%[mynick]> !hit||")
		user:SendData("$UserCommand 1 3 -=( The One Armed Bandit )=-\\Take Money & Quite $<%[mynick]> !oknow||")
		end
	end
end

OpConnected = NewUserConnected


function Main()
	bSwitch, sPlayer, iTriesLeft = false, "", 5
end


function ChatArrival( user, data )
	local data=string.sub(data,1,-2)
	s,e,cmd = string.find( data, "%b<>%s+(%S+)" )
	if cmd then
		local t = {

		["!insert"] = function ( user, data )
			if not bSwitch then
				sStart, iCredit, bSwitch, iTriesLeft, sPlayer = os.date("%X"), 0, true, 5, user.sName
				SendToAll( Bot, "Alright!, "..sPlayer.." just threw in a buck! Let's see what he can do ..." )
				SendToAll( Bot, "Credits left : "..iTriesLeft )
				user:SendData( Bot, "started. Pull with !hit in Main Chat!" )
				return 1
			end
		end,

		["!hit"] = function ( user, data )
			if sPlayer ~= user.sName then SendToAll(Bot, "Sorry "..user.sName.." you must wait until "..sPlayer.." is done with his round."); return 1; end
			if ( (iTriesLeft == 0) or (not bSwitch) ) then bSwitch = false;SendToAll( Bot, "Better insert a coin if you wanna play with me ..." ); return 1; end
			-- checks done carry on playing
			local iFirst, iSecond, iThird = math.random( 1, 8 ), math.random( 1, 8 ), math.random( 1, 8 )
			-- one try less left
			iTriesLeft = iTriesLeft - 1
			local tFruits = { "@", "$", "#","&", "?","O","%","?" }
			sFirst, sSecond, sThird = tFruits[iFirst], tFruits[iSecond], tFruits[iThird]
			SendToAll("\t...----------------o-0-o----------------...")
			SendToAll("\t?        One-Armed-Bandit        ?")
			SendToAll("\t?      >>>  "..sFirst.."  -  "..sSecond.."  -  "..sThird.."  <<<      ?")
			--SendToAll("\t"..iFirst.." "..iSecond.." "..iThird)
			SendToAll("\t```----------------o-0-o----------------```" )

			local Reward = {
				{ "Cool " ..user.sName.. ", you just won 10 bucks!", 10 },
				{ "Great!! " ..user.sName.." 20 bucks for you!", 20},
				{ user.sName..", just won 30 bucks...", 30},
				{ "Wow! "..user.sName.." it must be your lucky day, 40 bucks!!", 40},
				{ "yeah!! " ..user.sName.." cha-ching 50 bucks!!!", 50},
				{ "Woohoo!! " ..user.sName.." You're on a winning spree!! 70 bucks!!!", 70},
				{ "Wow, you won 90 bucks " ..user.sName.."!!", 90},
				{ "Awesome!! " ..user.sName.." You just hit the jackpot! cha-ching 100 bucks!!!", 100},
				{ "Great!! " ..user.sName.." a buck for you!", 1},
			}

			for i, v in Reward do
				failed = nil
				if (iFirst == i) then
					if (iSecond == i) then
						if (iThird == i) then
							SendToAll( Bot, Reward[i][1] ) ; iTriesLeft = iTriesLeft + Reward[i][2] ; iCredit = iCredit + Reward[i][2]
							SendToAll("A : credit is "..iCredit.." because I added "..Reward[i][2])
							break
						else
							SendToAll( Bot, Reward[9][1] ) ; iTriesLeft = iTriesLeft + Reward[9][2] ; iCredit = iCredit + Reward[9][2]
							SendToAll("B : credit is "..iCredit.." because I added "..Reward[9][2])
							break
							
						end
					else
						if (iThird == i) then
							SendToAll( Bot, Reward[9][1] ) ; iTriesLeft = iTriesLeft + Reward[9][2] ; iCredit = iCredit + Reward[9][2]
							SendToAll("C : credit is "..iCredit.." because I added "..Reward[9][2])
							break
						else
							failed = true
						end
					end 
				else
					if ( iSecond == i ) then
						if ( iThird == i ) then
							SendToAll( Bot, Reward[9][1] ) ; iTriesLeft = iTriesLeft + Reward[9][2] ; iCredit = iCredit + Reward[9][2]
							SendToAll("D : credit is "..iCredit.." because I added "..Reward[9][2])
							break
						else
							failed = true
							
						end
					else
						failed = true
						
					end
				end
			end
			if failed then SendToAll(Bot, "Ahhh, too bad "..user.sName.." you won nothing..."); end
			SendToAll("Credits left : "..iTriesLeft)
			if ( iTriesLeft == 0) then
				bSwitch = false
				SendToAll( Bot, "Outta credits, insert coin.")
				
			end
			if (not bSwitch) then IQuit( user, sStart, iTriesLeft ) end
				return 1
		end,

		["!oknow"] = function ( user, data )
			if bSwitch then
				bSwitch = false
				if (iCredit > 0) then
					SendToAll(Bot , user.sName.." has taken the money... He dont wanna play with me ...")
				else
					SendToAll(Bot, user.sName.." is a quiter ...")
					return 1
				end
				IQuit( user, sStart, iTriesLeft, true )
				
			end
		end,
		}
		if t[cmd] then return t[cmd]( user, data ) end
	end
end

function IQuit( user, sStart, iTriesLeft, bQuit )
	if (iCredit > 0) then
		local f = io.open( "bandit_wins.txt", "a+" )
		local m = "\n - ? -"..user.sName.." won "..iCredit.." bucks - started playing at "..sStart.." ended at "..os.date("%X ? on %d/%m-%Y")
		if bQuit then m = m.." ? * quiter *";end;
		f:write( m );f:close();iCredit = 0
	end
	local f = io.open( "bandit_plays.txt", "a+" )
	local m = "\n - ? -"..sPlayer.." - started playing at "..sStart.." ended at "..os.date("%X ? on %d/%m-%Y")
	if bQuit then m = m.." ? * quiter *"; end;
	f:write( m ); f:close()
end

added mouse commands   and commands wont show in main now  :P

Greetzz TT

Herodes

good job TT.. although you should add user.bUserCommand checking for the users that don't support $UserCommand, .. just some lil banwidth saver ;)

TiMeTrAVelleR

Script updated thanks for tip ;)

Anna

Any chance the bot can be made saving "scores" so users can continue playint at another point? Even if they leave hub, gets disconnected by hub (ie reset by server)

I think I had a one armed bandit in lua4 that had that options... unfortunatly I cant seem to find that version now...

This is a cool version though, but I'd prefere if scores were saved, and it would be nice with some possibility of showing top 5 players for instance

Anna

noticed one other thing, it seem to have probs counting:

[14:13]    ...----------------o-0-o----------------...
[14:13]    ?        One-Armed-Bandit        ?
[14:13]    ?      >>>  ?  -  @  -  ?  <<<      ?
[14:13]    ```----------------o-0-o----------------```
[14:13] Great!! ????? Anna ????? a buck for you!
[14:13] C : credit is 4 because I added 1 <---- I got a feeling sme goes bad here...
[14:13] Credits left : 1

Dessamator

hmm, im confused is one armed bandit, by chill or by flipdeluxe, or is flipdeluxe == chill? or chill just remake the script ?
Ignorance is Bliss.

jiten

QuoteOriginally posted by Anna
Any chance the bot can be made saving "scores" so users can continue playint at another point? Even if they leave hub, gets disconnected by hub (ie reset by server)

I think I had a one armed bandit in lua4 that had that options... unfortunatly I cant seem to find that version now...

This is a cool version though, but I'd prefere if scores were saved, and it would be nice with some possibility of showing top 5 players for instance
From what I saw, this script does save "scores" but not all.
It saves them everytime a user runs out of tries or when he uses the !oknow command.

Cheers

SMF spam blocked by CleanTalk