PtokaX forum

Development Section => Your Developing Problems => Topic started by: NightLitch on 05 November, 2003, 16:26:33

Title: NickBan(), can't get it working with offline users...
Post by: NightLitch on 05 November, 2003, 16:26:33
Is it possible to Nickban offline users using script???

I can't get this working....

It works great with built in.. but I want to log the ban...

--NICKBAN---------------------------------------------------------------------------------------------------
function doNickBan(curUser, data,cmd)
local s,e,cmd,nick,reason = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s*(.*)" )
if not nick then
curUser:sendmessage(BOTNAME,"Syntax: "..PREFIXA.."nickban [reason]")
return 1
end

------ THIS PART

local vUser = GetItemByName(nick)
if not vUser then
SendToAll(BOTNAME,"User "..nick.." has been NickBanned by "..curUser.sName.."")
nick:NickBan()
local f = openfile("GR8-files/bans.dat", "a")
if f then
write(f, strlower(nick).." none "..reason,SHOWTIME.."\r\n")
closefile(f)
end
return 0
end

------- THIS PART

if (reason == "") then reason = "for no reason"
else reason = ""..reason
end

local f = openfile("GR8-files/bans.dat", "a")
if f then
write(f, strlower(nick).." "..vUser.sIP.." "..reason,SHOWTIME.."\r\n")
closefile(f)
end


vUser:SendPM(BOTNAME,"You are being NickBanned by "..curUser.sName.." because: "..reason)
vUser:NickBan()

SendToAll(BOTNAME,"User "..nick.." has been NickBanned by "..curUser.sName.." because: "..reason)
return 1
end


plz help me out / NightLitch
Title:
Post by: NightLitch on 05 November, 2003, 16:28:42
This is the error I got:


Syntax error: attempt to index local `nick' (a string value)
Title:
Post by: NightLitch on 05 November, 2003, 16:45:36
Have also problem resolving Ban()

BanIP:Ban()

Syntax error: attempt to index local `BanIP' (a string value)
Title:
Post by: NightLitch on 05 November, 2003, 16:53:06
plz guys.... Opium, Optimus, Skrollster, Ph?tty....
Title:
Post by: Optimus on 05 November, 2003, 17:18:41
nope that not possible offline = offline so that's hard to get

more guys have asked that question on old forum, never seen a other answer then NO.

Tryed my self to but not working... sorry

maybe some 1 else has a solution... but will have to see about that ;)
Title:
Post by: pHaTTy on 05 November, 2003, 17:25:21
NickBan it is possible to ban the nick whilst they are out of the hub, and banning the ip with from there nick whilst they are offline, requires alot of script, and it to log every single user that connects..............brrrrrrrr
Title:
Post by: Guibs on 05 November, 2003, 17:28:31
Hi there,,

the line:
----
nick:NickBan()
----
Is the bad one,... :s

Because it's about :
----
- added user class methods:
   Ban()
   NickBan()

-- (from the scripting.txt file,, by ptaczek)
----
so,, it's means Ban() & NickBan() are about an user-object, (means the guy is connected) and not about a string,....
Then,, if the function 'doNickBan' is called after the inbuild command (!nickban), and the user is not connected,, you should maybe try:
--------
--NICKBAN---------------------------------------------------------------------------------------------------
function doNickBan(curUser, data,cmd)
local s,e,cmd,nick,reason = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s*(.*)" )

if not nick then
curUser:sendmessage(BOTNAME,"Syntax: "..PREFIXA.."nickban [reason]")
return 1
end

local vUser = GetItemByName(nick)
if not vUser then
reason = "N/A - off line ban"
local f = openfile("GR8-files/bans.dat", "a")
if f then
write(f, strlower(nick).." none "..reason,SHOWTIME.."\r\n")
closefile(f)
end
return 0
else

if (reason == "") then reason = "for no reason"
else reason = ""..reason
end

local f = openfile("GR8-files/bans.dat", "a")
if f then
write(f, strlower(nick).." "..vUser.sIP.." "..reason,SHOWTIME.."\r\n")
closefile(f)
end

vUser:SendPM(BOTNAME,"You are being NickBanned by "..curUser.sName.." because: "..reason)
vUser:NickBan()

SendToAll(BOTNAME,"User "..nick.." has been NickBanned by "..curUser.sName.." because: "..reason)
return 1

end

-- SendToAll(BOTNAME,"User "..nick.." has been NickBanned by "..curUser.sName.."")
-- nick:NickBan()

end
-------
And you can't use any reason with the inbuild command, if the guy is not connected, yep,... :s

Same thing for your:
-------
BanIP:Ban()

Syntax error: attempt to index local `BanIP' (a string value)
-------
You can't use :'Ban()' with a string,... but only with an 'user-object'...
-------
   local vUser = GetItemByName(nick)
   if vUser then
      vUser:Ban()
   end
--------
Good luck,,.... :)

l8tr, ;)
Title:
Post by: NightLitch on 05 November, 2003, 17:35:41
ThX Guibs... helps alot...
Title:
Post by: plop on 05 November, 2003, 17:42:28
so if the user object would be build with the bot it would be posible 2 do it ???
(sorry if it's a stupid/dumb question, my brain isn't working 2 good. still pi**ed about last night).

plop
Title:
Post by: NightLitch on 05 November, 2003, 17:46:39
Is it possible in any way to get the return 0 data to be sent in Bot...

will explain more clearly...


Send To Bot -- !nickban... can't I nickban i BOT or need the user to be online???

/NightLitch
Title:
Post by: NightLitch on 05 November, 2003, 18:37:03
Fixed a thing and two, and learn some too....

l8r...


/NightLitch
Title:
Post by: Optimus on 05 November, 2003, 18:39:27
hehe, i knew that. lol

i was just thinking in a other direction, with a return 1 & user:Ban() / user:NickBan()

And discoverd that it didn't worked...

Have a good 1

latersss