--=[ Nome do Bot ]=-
botName = "??ec?rit?-??t?"
sOpChatName = "???Ch?t?"
--=[ Comando ]=-
Command = "!slots"
--=[ Codigo ]=--
function getid(Table, name)
return table.foreachi(Table, function(id, item) if item.sName == name then return id end end)
end
function putitem(Table, item)
if not item then
return
end
local id = getid(Table, item.sName)
if id then
Table[id] = item
else
table.insert(Table, item)
id = Table.n
end
return id
end
function OnTimer()
local i = 1 while tabSlots[i] do
local Table = tabSlots[i]
if os.clock() >= Table.iClock + tmrSlots then
if Table.tItems.n == 0 then
SendPmToNick(Table.sName, botName, " ? N?o a users com slots livres no hub ? |")
end
SendPmToNick(Table.sName, botName, " ? Feito ?|")
table.remove(tabSlots, i)
if tabSlots.n == 0 then
end
else i = i + 1
end
end
end
function doSlots(user, nr, nick)
user:SendPM(botName, " ? A procurar... ? |")
SendToAll(botName, " -=[ A enviar informa??o do comando !slots a um Utilizador ]=- ")
SendPmToOps(sOpChatName, " -=[ A enviar informa??o do comando !slots ao Utilizador "..user.sName.." ]=- ")
SendToAll("$Search Hub:"..Command.." T?F?0?1?.|")
putitem(tabSlots, { sName = user.sName, iClock = os.clock(), iNR = nr, tItems = {n=0} })
end
tmrSlots = 5
tabSlots = {n=0}
function ChatArrival(user, data)
if string.find(data, "%b<>%s+("..Command..").*|") then
s, e, nr = string.find(data, "%b<>%s+"..Command.."%s+([0-9]+)")
if s then
nr = tonumber(nr)
else
nr = 1
end
doSlots(user, nr)
return 1
end
end
function SRArrival(user, data)
local s, e, free, all = string.find(data, " (%d+)/(%d+)"..string.char(5))
table.foreachi(tabSlots, function(id, item)
if not getid(item.tItems, user.sName) then
putitem(item.tItems, { sName = user.sName, sValue = free.."/"..all })
if (tonumber(free) >= item.iNR) then
SendPmToNick(item.sName, botName, " ? User ? ? "..user.sName.." ? ? "..free.."/"..all.." ?|")
end
end end)
end
function Main()
frmHub:RegBot(botName)
SetTimer(tmrSlots*1000)
StartTimer()
end
Hi. its possible convert this script for ptokax 4.1.1?
Just for try my old script ::)
Ok m8. i understand.
Sory about script credits :(