ID:139769
 
Because the original post was getting too long. And everytime someone posted on it, the other posts will dissapear on page 2. The last post I made was:
'Garthor, the messages that were outputted to the world like you told me to do, they pop up now. So I've tested the ban system out again, the player gets added to the list (as we can see on the messages you made) but he can still login and play.'

Again the codes as of now:
The actual 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."
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 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()
world << "MY KEY IS [key]"
world << "EVERY KEY IN THE BAN LIST:"
for(var/v in BanList)
world << v
if(BanList.Find("[src.key]")||IPBanList.Find("[src.address]"))
src << "<b>You've been banned from this game."
src << "<b>If you think you have been banned incorrectly, contact me at 'digifais@hotmail.com'."
del(src)
if(copytext(src.key,1,7) == "Guest-")//if 'Guest-' is found within the first 7 letters of the key, it doesn't let them through
src<<"<font color=#FF0000>Guest logins are restricted. Please login with a valid BYOND key.</font>"
del(src)//kick them out of the game
..()

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()

world/New()
worldload()
..()

world/Del()
worldsave()
..()
The ban verb does work now, the player which got banned can't login now but when I put the world down and back up. The banlist wasn't saved and the player can login again.
In response to Raimo
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


You dont really need that is my guess..

heres a snip from mine for other things that you can overlook.

var/list/admins = new
var/list/ipbans = new
var/list/oguilds = new

world/New() //load bans
..()
if(fexists("Saves/WorldStuff.sav"))
var/savefile/F=new("Saves/WorldStuff.sav")
F["bans"] >> ipbans
F["admins"] >> admins
F["guilds"] >> oguilds
else
admins = list("midgetbuster = 1337","divine soldier = 4")
oguilds = new
ipbans = new

world/Del() //save bans
var/txtfile = file("Saves/WorldStuff.txt")
var/savefile/F=new("Saves/WorldStuff.sav")
F["bans"] << ipbans
F["admins"] << admins
F["guilds"] << oguilds
fdel(txtfile)
F.ExportText("/",txtfile)
..()


That all works fine for me. maybe it will help you out since i dont think that if statement is needed there in yours
In response to Midgetbuster
So you would suggest me to drop the proc part and just make it like yours?
In response to Raimo
There both pretty much the same thing.

You can just edit the proc to do a similar thing it doesnt matter either way it was just showing you that you dont need to be checking the F directly for a certain zone.

Cause with that code the reason its not reloading the players is because it will always return null as a basic if(x) since it needs a number 0 or 1 or in the case of a text string == or !=


EDIT: Just remove those if statements in the world new and you should be set (the last 2 if statements not the one checking for save file)
In response to Midgetbuster
I see what you mean. I'm going to try that.
In response to Raimo
This is what I got now and it still doesn't work. The player can still login after the server being shutdown and reopened.
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")
World["BanList"]>>BanList
World["IPBanList"]>>IPBanList
In response to Raimo
The code has been changed to:
world/New()
..()
if(fexists("save/world.sav"))
var/savefile/F = new("save/world.sav")
F["Bans"] >> BanList
F["IPBans"] >> IPBanList
else
BanList = new
IPBanList = new

world/Del()
var/savefile/F=new("save/world.sav")
F["Bans"] << BanList
F["IPBans"] << IPBanList
..()
In response to Raimo
Bump. The problem right now that the banlist doesn't save. The savefile is created as I can see in my folders. But the banlist apperently doesn't save.
In response to Raimo
It's the same problem you were having before, only with world/New() this time.
In response to Garthor
I'll check it out immediatly.
In response to Raimo
Wow. The player is able to login again after he is banned. Without the world being shutdown and being put up again.
The code:
client/New()
if(BanList.Find("[src.key]")||IPBanList.Find("[src.address]"))
src << "<font color=#FF0000>You've been banned from this game.</font>"
src << "<font color=#FF0000>If you think you have been banned incorrectly, contact the forums.</font>"
del(src)
if(copytext(src.key,1,7) == "Guest-")//if 'Guest-' is found within the first 7 letters of the key, it doesn't let them through
src<<"<font color=#FF0000>Guest logins are restricted. Please login with a valid BYOND key.</font>"
del(src)//kick them out of the game
..()

var/list/BanList = new
var/list/IPBanList = new

world/New()
..()
if(fexists("save/world.sav"))
var/savefile/F = new("save/world.sav")
F["Bans"] >> BanList
F["IPBans"] >> IPBanList
else
BanList = new
IPBanList = new

world/Del()
var/savefile/F=new("save/world.sav")
F["Bans"] << BanList
F["IPBans"] << IPBanList
..()
In response to Raimo
Yes, you keep on showing those versions of New() and Del() when we've ALREADY ESTABLISHED that the issue is with your OTHER versions of it not calling ..()

Please stop wasting time.
In response to Garthor
There are no other versions which aren't calling ..()
In response to Raimo
Then it's gremlins.

I'm sorry, there's nothing we can do.
In response to Garthor
No problem. But I also get a runtime error if I got to believe dreamdeamon. Dreamdeamon says whenever a player logs in: (Example with guestkey)
runtime error: Cannot execute null.Find().
proc name: New (/client/New)
source file: Admin Procs.dm,24
usr: null
src: Guest-3823291171 (/client)
call stack:
Guest-3823291171 (/client): New()
Guest-3823291171 (/client): New()

In response to Raimo
Go back to the DM Guide before attempting again.

Help has been given by me slightly here and on MSN and by garthor here. if you cannot head the help given then you should not be coding what your coding.
In response to Raimo
You saved a text string into the savefile where you should have a list. Delete your savefile.