Play Russian Roulette with others.
Up to 6 players can play at the same time.
And YES RussianText.txt is a complete rip off from one of Mutor's script, but atlest he is credited for it
Script can also be found on my site
The script can be improved (code cleaned), but atm i don't feel like doing it, maybe later, maybe never, or maybe someone else will do it
-- Russian Roulette Multi Edition
-- Another main spaming script
-- Made by Madman
-- Version: I lost track, script rewritten to many times ;p
-------------------------------------------------
-- Thanks to
-- Mutor 4 Text
-- All others in lua hub that has helped
-------------------------------------------------
-- Start of user settings
-------------------------------------------------
tConfig = {
["Bot"] = "RussianRoulette",
["TableFile"] = "RussianRoulette.dat",
["TextFile"] = "RussianText.txt",
}
-------------------------------------------------
-- End of user settings
-------------------------------------------------
-------------------------------------------------
-- Stuff done at script start
-------------------------------------------------
function Main()
-- Check for the table file
local file = io.open(tConfig.TableFile)
if file then
file:close()
if loadfile(tConfig.TableFile) then
dofile(tConfig.TableFile)
end
if loadfile(tConfig.TextFile) then
dofile(tConfig.TextFile)
end
if RussianRoulette["Players"] then
RussianRoulette["Players"] = nil -- Clear Players
SaveToFile(tConfig.TableFile,RussianRoulette,"RussianRoulette")
end
else-- We didn't find it, create it
local MakeFile = io.open(tConfig.TableFile, "w+")
MakeFile:write('RussianRoulette = {\n\t["Score"] = {\n\t},\n}')
MakeFile:close()
end
frmHub:RegBot(tConfig.Bot) -- Reg the bot
GameOn = nil
end
Sec = 1000
Min = 60*Sec
Hour = 60*Min
Day = 24*Hour
TmrFreq = 1*Sec
-------------------------------------------------
-- Timer...
-------------------------------------------------
function OnTimer()
local nr = 0
for i,_ in pairs(RussianRoulette["Players"]) do
nr = nr+1
end
if nr >= 2 then
SendToPlayers("Time is up, let the dying begin!")
SendToPlayers(RussianRoulette["Players"][1].. " takes the first shoot")
GameOn = 1
elseif nr <= 1 then
SendToPlayers("Game was not started, not enough people joined")
RussianRoulette["Players"] = nil
SaveToFile(tConfig.TableFile,RussianRoulette,"RussianRoulette")
end
StopTimer()
end
-------------------------------------------------
-- Msg to players
-------------------------------------------------
function SendToPlayers(Msg)
for _,nick in pairs(RussianRoulette["Players"]) do
SendToNick(nick,"<" ..tConfig.Bot.. "> " ..Msg)
end
end
-------------------------------------------------
-- Chat handling
-------------------------------------------------
function ChatArrival(curUser, data)
local data = string.sub(data, 1, -2)
local s,e,cmd = string.find(data, "%b<>%s+[%!%+%#%?](%S+)") -- Find cmd
if cmd then
local tCmds = {
["play_rr"] = function(curUser,data)
local nr = 1
if RussianRoulette["Players"] == nil then
RussianRoulette["Players"] = {}
SetTimer(30*Sec)
StartTimer()
SendToAll(tConfig.Bot, "30 Sec to game start, type !play_rr to join")
else
for i,v in pairs(RussianRoulette["Players"]) do
if v == curUser.sName then
curUser:SendData(tConfig.Bot, "You allready are in the game") return 1
end
nr = nr+1
end
end
if nr == 7 then -- max 6 players
curUser:SendData(tConfig.Bot, "Russian Roulette table is currentlt full")
else
RussianRoulette["Players"][nr] = curUser.sName
SaveToFile(tConfig.TableFile,RussianRoulette,"RussianRoulette")
SendToAll(tConfig.Bot, curUser.sName.. " has joined Russian Roulette table")
end
end,
["shoot"] = function(curUser,data)
if GameOn then
MaxPlayers = table.maxn(RussianRoulette["Players"])
if RussianRoulette["Shooter"] == nil then -- If shooter is nil
if curUser.sName == RussianRoulette["Players"][1] then -- if current user is first in table
local bang = { "die", "live", "die", "live", "live", "die" }
local shoot = bang[math.random(1,6)] -- Does user live or die?
if shoot == "die" then -- id die
local DeadMsg = string.gsub(Dead[math.random(table.maxn(Dead))], "%[user%]", curUser.sName) -- Get a msg from text file
SendToPlayers("Dead! "..DeadMsg) -- send msg
SendToPlayers("Next in line is: " ..RussianRoulette["Players"][2]) -- nr 2 can now play
RussianRoulette["Shooter"] = 2
RussianRoulette["Players"][1] = nil -- Remove user from table
SaveToFile(tConfig.TableFile,RussianRoulette,"RussianRoulette")
else
local AliveMsg = string.gsub(Alive[math.random(table.getn(Alive))], "%[user%]", curUser.sName)
SendToPlayers("Alive! "..AliveMsg) -- send msg
SendToPlayers("Next in line is: " ..RussianRoulette["Players"][2])
RussianRoulette["Shooter"] = 2
SaveToFile(tConfig.TableFile,RussianRoulette,"RussianRoulette")
end
local nr = 0
for i,nick in pairs(RussianRoulette["Players"]) do
I = i
nr = nr +1
Name = nick
end
if nr == 1 then
if RussianRoulette["Score"][Name] then
RussianRoulette["Score"][Name] = RussianRoulette["Score"][Name]+1
else
RussianRoulette["Score"][Name] = 1
end
SendToAll(tConfig.Bot, "And we have a survivor! " ..RussianRoulette["Players"][I].. " lives and scores 1 point, Total score: " ..RussianRoulette["Score"][Name])
RussianRoulette["Players"] = nil
RussianRoulette["Shooter"] = nil
SaveToFile(tConfig.TableFile,RussianRoulette,"RussianRoulette")
else
SendToPlayers("Next in line is: " ..RussianRoulette["Players"][Next])
end
SaveToFile(tConfig.TableFile,RussianRoulette,"RussianRoulette")
else
curUser:SendData(tConfig.Bot,"Not your turn")
end
else
Shooter = RussianRoulette["Shooter"]
if curUser.sName == RussianRoulette["Players"][Shooter] then
local bang = { "die", "live", "die", "live", "live", "die" }
local shoot = bang[math.random(1,6)] -- Does user live or die?
if shoot == "die" then
local DeadMsg = string.gsub(Dead[math.random(table.maxn(Dead))], "%[user%]", curUser.sName) -- Get a msg from text file
SendToPlayers("Dead! "..DeadMsg) -- dead msg...
if Shooter == MaxPlayers then -- if we reached end of table
for i=1,6 do -- loop it again
if RussianRoulette["Players"][i] ~= nil then -- until we get a player
Next = i -- It's player's turn
break -- stop the loop
end
end
else -- if we wasent at the end of table
Next = Shooter+1
end
RussianRoulette["Shooter"] = Next -- get next shooter
RussianRoulette["Players"][Shooter] = nil -- remove shooter
SaveToFile(tConfig.TableFile,RussianRoulette,"RussianRoulette")
else
local AliveMsg = string.gsub(Alive[math.random(table.getn(Alive))], "%[user%]", curUser.sName)
SendToPlayers("Alive! "..AliveMsg)
if Shooter == MaxPlayers then
for i=1,6 do
if RussianRoulette["Players"][i] ~= nil then
Next = i
break
end
end
else
Next = Shooter+1
end
RussianRoulette["Shooter"] = Next
SaveToFile(tConfig.TableFile,RussianRoulette,"RussianRoulette")
end
local nr = 0
for i,nick in pairs(RussianRoulette["Players"]) do
I = i
nr = nr +1
Name = nick
end
if nr == 1 then
if RussianRoulette["Score"][Name] then
RussianRoulette["Score"][Name] = RussianRoulette["Score"][Name]+1
else
RussianRoulette["Score"][Name] = 1
end
SendToAll(tConfig.Bot, "And we have a survivor! " ..RussianRoulette["Players"][I].. " lives and scores 1 point, Total score: " ..RussianRoulette["Score"][Name])
RussianRoulette["Players"] = nil
RussianRoulette["Shooter"] = nil
SaveToFile(tConfig.TableFile,RussianRoulette,"RussianRoulette")
else
SendToPlayers("Next in line is: " ..RussianRoulette["Players"][Next])
end
SaveToFile(tConfig.TableFile,RussianRoulette,"RussianRoulette")
else
curUser:SendData(tConfig.Bot,"Not your turn")
end
end
else
curUser:SendData(tConfig.Bot,"Game is not on, use !play_rr to join")
end
end,
["score_rr"] = function(curUser,data)
local index = {}
for nick,score in pairs(RussianRoulette["Score"]) do table.insert(index,nick) end
table.sort(index, function(a,b) return RussianRoulette["Score"][a] > RussianRoulette["Score"][b] end)
local msg = "\r\n\r\n\t\t" ..string.rep("-",50).. "\r\n\t\t\tTop 10 Survivor's\r\n\t\t" ..string.rep("-",50).. "\r\n\t\tPlace\tScore\tNick"
for I=1,10 do
if index[I] == nil then
break
else
msg = msg.."\r\n\t\t"..I..".\t"..RussianRoulette["Score"][index[I]].."\t"..index[I]
end
end
curUser:SendData(tConfig.Bot,msg)
end,
}
if tCmds[cmd] then
return tCmds[cmd](curUser,data),1
end
end
end
-------------------------------------------------
-- Serialize by nErBoS
-------------------------------------------------
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 pairs(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
RussianText.txt bellow
-- Add/Edit triggers as you like
Alive = {
" [user] are one lucky SOB.",
"Uh, you can breath now you made it [user].",
"The gods smile upon you, this day [user].",
"Nice job, and [user]'s mother said [user] were good for nothing.",
"[user] have survived. ....for now.",
"[user] should be dead right now, this game is rigged.",
"Damn! I thought at last we were through with [user].",
"[user] lived, but [user] is still a schmuck.",
}
Dead = {
"[user] dead, now whose gonna clean up this mess?.",
"[user] stone cold, Hell is ready to recieve [user].",
"Wow, [user]'s brains look great on this ivory wall.",
"What a loser, at least [user] died quickly.",
"[user] blue and cold, and let me guess, uninsured?",
"No [user] they ain't blanks, R.I.P. ....stupid.",
"[user]. It just goes to prove stupid people shouldn't breed.",
"Dammit [user]! Thanks for nothing ya stinking corpse, I just lost $20.",
"Well I'm out of here. I'll see [user] at [user]'s funeral.",
"Got Ya! Hopefully this is the last we see of [user]"
}