RW?One-Armed Bandit
 

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

RW?One-Armed Bandit

Started by Herodes, 27 July, 2004, 13:35:17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Herodes

One script I toyed with ,  morning coffee works ...

--- 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 )
-------------------------------------------------------------------------------
----------------- edit this at will ... 
botName="Bandit" 

----------------- pls dont touch below here ..
----------------- or if you touch dont blame either of the authors .. :)
A = 5 
player="" 

function Main() 
OnOrOff="off" 
end 


function DataArrival(user, data) 
if( strsub(data, 1, 1) == "<" ) then 
data=strsub(data,1,strlen(data)-1) 
s,e,cmd = strfind( data, "%b<>%s+(%S+)" ) 
	if (cmd=="!insert") and (OnOrOff=="off") then
		startT = date("%X")
		credit = 0
		OnOrOff="on"
		A=5
		player=user.sName 
		SendToAll(botName, "Alright!, "..player.." just threw in a buck! Let's see what he can do ...") 
		SendToAll(botName, "started. Pull with !hit in Main Chat!") 
		SendToAll("Credits left : ",A) 
	elseif (cmd=="!hit") then 
		if (A == 0) then 
			OnOrOff="off" 
			SendToAll(botName, "Better insert a coin if you wanna play with me ...") 
		elseif (OnOrOff=="off") then 
			SendToAll(botName, "Better insert a coin if you wanna play with me ...") 
		elseif (OnOrOff=="on") then 
			if (player~=user.sName) then 
				SendToAll(botName, "Sorry "..user.sName.." you must wait until "..player.." is done with his round.") 
			elseif (player == user.sName) then 
				Pull()
				A=A-1
				SendToAll("\t...----------------o-0-o----------------...") 
				SendToAll("\t?        One-Armed-Bandit        ?") 
				SendToAll("\t?      >>>  "..Associate(first).."  -  "..Associate(second).."  -  "..Associate(third).."  <<<      ?") 
				SendToAll("\t"..first.." "..second.." "..third) 
				SendToAll("\t```----------------o-0-o----------------```" )

	Reward = { 	[1] = { [1] = "Cool " ..user.sName.. ", you just won 10 bucks!", ["bucks"] = 10}, 
			[2] = { [1] = "Great!! " ..user.sName.." 20 bucks for you!", ["bucks"] = 20},
			[3] = { [1] = user.sName..", just won 30 bucks...", ["bucks"] = 30},
			[4] = { [1] = "Wow! "..user.sName.." it must be your lucky day, 40 bucks!!", ["bucks"]=40},
			[5] = { [1] = "yeah!! " ..user.sName.." cha-ching 50 bucks!!!", ["bucks"] = 50},
			[6] = { [1] = "Woohoo!! " ..user.sName.." You're on a winning spree!! 70 bucks!!!", ["bucks"] = 70},
			[7] = { [1] = "Wow, you won 90 bucks " ..user.sName.."!!", ["bucks"] = 90},
			[8] = { [1] = "Awesome!! " ..user.sName.." You just hit the jackpot! cha-ching 100 bucks!!!", ["bucks"] = 100},
			[9] = { [1] = "Great!! " ..user.sName.." a buck for you!", ["bucks"] = 1},
		}
				for i, v in Reward do
					failed = 0  
					if (first == i) then
						if (second == i) then
							if (third == i) then	
								SendToAll( botName, Reward[i][1] )
								A = A + Reward[i]["bucks"]
								credit = credit + Reward[i]["bucks"]
								SendToAll("A : credit is "..credit.." because I added "..Reward[i]["bucks"])
								break
							elseif ( third ~= i ) then
								SendToAll( botName, Reward[9][1] )
								A = A + Reward[9]["bucks"]
								credit = credit + Reward[9]["bucks"]
								SendToAll("B : credit is "..credit.." because I added "..Reward[9]["bucks"])
								break
							end
						end
						if (second ~= i) then
							if (third == i) then	
								SendToAll( botName, Reward[9][1] )
								A = A + Reward[9]["bucks"]
								credit = credit + Reward[9]["bucks"]
								SendToAll("C : credit is "..credit.." because I added "..Reward[9]["bucks"] )
								break
							elseif (third ~= i) then failed = 1 end
						end
					end
					if ( first ~= i ) then
						if ( second == i ) then
							if ( third == i ) then
								SendToAll( botName, Reward[9][1] )
								A = A + Reward[9]["bucks"]
								credit = credit + Reward[9]["bucks"]
								SendToAll("D : credit is "..credit.." because I added "..Reward[9]["bucks"] )
								break
							elseif ( third ~= i ) then
								failed = 1
							end
						elseif (second ~= i ) then failed = 1 end
					end
				end
				if ( failed == 1 ) then SendToAll(botName,"Ahhh, too bad "..user.sName.." you won nothing...") end
				SendToAll("Credits left : ",A) 
				if ( A == 0) then 
					OnOrOff="off" 
					SendToAll(botName, "Outta credits, insert coin.") 
				end
				if (OnOrOff == "off") then IQuit(user, startT, A) end
			end 
		end 
	elseif (cmd == "!oknow") then
		if OnOrOff == "on" then
			OnOrOff="off" 
			if (credit ~= 0 ) then
				SendToAll(botName, user.sName.." has taken the money... He dont wanna play with me ...")
			else SendToAll(botName, user.sName.." is a quiter ...")
			end 
			IQuit(user, startT, A, "quit")
		end
	end		
end
end

function Associate(draw)
fruits = { [1] = "@", [2] = "$", [3] = "#", [4] = "&", [5] = "?", [6] = "O", [7] = "%", [8] = "?"}
local rollnum = ""
for i ,v in fruits do
	if i == draw then
		rollnum = v
	end
end
return rollnum
end

function Pull()
first = random(1,8) 
second = random(1,8) 
third = random(1,8) 
return first, second, third
end

function IQuit(user, startT, A, quit)
if (credit ~= 0) then 
	appendto("bandit_wins.txt") 
	if quit ~= nil then
		write( " \r\n - ? -"..user.sName.." won "..credit.." bucks - started playing at "..startT.." ended at "..date("%X ").." ? "..date("on %d/%m-%Y").." ? * quiter *") 
	else write( " \r\n - ? -"..user.sName.." won "..credit.." bucks - started playing at "..startT.." ended at "..date("%X ").." ? "..date("on %d/%m-%Y")) 
	end
	writeto() 
	credit = 0 
end 
appendto("bandit_plays.txt") 
if quit ~= nil then
	write("\r\n - ? -"..player.." - started playing at "..startT.." ended at "..date("%X ").." ? "..date("on %d/%m-%Y").." ? * quiter *") 
else write("\r\n - ? -"..player.." - started playing at "..startT.." ended at "..date("%X ").." ? "..date("on %d/%m-%Y")) 
end
writeto() 
end

SMF spam blocked by CleanTalk