Slot Machine 1.1 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

Slot Machine 1.1 lua 5

Started by Dessamator, 20 May, 2005, 17:02:26

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dessamator

--## Slot Machine 1.1
--## Idea given by witch and requested by DJ-Valhala
--## Winner Anounce idea given by (UK)Ridaz
--## Fixed a Bug in Rank (thanks DJ-Valhala)
--## Made by nErBoS
--## lua 5 by Dessamator
--## Commands:
--##	+account	- Creates an account with your nick
--##	+status		- Show the Status of your account
--##	+rank		- Show the TOP10 of the Slot Machine Game
--##	+loan 	- Ask for more Credits to the Bank
--##	+repay 	- Repay the credits own to the Bank
--##	+play		- Play in the Slot Machine 

sBot = "Slot-Machine"

arrResults = {
	["BAR"] = 100,
	["7"] = 50,
	["@"] = 25,
	["$"] = 10,
	["?"] = 5,
	["?"] = 3,
	["&"] = 1,
}
arrAux = {
	100,
	50,
	25,
	10,
	5,
	3,
	1,
}
arrCredit = {}
fCredit = "credit.dat"

--## Configuration ##--

iCredit = 50		-- Number of Credits that user will have in the beginnig
iCreditPlay = 2		-- Number of Credits tha a user needs to play
iCreditLoan = 1000	-- Number of Credits that a user can loan

--## END ##--

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(fCredit)
end

function OnExit()
	SaveToFile(fCredit , arrCredit , "arrCredit")
end

function ChatArrival(user, data)
	data = string.sub(data,1,string.len(data)-1)
	s,e,cmd = string.find(data, "%b<>%s+(%S+)")
	if (cmd == "+account") then
		CreateAcount(user)
		return 1
	elseif(cmd == "+status") then
		SeeStatus(user)
		return 1
	elseif (cmd == "+rank") then
		SeeRanking(user)
		return 1
	elseif (cmd == "+loan") then
		LoanCredits(user, data)
		return 1
	elseif (cmd == "+repay") then
		RepayLoan(user, data)
		return 1
	elseif (cmd == "+play") then
		PlaySM(user)
		return 1
	end
end
function ToArrival(user,data)
	if (string.sub(data,1,5+string.len(sBot)) == "$To: "..sBot) then
		ChatArrival(user,data)
	end
end

function CreateAcount(user)
	if (arrCredit[user.sName] == nil) then
		arrCredit[user.sName] = {}
		arrCredit[user.sName]["Credit"] = iCredit
		arrCredit[user.sName]["Loan"] = 0
		user:SendPM(sBot, "You have been giving a account with 50 credits. Have FUN !!")
		if (uLaterPtokax == 1) then
			OnExit()
		end
	else
		user:SendPM(sBot, "You already have a acount, type +status to see yout account status.")
	end
end

function SeeStatus(user)
	local sTmp = ""
	if (arrCredit[user.sName] ~= nil) then
		sTmp = sTmp.."\t\t--## "..user.sName.." Account ##--\r\n\r\n"
		sTmp = sTmp.."\t\tYour Credit: "..arrCredit[user.sName]["Credit"].."\r\n"
		sTmp = sTmp.."\t\tYour have Loan: "..arrCredit[user.sName]["Loan"].."\r\n"
		sTmp = sTmp.."\t\tYour Position in the Ranking: "..UserPosition(user.sName).."\r\n"
	else
		sTmp = "You don't have an account, to create one type +account."
	end
	user:SendPM(sBot, sTmp)
end

function UserPosition(nick)
	local pos,count,tableAux,usr,aux,usrCount = 1,arrCredit[nick]["Credit"]-arrCredit[nick]["Loan"],{}
	for usr, aux in arrCredit do
		usrCount = arrCredit[usr]["Credit"]-arrCredit[usr]["Loan"]
		if (usr ~= nick and CheckMacth(tableAux,usrCount) == 0 and usrCount > count) then
			tableAux[usrCount] = 1
			pos = pos + 1
		end
	end
	tableAux = nil
	return pos
end

function CheckMacth(table, value)
	if (type(table) == "table") then
		local number,aux
		for number, aux in table do
			if (tonumber(number) == tonumber(value)) then
				return 1
			end
		end
	end
	return 0
end

function SeeRanking(user)
	local sTmp,pos,top,match,usr,aux = "The Top 10 Ranking of Slot Machine:\r\n\r\n",1,10,0
	if (NumberOfPlayers() == 0) then
		user:SendPM(sBot, "There aren't any players for the moment.")
		return 0
	elseif (NumberOfPlayers() < top) then
		top = tonumber(NumberOfPlayers())
	end
	while pos < top+1 do
		for usr, aux in arrCredit do
			if (pos == UserPosition(usr)) then
				if (match == 0) then
					sTmp = sTmp..pos
				end
				sTmp = sTmp.."\tNick: "..usr.."   --## Credit: "..arrCredit[usr]["Credit"].." Loan: "..arrCredit[usr]["Loan"].." ##--\r\n"
				match = 1
			end
		end
		match = 0
		pos = pos + 1
	end
	user:SendPM(sBot, sTmp)
end

function NumberOfPlayers()
	local count,usr,aux = 0
	for usr, aux in arrCredit do
		count = count + 1
	end
	return count
end

function LoanCredits(user, data)
	local s,e,credit = string.find(data, "%b<>%s+%S+%s+(%S+)")
	if (credit == nil or tonumber(credit) == nil) then
		user:SendPM(sBot, "Syntax Error, +loan , you must write a number in the credit.")
	elseif (arrCredit[user.sName] ~= nil) then
		if (arrCredit[user.sName]["Loan"] + tonumber(credit) > 1000) then
			user:SendPM(sBot, "You can't make any more loan you have obtain the max loan that is "..iCreditLoan.." Credits.")
		else
			arrCredit[user.sName]["Credit"] = arrCredit[user.sName]["Credit"] + tonumber(credit)
			arrCredit[user.sName]["Loan"] = arrCredit[user.sName]["Loan"] + tonumber(credit)
			user:SendPM(sBot, "You have been loan "..credit.." Credits.")
			if (uLaterPtokax == 1) then
				OnExit()
			end
		end
	else
		user:SendPM(sBot, "You don't have a acount, type +account to create one.")
	end
end

function RepayLoan(user, data)
	local s,e,credit = string.find(data, "%b<>%s+%S+%s+(%S+)")
	if (credit == nil or tonumber(credit) == nil) then
		user:SendPM(sBot, "Syntax Error, +repay , you must write a number in the credit.")
	elseif (arrCredit[user.sName] ~= nil) then
		if (tonumber(credit) > arrCredit[user.sName]["Loan"]) then
			user:SendPM(sBot, "You are repaying more then you own.")
		else
			arrCredit[user.sName]["Credit"] = arrCredit[user.sName]["Credit"] - tonumber(credit)
			arrCredit[user.sName]["Loan"] = arrCredit[user.sName]["Loan"] - tonumber(credit)
			user:SendPM(sBot, "You have repay "..credit.." Credits.")
			if (uLaterPtokax == 1) then
				OnExit()
			end
		end
	else
		user:SendPM(sBot, "You don't have a acount, type +account to create one.")
	end
end

function PlaySM(user)
	if (arrCredit[user.sName] ~= nil) then
		if (arrCredit[user.sName]["Credit"] < 2) then
			user:SendPM(sBot, "You don't have enough credits to play in Slot Machine. You need "..iCreditPlay.." Credits to play.")
		else
			local sSMDraw = ""
			sSMDraw = sSMDraw.."You have "..arrCredit[user.sName]["Credit"].." Credits\r\n\r\n"
			sSMDraw = sSMDraw.."\t	             _________\r\n"
			sSMDraw = sSMDraw.."\t	           /                   \\\r\n"
			sSMDraw = sSMDraw.."\t	          !  Good Luck  !\r\n"
			sSMDraw = sSMDraw.."\t	    ___!___________!___\r\n"
			sSMDraw = sSMDraw.."\t	  /                                    \\\r\n"
			sSMDraw = sSMDraw.."\t	/       SLOT MACHINE      \\\r\n"
			sSMDraw = sSMDraw.."\t	!    ________________      !\r\n"
			sSMDraw = sSMDraw.."\t	!   !          !          !           !    !\r\n" 
			local draw,won = DealGame()
			sSMDraw = sSMDraw..draw
			sSMDraw = sSMDraw.."\t	!   !_____!_____!_____ !    !\r\n"
			sSMDraw = sSMDraw.."\t	!                                          !\r\n"
			sSMDraw = sSMDraw.."\t	!                                          !\r\n"
			sSMDraw = sSMDraw.."\t	!            _________            !\r\n"
			sSMDraw = sSMDraw.."\t	!           !_________!           !\r\n"
			sSMDraw = sSMDraw.."\t	!                                          !\r\n"
			sSMDraw = sSMDraw.."\t	!_____________________!\r\n\r\n"
			if (tonumber(won) == arrResults["BAR"]) then
				JackPot(user)
			end
			arrCredit[user.sName]["Credit"] = arrCredit[user.sName]["Credit"] + tonumber(won) 
			arrCredit[user.sName]["Credit"] = arrCredit[user.sName]["Credit"] - iCreditPlay 
			sSMDraw = sSMDraw.."You have WON "..won.." Credits.\r\n"
			sSMDraw = sSMDraw.."Now you have "..arrCredit[user.sName]["Credit"].." Credits.\r\n"
			user:SendPM(sBot, sSMDraw)
			if (uLaterPtokax == 1) then
				OnExit()
			end
		end
	else
		user:SendPM(sBot, "You don't have a acount, type +account to create one.")
	end	
end

function JackPot(user)
	local sTmp = "\r\n\r\n*********************************************\r\n" 
	sTmp = sTmp.."J A C K P O T W I N N E R\r\n\r\n"  
	sTmp = sTmp..user.sName.." has just scooped the top prize of "..arrResults["BAR"].." Credits.\r\n\r\n" 
	sTmp = sTmp.."Why not join him by typing\r\n\r\n" 
	sTmp = sTmp.."+account - Creates an account with your nick\r\n"  
	sTmp = sTmp.."+status - Show the Status of your account\r\n"  
	sTmp = sTmp.."+rank - Show the TOP10 of the Slot Machine Game\r\n"  
	sTmp = sTmp.."+loan  - Ask for more Credits to the Bank\r\n"  
	sTmp = sTmp.."+repay  - Repay the credits own to the Bank\r\n"  
	sTmp = sTmp.."+play - Play in the Slot Machine\r\n"  
	sTmp = sTmp.."*********************************************\r\n" 
	SendToAll(sBot, sTmp)
end 

function DealGame()
	local play1,play2,play3,draw,won = arrAux[math.random(1, table.getn(arrAux))],arrAux[math.random(1, table.getn(arrAux))],arrAux[math.random(1, table.getn(arrAux))],""
	draw = draw.."\t	!   ! "..DrawSimbol(play1).." ! "..DrawSimbol(play2).."  ! "..DrawSimbol(play3).."  !    !\r\n"
	if (tonumber(play1) == tonumber(play2) and tonumber(play1) == tonumber(play3)) then
		return draw,play1
	elseif (tonumber(play1) == tonumber(play2) or tonumber(play2) == tonumber(play3)) then
		return draw,iCreditPlay
	else
		return draw,0
	end
end
	
function DrawSimbol(number)
	number = tonumber(number)
	if (number == 100) then
		return "BAR"	
	elseif (number == 25) then
		return "  @  "
	elseif (number == 5) then
		return "   ?  "
	elseif (number == 50) then
		return "   7   "
	elseif (number == 10) then
		return "   $  "
	elseif (number == 1) then
		return "   &   "
	else
		local simbol,num
		for simbol, num in arrResults do
			if (tonumber(num) == number) then
				return "   "..simbol.."   "
			end
		end
	end
end

function Serialize(tTable, sTableName, sTab)
        assert(tTable, "tTable equals nil");
        assert(sTableName, "sTableName equals nil");

        assert(type(tTable) == "table", "tTable must be a table!");
        assert(type(sTableName) == "string", "sTableName must be a string!");

        sTab = sTab or "";
        sTmp = ""

        sTmp = sTmp..sTab..sTableName.." = {\n"

        for key, value in tTable do
                local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);

                if(type(value) == "table") then
                        sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
                else
                        local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
                        sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
                end

                sTmp = sTmp..",\n"
        end

        sTmp = sTmp..sTab.."}"
        return sTmp
end

function SaveToFile(file , table , tablename)
	local handle = io.open(file,"w+")
        handle:write(Serialize(table, tablename))
	handle:flush()
        handle:close()
end
function LoadFromFile(file)
local handle = io.open(file,"r")
        if (handle ~= nil) then
                dofile(file)
handle:flush()
handle:close()
        end

end
Ignorance is Bliss.

TommyGun

#1
http://members.lycos.nl/gamerguntk/uploads/slots/error.PNG

I made a account with +account

When i say +loan he says that i need to give a number. So i do (example) +loan 100 but it does nothing. The text is just in the main chat. And +rank is the same, just stands in the main chat and i dont get the rank or something in private.

Hope you guys understand

:)

But looking good!
My computer specifications :: http://tweakers.net/gallery/sys/9478

Anna

I dont get that error when trying thoose commands...

the user doin the commands, does he/she have an account (+account)?

if not that could be part of problem, I've only tested when having an account

Dessamator

indeed, what command did u use, i have to know it in order to fix it,  :]
Ignorance is Bliss.

TommyGun

I made a account with +account

When i say +loan he says that i need to give a number. So i do (example) +loan 100 but it does nothing. The text is just in the main chat. And +rank is the same, just stands in the main chat and i dont get the rank or something in private.

Hope you guys understand
My computer specifications :: http://tweakers.net/gallery/sys/9478

Dessamator

ok thnx ill check it out  ;)
Ignorance is Bliss.

Dessamator

#6
i tried that, no errors here !, im gonna test it a bit more !

works fine :

Quote21:59] +account
[21:59] You have been giving a account with 50 credits. Have FUN !!
[21:59] +play
[21:59] You have 50 Credits

                   _________
                 /                   \
                !  Good Luck  !
          ___!___________!___
        /                                    \
      /       SLOT MACHINE      \
      !    ________________      !
      !   !          !          !           !    !
      !   !    &    ! BAR  ! BAR  !    !
      !   !_____!_____!_____ !    !
      !                                          !
      !                                          !
      !            _________            !
      !           !_________!           !
      !                                          !
      !_____________________!

You have WON 2 Credits.
Now you have 50 Credits.
i see that ur using chatstats, that script can be buggy sometimes try moving the slotbar in the script order upwards( put it as the first),

Good Luck !!
Ignorance is Bliss.

TommyGun

#7
The +stats and +loan still doesnt work here. Strange...

It's on #1 in my script editor

205: attempt to concatentate field 'Loan' (a nil value)

Didnt get an error this time with +stats :S
My computer specifications :: http://tweakers.net/gallery/sys/9478

gemini

it's possible reset or restart account
it's possible with commands slot machine zright clicker
thanks

Dessamator

QuoteOriginally posted by TommyGun
The +stats and +loan still doesnt work here. Strange...

It's on #1 in my script editor

205: attempt to concatentate field 'Loan' (a nil value)

Didnt get an error this time with +stats :S

no errors here, and its not +stats , +stats is a default ptokax command for viewing statistics

and to gemini, ill see what i can do :)
Ignorance is Bliss.

Dessamator

#10
--## Slot Machine 1.1
--## Idea given by witch and requested by DJ-Valhala
--## Winner Anounce idea given by (UK)Ridaz
--## Fixed a Bug in Rank (thanks DJ-Valhala)
--## Made by nErBoS
--## lua 5 by Dessamator
--## Commands:
--##	+account	- Creates an account with your nick
--##	+status		- Show the Status of your account
--##	+rank		- Show the TOP10 of the Slot Machine Game
--##	+loan 	- Ask for more Credits to the Bank
--##	+repay 	- Repay the credits own to the Bank
--##	+play		- Play in the Slot Machine 
--##	+reset		- Reset account

sBot = "Slot-Machine"

arrResults = {
	["BAR"] = 100,
	["7"] = 50,
	["@"] = 25,
	["$"] = 10,
	["?"] = 5,
	["?"] = 3,
	["&"] = 1,
}
arrAux = {
	100,
	50,
	25,
	10,
	5,
	3,
	1,
}
arrCredit = {}
fCredit = "credit.dat"

--## Configuration ##--

iCredit = 50		-- Number of Credits that user will have in the beginnig
iCreditPlay = 2		-- Number of Credits tha a user needs to play
iCreditLoan = 1000	-- Number of Credits that a user can loan

--## END ##--

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(fCredit)
end

function OnExit()
	SaveToFile(fCredit , arrCredit , "arrCredit")
end

function ChatArrival(user, data)
	data = string.sub(data,1,string.len(data)-1)
	s,e,cmd = string.find(data, "%b<>%s+(%S+)")
	if (cmd == "+account") then
		CreateAcount(user)
		return 1
	elseif(cmd == "+status") then
		SeeStatus(user)
		return 1
	elseif (cmd == "+rank") then
		SeeRanking(user)
		return 1
	elseif (cmd == "+loan") then
		LoanCredits(user, data)
		return 1
	elseif (cmd == "+repay") then
		RepayLoan(user, data)
		return 1
	elseif (cmd == "+play") then
		PlaySM(user)
		return 1
	elseif (cmd=="+reset") then
		arrCredit[user.sName]["Credit"] = 0
		arrCredit[user.sName]["Loan"] = 0
		user:SendPM(sBot,"Your Account has been reset")
	end
end
function ToArrival(user,data)
	if (string.sub(data,1,5+string.len(sBot)) == "$To: "..sBot) then
		ChatArrival(user,data)
	end
end

function CreateAcount(user)
	if (arrCredit[user.sName] == nil) then
		arrCredit[user.sName] = {}
		arrCredit[user.sName]["Credit"] = iCredit
		arrCredit[user.sName]["Loan"] = 0
		user:SendPM(sBot, "You have been giving a account with 50 credits. Have FUN !!")
		if (uLaterPtokax == 1) then
			OnExit()
		end
	else
		user:SendPM(sBot, "You already have a acount, type +status to see yout account status.")
	end
end

function SeeStatus(user)
	local sTmp = ""
	if (arrCredit[user.sName] ~= nil) then
		sTmp = sTmp.."\t\t--## "..user.sName.." Account ##--\r\n\r\n"
		sTmp = sTmp.."\t\tYour Credit: "..arrCredit[user.sName]["Credit"].."\r\n"
		sTmp = sTmp.."\t\tYour have Loan: "..arrCredit[user.sName]["Loan"].."\r\n"
		sTmp = sTmp.."\t\tYour Position in the Ranking: "..UserPosition(user.sName).."\r\n"
	else
		sTmp = "You don't have an account, to create one type +account."
	end
	user:SendPM(sBot, sTmp)
end

function UserPosition(nick)
	local pos,count,tableAux,usr,aux,usrCount = 1,arrCredit[nick]["Credit"]-arrCredit[nick]["Loan"],{}
	for usr, aux in arrCredit do
		usrCount = arrCredit[usr]["Credit"]-arrCredit[usr]["Loan"]
		if (usr ~= nick and CheckMacth(tableAux,usrCount) == 0 and usrCount > count) then
			tableAux[usrCount] = 1
			pos = pos + 1
		end
	end
	tableAux = nil
	return pos
end

function CheckMacth(table, value)
	if (type(table) == "table") then
		local number,aux
		for number, aux in table do
			if (tonumber(number) == tonumber(value)) then
				return 1
			end
		end
	end
	return 0
end

function SeeRanking(user)
	local sTmp,pos,top,match,usr,aux = "The Top 10 Ranking of Slot Machine:\r\n\r\n",1,10,0
	if (NumberOfPlayers() == 0) then
		user:SendPM(sBot, "There aren't any players for the moment.")
		return 0
	elseif (NumberOfPlayers() < top) then
		top = tonumber(NumberOfPlayers())
	end
	while pos < top+1 do
		for usr, aux in arrCredit do
			if (pos == UserPosition(usr)) then
				if (match == 0) then
					sTmp = sTmp..pos
				end
				sTmp = sTmp.."\tNick: "..usr.."   --## Credit: "..arrCredit[usr]["Credit"].." Loan: "..arrCredit[usr]["Loan"].." ##--\r\n"
				match = 1
			end
		end
		match = 0
		pos = pos + 1
	end
	user:SendPM(sBot, sTmp)
end

function NumberOfPlayers()
	local count,usr,aux = 0
	for usr, aux in arrCredit do
		count = count + 1
	end
	return count
end

function LoanCredits(user, data)
	local s,e,credit = string.find(data, "%b<>%s+%S+%s+(%S+)")
	if (credit == nil or tonumber(credit) == nil) then
		user:SendPM(sBot, "Syntax Error, +loan , you must write a number in the credit.")
	elseif (arrCredit[user.sName] ~= nil) then
		if (arrCredit[user.sName]["Loan"] + tonumber(credit) > 1000) then
			user:SendPM(sBot, "You can't make any more loan you have obtain the max loan that is "..iCreditLoan.." Credits.")
		else
			arrCredit[user.sName]["Credit"] = arrCredit[user.sName]["Credit"] + tonumber(credit)
			arrCredit[user.sName]["Loan"] = arrCredit[user.sName]["Loan"] + tonumber(credit)
			user:SendPM(sBot, "You have been loan "..credit.." Credits.")
			if (uLaterPtokax == 1) then
				OnExit()
			end
		end
	else
		user:SendPM(sBot, "You don't have a acount, type +account to create one.")
	end
end

function RepayLoan(user, data)
	local s,e,credit = string.find(data, "%b<>%s+%S+%s+(%S+)")
	if (credit == nil or tonumber(credit) == nil) then
		user:SendPM(sBot, "Syntax Error, +repay , you must write a number in the credit.")
	elseif (arrCredit[user.sName] ~= nil) then
		if (tonumber(credit) > arrCredit[user.sName]["Loan"]) then
			user:SendPM(sBot, "You are repaying more then you own.")
		else
			arrCredit[user.sName]["Credit"] = arrCredit[user.sName]["Credit"] - tonumber(credit)
			arrCredit[user.sName]["Loan"] = arrCredit[user.sName]["Loan"] - tonumber(credit)
			user:SendPM(sBot, "You have repay "..credit.." Credits.")
			if (uLaterPtokax == 1) then
				OnExit()
			end
		end
	else
		user:SendPM(sBot, "You don't have a acount, type +account to create one.")
	end
end

function PlaySM(user)
	if (arrCredit[user.sName] ~= nil) then
		if (arrCredit[user.sName]["Credit"] < 2) then
			user:SendPM(sBot, "You don't have enough credits to play in Slot Machine. You need "..iCreditPlay.." Credits to play.")
		else
			local sSMDraw = ""
			sSMDraw = sSMDraw.."You have "..arrCredit[user.sName]["Credit"].." Credits\r\n\r\n"
			sSMDraw = sSMDraw.."\t	             _________\r\n"
			sSMDraw = sSMDraw.."\t	           /                   \\\r\n"
			sSMDraw = sSMDraw.."\t	          !  Good Luck  !\r\n"
			sSMDraw = sSMDraw.."\t	    ___!___________!___\r\n"
			sSMDraw = sSMDraw.."\t	  /                                    \\\r\n"
			sSMDraw = sSMDraw.."\t	/       SLOT MACHINE      \\\r\n"
			sSMDraw = sSMDraw.."\t	!    ________________      !\r\n"
			sSMDraw = sSMDraw.."\t	!   !          !          !           !    !\r\n" 
			local draw,won = DealGame()
			sSMDraw = sSMDraw..draw
			sSMDraw = sSMDraw.."\t	!   !_____!_____!_____ !    !\r\n"
			sSMDraw = sSMDraw.."\t	!                                          !\r\n"
			sSMDraw = sSMDraw.."\t	!                                          !\r\n"
			sSMDraw = sSMDraw.."\t	!            _________            !\r\n"
			sSMDraw = sSMDraw.."\t	!           !_________!           !\r\n"
			sSMDraw = sSMDraw.."\t	!                                          !\r\n"
			sSMDraw = sSMDraw.."\t	!_____________________!\r\n\r\n"
			if (tonumber(won) == arrResults["BAR"]) then
				JackPot(user)
			end
			arrCredit[user.sName]["Credit"] = arrCredit[user.sName]["Credit"] + tonumber(won) 
			arrCredit[user.sName]["Credit"] = arrCredit[user.sName]["Credit"] - iCreditPlay 
			sSMDraw = sSMDraw.."You have WON "..won.." Credits.\r\n"
			sSMDraw = sSMDraw.."Now you have "..arrCredit[user.sName]["Credit"].." Credits.\r\n"
			user:SendPM(sBot, sSMDraw)
			if (uLaterPtokax == 1) then
				OnExit()
			end
		end
	else
		user:SendPM(sBot, "You don't have a acount, type +account to create one.")
	end	
end

function JackPot(user)
	local sTmp = "\r\n\r\n*********************************************\r\n" 
	sTmp = sTmp.."J A C K P O T W I N N E R\r\n\r\n"  
	sTmp = sTmp..user.sName.." has just scooped the top prize of "..arrResults["BAR"].." Credits.\r\n\r\n" 
	sTmp = sTmp.."Why not join him by typing\r\n\r\n" 
	sTmp = sTmp.."+account - Creates an account with your nick\r\n"  
	sTmp = sTmp.."+status - Show the Status of your account\r\n"  
	sTmp = sTmp.."+rank - Show the TOP10 of the Slot Machine Game\r\n"  
	sTmp = sTmp.."+loan  - Ask for more Credits to the Bank\r\n"  
	sTmp = sTmp.."+repay  - Repay the credits own to the Bank\r\n"  
	sTmp = sTmp.."+play - Play in the Slot Machine\r\n"  
	sTmp = sTmp.."*********************************************\r\n" 
	SendToAll(sBot, sTmp)
end 

function DealGame()
	local play1,play2,play3,draw,won = arrAux[math.random(1, table.getn(arrAux))],arrAux[math.random(1, table.getn(arrAux))],arrAux[math.random(1, table.getn(arrAux))],""
	draw = draw.."\t	!   ! "..DrawSimbol(play1).." ! "..DrawSimbol(play2).."  ! "..DrawSimbol(play3).."  !    !\r\n"
	if (tonumber(play1) == tonumber(play2) and tonumber(play1) == tonumber(play3)) then
		return draw,play1
	elseif (tonumber(play1) == tonumber(play2) or tonumber(play2) == tonumber(play3)) then
		return draw,iCreditPlay
	else
		return draw,0
	end
end
	
function DrawSimbol(number)
	number = tonumber(number)
	if (number == 100) then
		return "BAR"	
	elseif (number == 25) then
		return "  @  "
	elseif (number == 5) then
		return "   ?  "
	elseif (number == 50) then
		return "   7   "
	elseif (number == 10) then
		return "   $  "
	elseif (number == 1) then
		return "   &   "
	else
		local simbol,num
		for simbol, num in arrResults do
			if (tonumber(num) == number) then
				return "   "..simbol.."   "
			end
		end
	end
end

function Serialize(tTable, sTableName, sTab)
        assert(tTable, "tTable equals nil");
        assert(sTableName, "sTableName equals nil");

        assert(type(tTable) == "table", "tTable must be a table!");
        assert(type(sTableName) == "string", "sTableName must be a string!");

        sTab = sTab or "";
        sTmp = ""

        sTmp = sTmp..sTab..sTableName.." = {\n"

        for key, value in tTable do
                local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);

                if(type(value) == "table") then
                        sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
                else
                        local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
                        sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
                end

                sTmp = sTmp..",\n"
        end

        sTmp = sTmp..sTab.."}"
        return sTmp
end

function SaveToFile(file , table , tablename)
	local handle = io.open(file,"w+")
        handle:write(Serialize(table, tablename))
	handle:flush()
        handle:close()
end
function LoadFromFile(file)
local handle = io.open(file,"r")
        if (handle ~= nil) then
                dofile(file)
handle:flush()
handle:close()
        end

end

done
as for right clicks u can do it urself, search the howto section to learn how to do so!
Ignorance is Bliss.

TommyGun

QuoteOriginally posted by Dessamator
QuoteOriginally posted by TommyGun
The +stats and +loan still doesnt work here. Strange...

It's on #1 in my script editor

205: attempt to concatentate field 'Loan' (a nil value)

Didnt get an error this time with +stats :S

no errors here, and its not +stats , +stats is a default ptokax command for viewing statistics

and to gemini, ill see what i can do :)

I mean +rank.

I think it just cant work togheter with the chatstats script :(
My computer specifications :: http://tweakers.net/gallery/sys/9478

Dessamator

have u tried disabling the  chatstats?, either way, post ur chatstats here, and ill test it with both scripts !
Ignorance is Bliss.

TommyGun

No i did not turned it off....

But i got 4 scripts running:

RoboCop
TriviaBOT
ChatStats
AccountManager

Thanks :)
My computer specifications :: http://tweakers.net/gallery/sys/9478

Dessamator

i tried it with all those scripts on, and it worked perfectly !!, you obviously changed something there, that caused that error!
Ignorance is Bliss.

TommyGun

Very strange. I did not change anything. I downloaded it again and the problem is still coming back! Im getting crazy? Thanks for your help.
My computer specifications :: http://tweakers.net/gallery/sys/9478

Dessamator

#16
hmm, i even tested it with ur ptokax version 17.03, and it worked, the only thing i can think of, is that somehow ur credit.dat file has some error in it,
first of all open the credit.dat(it should be in ur scripts folder), and paste its contents here !

after that do the following,
1.Stop the script : slotmachine
2.delete the file : credit.dat
3. Start  the script !

Hope it helps!
Ignorance is Bliss.

gemini

thanks
Dessamator  :))

Dessamator

Ignorance is Bliss.

TommyGun

QuoteOriginally posted by Dessamator
hmm, i even tested it with ur ptokax version 17.03, and it worked, the only thing i can think of, is that somehow ur credit.dat file has some error in it,
first of all open the credit.dat(it should be in ur scripts folder), and paste its contents here !

after that do the following,
1.Stop the script : slotmachine
2.delete the file : credit.dat
3. Start  the script !

Hope it helps!

I will try tonight!
My computer specifications :: http://tweakers.net/gallery/sys/9478

Dessamator

Ignorance is Bliss.

TommyGun

#21
Upgraded to 17.08 (PtokaX) and it works!

But sometimes, i get this:

http://members.lycos.nl/gamerguntk/uploads/4/lol.PNG

Strange :)
My computer specifications :: http://tweakers.net/gallery/sys/9478

Dessamator

#22
goody,
btw the second error was caused by the code board , change this:
[code]arrResults = {

["BAR"] = 100,
["7"] = 50,
["@"] = 25,
["$"] = 10,
["?"] = 5,
["€"] = 3,
["&"] = 1,

}
to this :

arrResults = {
["BAR"] = 100,
["7"] = 50,
["@"] = 25,
["$"] = 10,
["?"] = 5,
["?"] = 3,
["&"] = 1,

}
Ignorance is Bliss.

TommyGun

I love you man :D
My computer specifications :: http://tweakers.net/gallery/sys/9478

Dessamator

QuoteOriginally posted by TommyGun
I love you man :D

lool, im guessing that it worked, btw save the love for the women they need it more than i do!
and...

ur welcome, :)
Ignorance is Bliss.

SMF spam blocked by CleanTalk