if can be done...
+mainchatreg - ONLY Reg's / ViP's etc... can talk n the main chat
+mainchatpublic - all users can talk in the main chat
;)
I know it's possible in dch++ through a plugin. but for ptokax it should be done with a script dunno how, i'll leave that to the experienced scripters, i'm still learning :P
i need a script *.lua hehe no plugins :P
btw i need this bot asap!!! :D
Hi,
Here you have...
--## MAINCHAT CONTROLER BOT (LUA 4)
--## Requested by D-J Valhala
--## Made by nErBoS
--## Commands:
--## +mainchatreg - Only Regged users can talk in the Main-Chat
--## +mainchatpublic - All users can talk in the MainChat
sBot = "MC-Bot"
arrMC = {["ALL"] = 1}
fMC = "mc.dat"
--## Configuration ##--
uLaterPtokax = 0 -- Choose 0 if you are using a Ptokax version 0.3.3.0 or higher
-- Choose 1 if you are using a Ptokax version lower then 0.3.3.0
--## END ##--
function Main()
frmHub:RegBot(sBot)
LoadFromFile(fMC)
end
function OnExit()
SaveToFile(fMC,arrMC,"arrMC")
end
function DataArrival(user, data)
if (user.bOperator and (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot)) then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd == "+mainchatreg") then
if (arrMC["ALL"] == 0) then
user:SendPM(sBot, "The Main-Chat is already limited to regged users only.")
else
user:SendPM(sBot, "The Main-Chat is now limited only to regged users.")
SendPmToOps(sBot, "The Main-Chat has been limited only to regged users by: "..user.sName)
arrMC["ALL"] = 0
if (uLaterPtokax == 1) then
OnExit()
end
end
return 1
elseif (cmd == "+mainchatpublic") then
if (arrMC["ALL"] == 1) then
user:SendPM(sBot, "The Main-Chat is already allowed to every user.")
else
user:SendPM(sBot, "The Main-Chat is now allowed to every user.")
SendPmToOps(sBot, "The Main-Chat has been allowed to every user by: "..user.sName)
arrMC["ALL"] = 1
if (uLaterPtokax == 1) then
OnExit()
end
end
return 1
end
end
if (strsub(data,1,1) == "<" and arrMC["ALL"] == 0 and user.Profile == -1) then
user:SendData(sBot, "You are not allowed to talk in the Main-Chat.")
return 1
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
Best regards, nErBoS
hehehe 10x alot my HubScripter :D:D:D
--## MAINCHAT CONTROLER BOT (LUA 4)
--## Requested by D-J Valhala
--## Made by nErBoS
--## Commands:
--## +mainchatreg - Only Regged users can talk in the Main-Chat
--## +mainchatpublic - All users can talk in the MainChat
sBot = "-PsYiBot-"
arrMC = {["ALL"] = 1}
fMC = "mc.dat"
--## Configuration ##--
uLaterPtokax = 0 -- Choose 0 if you are using a Ptokax version 0.3.3.0 or higher
-- Choose 1 if you are using a Ptokax version lower then 0.3.3.0
--## END ##--
function Main()
frmHub:RegBot(sBot)
LoadFromFile(fMC)
end
function OnExit()
SaveToFile(fMC,arrMC,"arrMC")
end
function DataArrival(user, data)
if (user.iProfile == 0 and (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot)) then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd == "+privatemain") then
if (arrMC["ALL"] == 0) then
user:SendData(sBot, "The Main-Chat is already limited to regged users only.")
else
user:SendData(sBot, "The Main-Chat is now limited only to regged users.")
SendPmToOps(sBot, "The Main-Chat has been limited only to regged users by: "..user.sName)
arrMC["ALL"] = 0
if (uLaterPtokax == 1) then
OnExit()
end
end
return 0
elseif (cmd == "+publicmain") then
if (arrMC["ALL"] == 1) then
user:SendData(sBot, "The Main-Chat is already allowed to every user.")
else
user:SendData(sBot, "The Main-Chat is now allowed to every user.")
SendPmToOps(sBot, "The Main-Chat has been allowed to every user by: "..user.sName)
arrMC["ALL"] = 1
if (uLaterPtokax == 1) then
OnExit()
end
end
return 0
end
end
if (strsub(data,1,1) == "<" and arrMC["ALL"] == 0 and user.Profile == -1) then
user:SendData(sBot, "You are not allowed to talk in the Main-Chat.")
return 1
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
don't work :|
Hi,
Sorry forgot the "i" in "user.iProfile", here you have...
--## MAINCHAT CONTROLER BOT (LUA 4)
--## Requested by D-J Valhala
--## Made by nErBoS
--## Commands:
--## +privatemain - Only Regged users can talk in the Main-Chat
--## +publicmain - All users can talk in the MainChat
sBot = "-PsYiBot-"
arrMC = {["ALL"] = 1}
fMC = "mc.dat"
--## Configuration ##--
uLaterPtokax = 0 -- Choose 0 if you are using a Ptokax version 0.3.3.0 or higher
-- Choose 1 if you are using a Ptokax version lower then 0.3.3.0
--## END ##--
function Main()
frmHub:RegBot(sBot)
LoadFromFile(fMC)
end
function OnExit()
SaveToFile(fMC,arrMC,"arrMC")
end
function DataArrival(user, data)
if (user.iProfile == 0 and (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot)) then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd == "+privatemain") then
if (arrMC["ALL"] == 0) then
user:SendData(sBot, "The Main-Chat is already limited to regged users only.")
else
user:SendData(sBot, "The Main-Chat is now limited only to regged users.")
SendPmToOps(sBot, "The Main-Chat has been limited only to regged users by: "..user.sName)
arrMC["ALL"] = 0
if (uLaterPtokax == 1) then
OnExit()
end
end
return 0
elseif (cmd == "+publicmain") then
if (arrMC["ALL"] == 1) then
user:SendData(sBot, "The Main-Chat is already allowed to every user.")
else
user:SendData(sBot, "The Main-Chat is now allowed to every user.")
SendPmToOps(sBot, "The Main-Chat has been allowed to every user by: "..user.sName)
arrMC["ALL"] = 1
if (uLaterPtokax == 1) then
OnExit()
end
end
return 0
end
end
if (strsub(data,1,1) == "<" and arrMC["ALL"] == 0 and user.iProfile == -1) then
user:SendData(sBot, "You are not allowed to talk in the Main-Chat.")
return 1
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
Best regards, nErBoS
script don't work m8