hello
i search a script with :
3 warn than 1 kick -> 3 kick than 1 ban with 6 hours ... and this save with a file and than the op write a commands than he see the banlist
TheRevenge
:rolleyes: sorry for my bad english ;)
maybe Robocop could help you with slight adjustments... Although ban is a ban... it lasts 4ever
there is user:TimeBan(360)
:)
Hope its what you are looking for
--Made by nErBoS, slight adjustments by enema
Bot = "security"
warn = {}
kicked = {}
function Main()
--frmHub:RegBot(Bot)
end
function NewUserConnected(user, data)
if (warn[user.sName] == 3) then
user:SendData(Bot, "You going to be kicked because you had 3 warns.")
user:TempBan()
warn[user.sName] = nil
else
end
if (kicked[user.sName] == 3) then
user:SendData(Bot, "You going to be banned because you had 3 kicks.")
user:TimeBan(360)
kicked[user.sName] = nil
else
end
end
function DataArrival(user, data)
if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if (cmd=="!kick") then
if (user.bOperator) then
local s,e,usr,reason = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
if (usr == nil or reason == nil) then
user:SendData(Bot, "Syntax error, !kick , must have a nick and reason.")
else
if (GetItemByName(usr) == nil) then
user:SendData(Bot, "The user "..usr.." is not online.")
else
local userToBeKicked = GetItemByName(usr)
SendToAll(Bot, "User "..userToBeKicked.sName.." was kicked by "..Bot.." because of "..reason)
userToBeKicked:SendPM(Bot, "You are being kicked because: "..reason)
if (kicked[userToBeKicked.sName] == nil) then
kicked[userToBeKicked.sName] = 1
else
kicked[userToBeKicked.sName] = kicked[userToBeKicked.sName] + 1
end
userToBeKicked:TempBan()
end
end
else
user:SendData(Bot, "You don?t have permission to use this command.")
end
return 1
elseif (cmd=="!warn") then
if (user.bOperator) then
local s,e,usr,reason = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
if (usr == nil or reason == nil) then
user:SendData(Bot, "Syntax error, !warn , must have a nick and reason.")
else
if (GetItemByName(usr) == nil) then
user:SendData(Bot, "The user "..usr.." is not online.")
else
local userToBeWarned = GetItemByName(usr)
userToBeWarned:SendPM(Bot, "You have been warned because: "..reason)
user:SendData(Bot, "Your warn has been sent.")
SendToAll(Bot, "User "..userToBeWarned.sName.." was warned by "..Bot.." because of "..reason)
if (warn[userToBeWarned.sName] == nil) then
warn[userToBeWarned.sName] = 1
else
warn[userToBeWarned.sName] = warn[userToBeWarned.sName] + 1
end
userToBeWarned:Disconnect()
end
end
else
user:SendData(Bot, "You don?t have permission to use this command.")
end
return 1
end
end
end
It has one mayor error or missfunction - it doesnt save any logs when you restart your scripts or hub. I will try to fix that
Hi,
Here is the "mulfunction" fixed :D
--Made by nErBoS, slight adjustments by enema
--Add Table Save and Load
Bot = "security"
warn = {}
kicked = {}
fKick = "kick.dat"
fWarn = "warn.dat"
--## Configuration ##--
uLaterPtokax = 0 -- Choose 0 if you are using Ptokax Version 0.3.3.0 or higher
-- Choose 1 if you are using Ptokax Version lower then 0.3.3.0
--## END ##--
function Main()
--frmHub:RegBot(Bot)
LoadFromFile(fKick)
LoadFromFile(fWarn)
end
function OnExit()
SaveToFile(fKick , kicked , "kicked")
SaveToFile(fWarn , warn , "warn")
end
function NewUserConnected(user, data)
if (warn[user.sName] == 3) then
user:SendData(Bot, "You going to be kicked because you had 3 warns.")
user:TempBan()
warn[user.sName] = nil
if (uLaterPtokax == 1) then
SaveToFile(fWarn , warn , "warn")
end
end
if (kicked[user.sName] == 3) then
user:SendData(Bot, "You going to be banned because you had 3 kicks.")
user:TimeBan(360)
kicked[user.sName] = nil
if (uLaterPtokax == 1) then
SaveToFile(fKick , kicked , "kicked")
end
end
end
function DataArrival(user, data)
if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if (cmd=="!kick") then
if (user.bOperator) then
local s,e,usr,reason = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
if (usr == nil or reason == nil) then
user:SendData(Bot, "Syntax error, !kick , must have a nick and reason.")
else
if (GetItemByName(usr) == nil) then
user:SendData(Bot, "The user "..usr.." is not online.")
else
local userToBeKicked = GetItemByName(usr)
SendToAll(Bot, "User "..userToBeKicked.sName.." was kicked by "..Bot.." because of "..reason)
userToBeKicked:SendPM(Bot, "You are being kicked because: "..reason)
if (kicked[userToBeKicked.sName] == nil) then
kicked[userToBeKicked.sName] = 1
else
kicked[userToBeKicked.sName] = kicked[userToBeKicked.sName] + 1
end
if (uLaterPtokax == 1) then
SaveToFile(fKick , kicked , "kicked")
end
userToBeKicked:TempBan()
end
end
else
user:SendData(Bot, "You don?t have permission to use this command.")
end
return 1
elseif (cmd=="!warn") then
if (user.bOperator) then
local s,e,usr,reason = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
if (usr == nil or reason == nil) then
user:SendData(Bot, "Syntax error, !warn , must have a nick and reason.")
else
if (GetItemByName(usr) == nil) then
user:SendData(Bot, "The user "..usr.." is not online.")
else
local userToBeWarned = GetItemByName(usr)
userToBeWarned:SendPM(Bot, "You have been warned because: "..reason)
user:SendData(Bot, "Your warn has been sent.")
SendToAll(Bot, "User "..userToBeWarned.sName.." was warned by "..Bot.." because of "..reason)
if (warn[userToBeWarned.sName] == nil) then
warn[userToBeWarned.sName] = 1
else
warn[userToBeWarned.sName] = warn[userToBeWarned.sName] + 1
end
if (uLaterPtokax == 1) then
SaveToFile(fWarn , warn , "warn")
end
userToBeWarned:Disconnect()
end
end
else
user:SendData(Bot, "You don?t have permission to use this command.")
end
return 1
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
Best regards, nErBoS
grr... :D nErBoS, in your script there are still some enlgish mistakes. I thought I fix them, but when I look above, I see that bot, which I posted isint fixed or adjusted at all :D I just changed 2 things (I guess), well maybe more... not sure
Hi,
"English Mistakes" yes i write and speak bad english :P. Please correct them.
Best regards, nErBoS
No offence, nErBoS!!! I dont speek or write any better :DDD
Hi,
Not taken, welcome to the club then :)) .
Best regards, nErBoS