The One Armed Bandit [API 2]
 

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 [API 2]

Started by Cêñoßy†ê, 08 December, 2007, 14:08:39

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Cêñoßy†ê

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
Powered By Leviathan™ 2nd Generation v. 1.9

SMF spam blocked by CleanTalk