hello ppl i need a tranlation on that script ....
to english
--## OpChat Modificado
--## Feito por nErBoS
--## Comandos para OPs:
--## +invite -- Convida um utilizador para participar no OpChat
--## +delinvite -- Retira o convite de participar no OpChat a um utilizador
--## +invitelist -- Mostra a lista de utilizadores convidados a falar no OpChat
--## +talklog -- Mostra a conversa que houve no OpChat na sua ausencia
sOpChat = "OpChat"
arrInvite = {}
arrLog = {}
fInvite = "invite.dat"
fLog = "log.dat"
--## Configura??o ##--
uLaterPtokax = 1 -- 0 se tiveres a usar a vers?o do Ptokax 0.3.3.0 ou superior
-- 1 se tiveres a usar uma vers?o de Ptokax abaixo da 0.3.3.0
arrOpLevel = { --Coloque nesta tabela o nome de "profile" com privilegios de OP e o seu corresponde numero
["Master"] = 0,
["Operator"] = 1,
["Moderator"] = 4,
["NetFounder"] = 5,
}
--## FIM ##--
function Main()
frmHub:RegBot(sOpChat)
frmHub:EnableFullData(1)
LoadFromFile(fInvite)
LoadFromFile(fLog)
Refresh()
end
function OnExit()
SaveToFile(fInvite , arrInvite , "arrInvite")
SaveToFile(fLog , arrLog , "arrLog")
end
function OpConnected(user)
if (arrLog[user.sName] == nil) then
Refresh()
elseif (arrLog[user.sName]["Talk"] ~= "") then
user:SendPM(sBot, "Houve conversa no OpChat na tua aus?ncia. Escreve +talklog para a leres.")
end
arrLog[user.sName]["Mode"] = "online"
end
function OpDisconnected(user)
arrLog[user.sName]["Mode"] = "offline"
end
function DataArrival(user, data)
if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sOpChat)) == "$To: "..sOpChat) then
data = strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd == "+invite" and user.bOperator) then
InviteUser(user, data)
return 1
elseif (cmd == "+delinvite" and user.bOperator) then
RemoveInvite(user, data)
return 1
elseif (cmd == "+invitelist" and user.bOperator) then
InviteList(user)
return 1
elseif (cmd == "+talklog" and user.bOperator) then
ShowTalkLog(user)
return 1
end
end
if (strsub(data,1,5+strlen(sOpChat)) == "$To: "..sOpChat) then
if (user.bOperator or arrInvite[strlower(user.sName)] ~= nil) then
SendTalkToOps(data)
SendTalkToInvited(data)
return 1
else
user:SendPM(sBot, "N?o podes falar no OpChat.")
return 1
end
end
end
function InviteUser(user, data)
local s,e,nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (nick == nil) then
user:SendPM(sOpChat, "Syntax Erro, +invite . Tens de escrever um nick.")
elseif (arrInvite[strlower(nick)] ~= nil) then
user:SendPM(sOpChat, "O utilizador "..nick.." j? se encontra convidado para falar no OpChat.")
else
arrInvite[strlower(nick)] = user.sName
user:SendPM(sOpChat, "O utilizador "..nick.." foi convidado a falar no OpChat.")
if (GetItemByName(nick) ~= nil) then
GetItemByName(nick):SendPM(sOpChat, "Foste convidado para falar no OpChat pelo Operador "..user.sName)
end
SendPmToOps(sOpChat, "O utilizador "..nick.." foi convidado a falar no OpChat pelo Operador "..user.sName)
if (uLaterPtokax == 1) then
SaveToFile(fInvite , arrInvite , "arrInvite")
end
end
end
function RemoveInvite(user, data)
local s,e,nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (nick == nil) then
user:SendPM(sOpChat, "Syntax Erro, +delinvite . Tens de escrever um nick.")
elseif (arrInvite[strlower(nick)] == nil) then
user:SendPM(sOpChat, "O utilizador "..nick.." n?o se encontra convidado para falar no OpChat.")
else
arrInvite[strlower(nick)] = nil
user:SendPM(sOpChat, "O utilizador "..nick.." j? n?o se encontra convidado a falar no OpChat.")
if (GetItemByName(nick) ~= nil) then
GetItemByName(nick):SendPM(sOpChat, "O convite para falar no OpChat for removido pelo Operador "..user.sName)
end
SendPmToOps(sOpChat, "Ao utilizador "..nick.." foi lhe removido o convite para falar no OpChat pelo Operador "..user.sName)
if (uLaterPtokax == 1) then
SaveToFile(fInvite , arrInvite , "arrInvite")
end
end
end
function InviteList(user)
local sTmp,op,usr = "Lista de utilizadores convidados para falar no OpChat:\r\n\r\n"
for usr, op in arrInvite do
sTmp = sTmp.."Utilizador: "..usr.."\tConvidado por: "..op.."\r\n"
end
user:SendPM(sBot, sTmp)
end
function SendTalkToOps(data)
local s,e,from,talk = strfind(data, "$To:%s+%S+%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
local aux,profile,usr
if (from ~= nil and talk ~= nil) then
SaveToLog(from, talk)
for aux, profile in GetProfiles() do
for aux, usr in GetUsersByProfile(profile) do
if (GetItemByName(usr) ~= nil and GetItemByName(usr).bOperator and GetItemByName(usr).sName ~= from) then
SendToNick(GetItemByName(usr).sName, "$To: "..GetItemByName(usr).sName.." From: "..sOpChat.." $<"..from.."> "..talk)
end
end
end
end
end
function SendTalkToInvited(data)
local s,e,from,talk = strfind(data, "$To:%s+%S+%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
local aux,usr
if (from ~= nil and talk ~= nil) then
for usr, aux in arrInvite do
if (GetItemByName(usr) ~= nil and GetItemByName(usr).sName ~= from) then
SendToNick(GetItemByName(usr).sName, "$To: "..GetItemByName(usr).sName.." From: "..sOpChat.." $<"..from.."> "..talk)
end
end
end
end
function Refresh()
local aux,aux2,usr,profile
for profile, aux in arrOpLevel do
for aux2, usr in GetUsersByProfile(profile) do
if (arrLog[usr] == nil) then
arrLog[usr] = {}
if (GetItemByName(usr) == nil) then
arrLog[usr]["Mode"] = "offline"
else
arrLog[usr]["Mode"] = "online"
end
arrLog[usr]["Talk"] = ""
elseif (GetItemByName(usr) == nil) then
arrLog[usr]["Mode"] = "offline"
else
arrLog[usr]["Mode"] = "online"
end
end
end
if (uLaterPtokax == 1) then
SaveToFile(fLog , arrLog , "arrLog")
end
end
function SaveToLog(from, talk)
local usr,aux
for usr, aux in arrLog do
if (arrLog[usr]["Mode"] == "offline") then
arrLog[usr]["Talk"] = arrLog[usr]["Talk"].."<"..from.."> "..talk.."\r\n"
end
end
if (uLaterPtokax == 1) then
SaveToFile(fLog , arrLog , "arrLog")
end
end
function ShowTalkLog(user)
if (arrLog[user.sName]["Talk"] == "") then
user:SendPM(sOpChat, "N?o existe mais nenhuma conversa no OpChat em que n?o estivesse presente.")
else
user:SendPM(sOpChat, "Conversa que houve no OpChat na sua ausencia:\r\n\r\n"..arrLog[user.sName]["Talk"])
user:SendPM(sOpChat, "O log foi limpo.")
arrLog[user.sName]["Talk"] = ""
if (uLaterPtokax == 1) then
SaveToFile(fLog , arrLog , "arrLog")
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 format("[%q]",key) or format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and 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)
writeto(file)
write(Serialize(table, tablename))
writeto()
end
function LoadFromFile(file)
if (readfrom(file) ~= nil) then
readfrom(file)
dostring(read("*all"))
readfrom()
end
end
still need help to translate that script
That should work:--## OpChat Modified
--## Made by nErBoS
--## Commands for OPs:
--## +invite -- Invite a user to participate in the OpChat
--## +delinvite -- Delete an invitation
--## +invitelist -- Show a list of users invited to the OpChat
--## +talklog -- Shows the conversations that took place in the OpChat while you were away
sOpChat = "OpChat"
arrInvite = {}
arrLog = {}
fInvite = "invite.dat"
fLog = "log.dat"
--## Configuration ##--
uLaterPtokax = 1 -- Use 0 if your hub is running Ptokax 0.3.3.0 or higher
-- Use 1 if your hub is running Ptokax lower than v. 0.3.3.0
arrOpLevel = { --This table holds the profile names with OP privileges and their corresponding number
["Master"] = 0,
["Operator"] = 1,
["Moderator"] = 4,
["NetFounder"] = 5,
}
--## END ##--
function Main()
frmHub:RegBot(sOpChat)
frmHub:EnableFullData(1)
LoadFromFile(fInvite)
LoadFromFile(fLog)
Refresh()
end
function OnExit()
SaveToFile(fInvite , arrInvite , "arrInvite")
SaveToFile(fLog , arrLog , "arrLog")
end
function OpConnected(user)
if (arrLog[user.sName] == nil) then
Refresh()
elseif (arrLog[user.sName]["Talk"] ~= "") then
user:SendPM(sBot, "There was conversation on the OpChat while you were away. Type +talklog to read what was said.")
end
arrLog[user.sName]["Mode"] = "online"
end
function OpDisconnected(user)
arrLog[user.sName]["Mode"] = "offline"
end
function DataArrival(user, data)
if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sOpChat)) == "$To: "..sOpChat) then
data = strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd == "+invite" and user.bOperator) then
InviteUser(user, data)
return 1
elseif (cmd == "+delinvite" and user.bOperator) then
RemoveInvite(user, data)
return 1
elseif (cmd == "+invitelist" and user.bOperator) then
InviteList(user)
return 1
elseif (cmd == "+talklog" and user.bOperator) then
ShowTalkLog(user)
return 1
end
end
if (strsub(data,1,5+strlen(sOpChat)) == "$To: "..sOpChat) then
if (user.bOperator or arrInvite[strlower(user.sName)] ~= nil) then
SendTalkToOps(data)
SendTalkToInvited(data)
return 1
else
user:SendPM(sBot, "You can't speak in the OpChat.")
return 1
end
end
end
function InviteUser(user, data)
local s,e,nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (nick == nil) then
user:SendPM(sOpChat, "Syntax Error: the command is +invite .")
elseif (arrInvite[strlower(nick)] ~= nil) then
user:SendPM(sOpChat, "The user "..nick.." has already been invited to the OpChat.")
else
arrInvite[strlower(nick)] = user.sName
user:SendPM(sOpChat, "The user "..nick.." has been invited to the OpChat.")
if (GetItemByName(nick) ~= nil) then
GetItemByName(nick):SendPM(sOpChat, "You have been invited to talk on the OpChat by the Operator "..user.sName)
end
SendPmToOps(sOpChat, "The user "..nick.." has been invited to the OpChat by the Operator "..user.sName)
if (uLaterPtokax == 1) then
SaveToFile(fInvite , arrInvite , "arrInvite")
end
end
end
function RemoveInvite(user, data)
local s,e,nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (nick == nil) then
user:SendPM(sOpChat, "Syntax Error: the command is +delinvite .")
elseif (arrInvite[strlower(nick)] == nil) then
user:SendPM(sOpChat, "The user "..nick.." has not been invited to the OpChat.")
else
arrInvite[strlower(nick)] = nil
user:SendPM(sOpChat, "The user "..nick.." has not yet been invited to the OpChat.")
if (GetItemByName(nick) ~= nil) then
GetItemByName(nick):SendPM(sOpChat, "Your invitation to the OpChat has been deleted by the Operator "..user.sName)
end
SendPmToOps(sOpChat, "The user "..nick.." was removed from the list of users invited to the OpChat by the Operator "..user.sName)
if (uLaterPtokax == 1) then
SaveToFile(fInvite , arrInvite , "arrInvite")
end
end
end
function InviteList(user)
local sTmp,op,usr = "List of all users invited to the OpChat:\r\n\r\n"
for usr, op in arrInvite do
sTmp = sTmp.."User: "..usr.."\tInvited by: "..op.."\r\n"
end
user:SendPM(sBot, sTmp)
end
function SendTalkToOps(data)
local s,e,from,talk = strfind(data, "$To:%s+%S+%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
local aux,profile,usr
if (from ~= nil and talk ~= nil) then
SaveToLog(from, talk)
for aux, profile in GetProfiles() do
for aux, usr in GetUsersByProfile(profile) do
if (GetItemByName(usr) ~= nil and GetItemByName(usr).bOperator and GetItemByName(usr).sName ~= from) then
SendToNick(GetItemByName(usr).sName, "$To: "..GetItemByName(usr).sName.." From: "..sOpChat.." $<"..from.."> "..talk)
end
end
end
end
end
function SendTalkToInvited(data)
local s,e,from,talk = strfind(data, "$To:%s+%S+%s+From:%s+(%S+)%s+$%b<>%s+(.+)")
local aux,usr
if (from ~= nil and talk ~= nil) then
for usr, aux in arrInvite do
if (GetItemByName(usr) ~= nil and GetItemByName(usr).sName ~= from) then
SendToNick(GetItemByName(usr).sName, "$To: "..GetItemByName(usr).sName.." From: "..sOpChat.." $<"..from.."> "..talk)
end
end
end
end
function Refresh()
local aux,aux2,usr,profile
for profile, aux in arrOpLevel do
for aux2, usr in GetUsersByProfile(profile) do
if (arrLog[usr] == nil) then
arrLog[usr] = {}
if (GetItemByName(usr) == nil) then
arrLog[usr]["Mode"] = "offline"
else
arrLog[usr]["Mode"] = "online"
end
arrLog[usr]["Talk"] = ""
elseif (GetItemByName(usr) == nil) then
arrLog[usr]["Mode"] = "offline"
else
arrLog[usr]["Mode"] = "online"
end
end
end
if (uLaterPtokax == 1) then
SaveToFile(fLog , arrLog , "arrLog")
end
end
function SaveToLog(from, talk)
local usr,aux
for usr, aux in arrLog do
if (arrLog[usr]["Mode"] == "offline") then
arrLog[usr]["Talk"] = arrLog[usr]["Talk"].."<"..from.."> "..talk.."\r\n"
end
end
if (uLaterPtokax == 1) then
SaveToFile(fLog , arrLog , "arrLog")
end
end
function ShowTalkLog(user)
if (arrLog[user.sName]["Talk"] == "") then
user:SendPM(sOpChat, "There was no conversation in the OpChat while you were away.")
else
user:SendPM(sOpChat, "Here is what was said in the OpChat while you were away:\r\n\r\n"..arrLog[user.sName]["Talk"])
user:SendPM(sOpChat, "The log was cleared.")
arrLog[user.sName]["Talk"] = ""
if (uLaterPtokax == 1) then
SaveToFile(fLog , arrLog , "arrLog")
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 format("[%q]",key) or format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and 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)
writeto(file)
write(Serialize(table, tablename))
writeto()
end
function LoadFromFile(file)
if (readfrom(file) ~= nil) then
readfrom(file)
dostring(read("*all"))
readfrom()
end
end
Any errors in translation will be the fault of online automated translators, as I don't speak Portuguese :p
thx..but just got one problem with that script...the invited user can't talk on the opchat
do u want me 2 rip lawmaker opchat?
yes if you want to