PtokaX forum

Development Section => Your Developing Problems => Topic started by: NightLitch on 07 January, 2004, 20:31:50

Title: Timeban, resolving characters, help
Post by: NightLitch on 07 January, 2004, 20:31:50
hey guys help me out...

I Have tried made my time ban like this:

!timeban nick reason 3h

but can't get the strfind to be right... plz help hope you
see what I try to accomplish...

function dotimeban(curUser,data)
local s,e,cmd,nick,reason,num,val = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s*(.*)%s*(%d*)(%l*)" )
if nick == nil or nick == "" then
curUser:SendTo(BotName,CmdErrorMsg.." "..Prefix.."timeban [reason] [/time(m,h,d)]:"..CmdErrorPar)
return 1
end
if val == "m" then num = tMin
elseif val == "h" then num = tHour
elseif val == "d" then num = tDay
else
curUser:SendTo(BotName,CmdErrorPar)
return 1
end
local vDAYS = tonumber(tDay)*1440
local vHOURS = tonumber(tHour)*60
local vMINS = tonumber(tMin)*1
local days, hours, minutes = floor(mod(vDAYS/1440, 30)), floor(mod(vHOURS/60, 24)), floor(mod(vMINS/1, 60))
if days == nil then days = 0 elseif hours == nil then hours = 0 elseif minutes == nil then minutes = 0
end
if (reason == "" or reason == nil) then reason = "for no reason"
else reason = ""..reason
end
local vUser = GetItemByName(nick)
if not vUser then
curUser:SendTo(BotName,nick.." is not online or wrong name...")
return 1
end
if KickOperator == "disable" then
if vUser.bOperator or vUser.iProfile == BT.Lvl then
curUser:SendTo(BotName,"***You Can't Kick an Operator or Beta-T")
return 1
else
end
end
KickBanCounter(vUser,BanCounter,sBanFile)
KickBanWriteFile(vUser,reason,BanMsg,sBanMess)

Counter["timban"] = Counter["timban"] + 1
OpKickCounter(curUser,OpKickCount)
vUser:SendPM(BotName,"You are being TimeBanned by "..curUser.sName..", for: "..days.." days, "..hours.." hours, "..minutes.." minutes , Because: "..reason..",  Forum: "..ForumName)
if vDAYS == nil then vDAYS = 0 elseif vHOURS == nil then vHOURS = 0 elseif vMINS == nil then vMINS = 0
end
min = vDAYS+vHOURS+vMINS
-- vUser:TimeBan(min)
SendToAll(BotName,curUser.sName.." is TimeBanning "..nick..", for: "..days.." days, "..hours.." hours, "..minutes.." minutes , Reason: "..reason..",  Forum: "..ForumName)
return 1
end

thx
Title:
Post by: c h i l l a on 07 January, 2004, 20:43:55
nightlitch try to put the reason at last...

or try this

local s,e,cmd,nick,reason,num,val = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.*)%s+(%d+)(%l)$" )

or this if the pipe is still there

local s,e,cmd,nick,reason,num,val = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.*)%s+(%d+)(%l)%|$" )

cause thh .*  will use all chars up I think
Title:
Post by: NightLitch on 07 January, 2004, 21:19:46
k, thx Chilla
Title:
Post by: plop on 08 January, 2004, 00:52:28
QuoteOriginally posted by c h i l l a
nightlitch try to put the reason at last...

or try this

local s,e,cmd,nick,reason,num,val = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.*)%s+(%d+)(%l)$" )

or this if the pipe is still there

local s,e,cmd,nick,reason,num,val = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.*)%s+(%d+)(%l)%|$" )

cause thh .*  will use all chars up I think
yep .* goes as big as it can, so you won't get the last/first.
should all be fixed now i gues, nightlitch was in my hub earlyer for help on this.
gave him the same advise as you did, reason as last.

plop