ID:139804
 
Code:
The actual Ban verb.
    Ban(mob/M in world)
set category = "Staff"
set name = "Ban"
set desc = "Ban someone's Key/IP."
if(M)
var/BanKey = M.key
var/BanIP = M.client.address
if(!BanIP)BanIP=world.address
switch(alert(usr,"How will you ban [M.key]?","Ban","Key","Ip","Key and Ip"))
if("Key")
var/reason = input(usr,"Why are you banning?","Ban Reason")as null|text
if(!reason) reason = "No reason supplied. - [src]"
if(BanKey in BanList)return
addban(BanKey,null)
if(M)del(M)
info(null,world,"[BanKey] has been banned.([reason] - [src])")
if("Ip")
var/reason = input(usr,"Why are you banning?","Ban Reason")as null|text
if(!reason) reason = "No reason supplied. - [src]"
if(BanIP in IPBanList)return
addban(null,BanIP)
if(M)del(M)
info(null,world,"[BanKey] has been banned.([reason] - [src])")
if("Key and Ip")
var/reason = input(usr,"Why are you banning?","Ban Reason")as null|text
if(!reason) reason = "No reason supplied. - [src]"
if(!(BanKey in BanList))addban(BanKey,null)
if(!(BanIP in IPBanList))addban(null,BanIP)
if(M)del(M)
info(null,world,"[BanKey] has been banned.([reason] - [src])")

The Ban procs and such:
client/proc
isban()
if(BanList.Find("[key]")||IPBanList.Find("[address]"))
src<<"You're banned from this server."
del(src)
proc
addban(BanKey,BanIP)
if(BanKey)BanList+=BanKey
if(BanIP)IPBanList+=BanIP

remban(BanKey,BanIP)
if(BanKey)BanList-=BanKey
if(BanIP)IPBanList-=BanIP

info(mob/s,list/TargList,text)
for(var/mob/p in TargList)
if(!p)continue
var/message
if(s) message += "[s] "
if(text) message += "[text]"
p<<message

client/New()
..()
if(bans.Find("[src.key]")||IPBanList.Find("[src.address]"))
usr << "<b>You've been banned from this game."
usr << "<b>If you think you have been banned incorrectly, contact me at 'digifais@hotmail.com'."
bans.len++
del(src)
var
bans[10]

proc
worldsave()
var/savefile/World = new("save/world.sav")
World["BanList"]<<BanList
World["IPBanList"]<<IPBanList
worldload()
if(fexists("save/world.sav"))
var/savefile/World = new("save/world.sav")
if(World["BanList"])World["BanList"]>>BanList
if(World["IPBanList"])World["IPBanList"]>>IPBanList

var/list
BanList = new/list()
IPBanList = new/list()

Problem description:
When I ban a person, he get deleted and such from the world, just like Boot and he gets added to the Ban list. But he/she seems to be able to login again after I banned him/her. How would I fix this?

Sincerely,
Raimo.
check it with mob Login() instead of client New(). and check the mobs key to see if it's in the banlist.
In response to Bravo1
So you would want me to do it like this:
mob/Login()
if(bans.Find(src.ckey))
usr << "<b>You've been banned from this game."
usr << "<b>If you think you have been banned incorrectly, contact me at 'digifais@hotmail.com'."
bans.len++
del(src)
You are searching the list bans but you never actually add anything to it. Presumably, you are intending to use the BanList list instead.

Also: don't move things to Login(). It belongs in client/New(). However, you probably want to move ..() to AFTER you check the ban information.
In response to Garthor
Garthor wrote:
Also: don't move things to Login(). It belongs in client/New().

Why wouldn't you want to handle this at world.IsBanned?
In response to Garthor
The player which got banned can stil login after being tested. I changed this:
client/New()
if(BanList.Find("[src.key]")||IPBanList.Find("[src.address]"))
usr << "<b>You've been banned from this game."
usr << "<b>If you think you have been banned incorrectly, contact me at 'digifais@hotmail.com'."
bans.len++
del(src)
..()
In response to Raimo
Yes, though it may not work with what you have, checking with login is a bit more on the safe side, since login, for me, has always seemed more effective than client/new. Whiule there's probably not any difference between the two, I think referencing mobs is easier than clients.
In response to Bravo1
Login() is called AFTER client/New(), and is furthermore called every time a client changes mobs.

If your goal is to prevent a connection, then client/New() is IsBanned() is the place to do it. I mean, you could put the ban detection in mob/Move(), but why the hell would you?
In response to Garthor
I'm not quite sure what you're aiming for, Garthor.
And it's still not fixed by the way. I really got no clue what to do.
In response to Raimo
Lol.. IsBanned() proc is for if you want to stop him through host.. so he can't login to the game at all.. seeing as you have
client/New()
..()
if(bans.Find("[src.key]")||IPBanList.Find("[src.address]"))
usr << "<b>You've been banned from this game."
usr << "<b>If you think you have been banned incorrectly, contact me at 'digifais@hotmail.com'."
bans.len++
del(src)


I will believe that you want them to login but not show the login message like "[usr] has logged in!"... xD
What I do is make a proc in the login message to return if they are banned.
mob
Login()
for(var/client/C)
if(bans.Find(key))
return
else
C << "[usr] has logged in!"

The may not be a good system.. but it works.
NOTE: I can't seem to get IPBan to work maybe you can somehow figure it out, but this is good for key bans. Hope this helps.
In response to NarutoBleach
No, actually, what you wrote won't work, and is incredibly dumb. Why would you search the bans list once for every single player logged in, every time a player logs in?
In response to Raimo
What do you have at the moment? And how are you testing whether it works or not?
In response to Garthor
Actually I've tested it and it works.. It doesn't show me login in if I'm banned.. and like I said, it's not the best way to do it.. but it works.. it checks to see if it's in ban.. if it is then it doesn't show "[usr] has logged in" or w.e
In response to NarutoBleach
No, actually, what you have there prevents it from SAYING you log in if you're in the bans list. It does not, in fact, prevent you from actually logging in at all.
In response to Garthor
I never said it pervents you from loging in.. all I'm saying is that it doesn't gave a login msg to anyone... the client/new proc he has already dels the person that's login g in if they're banned. so this is just to pervent the login msg from the world to see.. He could also use the client/new IsBanned proc and pervent them from loging in at all and give a msg while loggin in, on the blue thingie.. w/e it's called... Bleh [screw] my grammar....
In response to NarutoBleach
To prevent the login message, you'd move ..() in client/New() to AFTER they've been cleared for entry. You don't need to touch Login() in the slightest.
In response to Garthor
Ahh I see.. I guess he didn't test it out fully as to he kept on going after your msg.
In response to Garthor
For the verb:
    Ban(mob/M in world)
set category = "Staff"
set name = "Ban"
set desc = "Ban someone's Key/IP."
if(M)
var/BanKey = M.key
var/BanIP = M.client.address
if(!BanIP)BanIP=world.address
switch(alert(usr,"How will you ban [M.key]?","Ban","Key","Ip","Key and Ip"))
if("Key")
var/reason = input(usr,"Why are you banning?","Ban Reason")as null|text
if(!reason) reason = "No reason supplied. - [src]"
if(BanKey in BanList)return
addban(BanKey,null)
if(M)del(M)
info(null,world,"[BanKey] has been banned.([reason] - [src])")
if("Ip")
var/reason = input(usr,"Why are you banning?","Ban Reason")as null|text
if(!reason) reason = "No reason supplied. - [src]"
if(BanIP in IPBanList)return
addban(null,BanIP)
if(M)del(M)
info(null,world,"[BanKey] has been banned.([reason] - [src])")
if("Key and Ip")
var/reason = input(usr,"Why are you banning?","Ban Reason")as null|text
if(!reason) reason = "No reason supplied. - [src]"
if(!(BanKey in BanList))addban(BanKey,null)
if(!(BanIP in IPBanList))addban(null,BanIP)
if(M)del(M)
info(null,world,"[BanKey] has been banned.([reason] - [src])")

For the procs and such:
client/proc
isban()
if(BanList.Find("[key]")||IPBanList.Find("[address]"))
src<<"You're banned from this server."
del(src)
proc
addban(BanKey,BanIP)
if(BanKey)BanList+=BanKey
if(BanIP)IPBanList+=BanIP

remban(BanKey,BanIP)
if(BanKey)BanList-=BanKey
if(BanIP)IPBanList-=BanIP

info(mob/s,list/TargList,text)
for(var/mob/p in TargList)
if(!p)continue
var/message
if(s) message += "[s] "
if(text) message += "[text]"
p<<message

client/New()
if(BanList.Find("[src.key]")||IPBanList.Find("[src.address]"))
usr << "<b>You've been banned from this game."
usr << "<b>If you think you have been banned incorrectly, contact me at 'digifais@hotmail.com'."
bans.len++
del(src)
..()
var
bans[10]

proc
worldsave()
var/savefile/World = new("save/world.sav")
World["BanList"]<<BanList
World["IPBanList"]<<IPBanList
worldload()
if(fexists("save/world.sav"))
var/savefile/World = new("save/world.sav")
if(World["BanList"])World["BanList"]>>BanList
if(World["IPBanList"])World["IPBanList"]>>IPBanList

var/list
BanList = new/list()
IPBanList = new/list()


And I am testing it by hosting it on Dream Deamon on Invisble mode. Then I login with one of my keys. Then I logout on that one and login with another one, and join the game with that key I am logged in right now.
I test it by keybanning the first key which I logged in with my other key. Then I reconnect my first key and it's still able to login.
In response to Raimo
Lol.. Everything is fine.. you need to add the worldsave() proc at world/Del() and worldload() at world/New()... that should fix the problem.. xD we all have been talking about the wrong problem the whole time..
In response to NarutoBleach
Okay, I'm going to test this out right now.
Page: 1 2 3