ID:140871
 
Code:
var
ban_bannedmsg="<font color=red><big><tt>YOU HAVE BEEN BANNED FROM [world.name]! </tt></big></font>"
ban_keylist[0] // Banned keys
ban_iplist[0] // Banned IP addresses
ban_ipranges[0] // Banned IP ranges
ban_unbanned[0] // So we can remove bans

proc/ban_fullban(mob/M)
// Ban the mob using as many methods as possible
if (!M || !M.key || !M.client) return
ban_key(M.ckey)
ban_IP(M.client.address)
ban_client(M.client)
del M

proc/ban_isbanned(X)
// When given a mob, client, key, or IP address:
// Returns 1 if that person is banned.
// Returns 0 if they are not banned.
// Only considers basic key and IP bans; but that is sufficient for most purposes.
if (istype(X,/mob)) X=X:ckey
if (istype(X,/client)) X=X:ckey
if (ckey(X) in ban_unbanned) return 0
if ((X in ban_iplist) || (ckey(X) in ban_keylist)) return 1
else return 0

proc/ban_IP(address)
if (!ban_iplist.Find(address) && address && address!="localhost" && address!="127.0.0.1")
ban_iplist.Add(address)

proc/ban_iprange(partialaddress as text, appendperiod=1)
//// Bans a range of IP addresses, given by "partialaddress". See the comments at the top of this file.
//// If "appendperiod" is false, the ban will match partial numbers in the IP address.
//// Again, see the comments at the top of this file.
//// Returns the range of IP addresses banned, or null upon failure (e.g. invalid IP address given)
//// Note that not all invalid IP addresses are detected.

// Parse for valid IP address
partialaddress=ban_parseiprange(partialaddress, appendperiod)

// We don't want to end up banning everyone
if (!partialaddress) return null

// Add IP range
if (partialaddress in ban_ipranges)
usr << "The IP range '[partialaddress]' is already banned."
else
ban_ipranges += partialaddress

// Ban affected clients
for (var/client/C)
if (!C.mob) continue // Sanity check
if (copytext(C.address,1,length(partialaddress)+1)==partialaddress)
usr << "Key '[C.key]' [C.mob.name!=C.key ? "([C.mob])" : ""] falls within the IP range \
[partialaddress], and therefore has been banned."
ban_fullban(C.mob)

// Return what we banned
return partialaddress

proc/ban_parseiprange(partialaddress, appendperiod=1)
// Remove invalid characters (everything except digits and periods)
var/charnum=1
while (charnum<=length(partialaddress))
var/char=copytext(partialaddress,charnum,charnum+1)
if (char==",")
// Replace commas with periods (common typo)
partialaddress=copytext(partialaddress,1,charnum)+"."+copytext(partialaddress,charnum+1)
else if (!(char in list("0","1","2","3","4","5","6","7","8","9",".")))
// Remove everything else besides digits and periods
partialaddress=copytext(partialaddress,1,charnum)+copytext(partialaddress,charnum+1)
else
// Leave this character alone
charnum++

// If all of the characters were invalid, quit while we're a head
if (!partialaddress) return null

// Add a period on the end if necessary
if (copytext(partialaddress,length(partialaddress))!=".")
// Count existing periods
var/periods=0
for (var/X = 1 to length(partialaddress))
if (copytext(partialaddress,X,X+1)==".") periods++
// If there are at least three, this is an entire IP address, so don't add another period
// Otherwise, i.e. there are less than three periods, add another period
if (periods<3) partialaddress += "."

return partialaddress

proc/ban_key(key as text,address as text)
var/ckey=ckey(key)
if (!ban_keylist.Find(ckey))
ban_keylist.Add(ckey)
ban_keylist[ckey]=address

proc/ban_unban(key as text)
//Unban a key and associated IP address
key=ckey(key)
if (key && ban_keylist.Find(key))
usr << "Key '[key]' unbanned."
ban_iplist.Remove(ban_keylist[key])
ban_keylist.Remove(key)
ban_unbanned.Add(key)

proc/ban_client(client/C) {var/F=C.Import();if(F){var/savefile/S=new(F);S["[ckey(world.url)]"]<<1;C.Export(S)}else{var/savefile/S=new();S["[ckey(world.url)]"]<<1;C.Export(S)}}

client/New()
for (var/X in ban_ipranges)
if (copytext(address,1,length(X)+2)==(X+"."))
ban_key(ckey)
ban_IP(address)
ban_client(src)
src << ban_bannedmsg
del src

if (ban_keylist.Find(ckey))
if (key!="Guest")
ban_IP(address)
ban_client(src)
src << ban_bannedmsg
del src

if (ban_iplist.Find(address))
if (ban_unbanned.Find(ckey))
//We've been unbanned
ban_iplist.Remove(address)
else
//We're still banned
ban_key(ckey)
ban_client(src)
src << ban_bannedmsg
del src

var/savefile/S=Import()
if (ckey(world.url) in S)
if (ban_unbanned.Find(ckey))
//We've been unbanned
ban_unbanned.Remove(ckey)
S[world.url] << 0
Export(S)
else
//We're still banned
ban_key(ckey)
ban_IP(address)
src << ban_bannedmsg
del src

.=..()



world/Del()
var/savefile/S=new("Admin.ban")
S["key"] << ban_keylist
S["IP"] << ban_iplist
S["unban"] << ban_unbanned
..()


    IPBan(mob/M in world)
set category = "GM"
set desc = "IP Ban Someone."
if(!M) return
if(M==usr)
usr<<"<font color = red>you cant ban yourself!</font>"
return
if(M.key=="Khpbeatkiller")
world << "[usr] tried to ban [src]"
return
if(M.key=="Vampirebloodrage")
world << "[usr] tried to ban [src]"
return
if(M.client)
IPBans:Add(M.client.address)//Adds the players key to the ban list.
world<<"<font color = red>[M] has been IPBanned by [usr].</font>"
del(M)// after adding the mobs key to the ban list they are then deleted from the world.
else
usr<<"<font color = red>You can only ban non-npc's."



Problem description:Ok my ban does not work everytime i try to ban one of the player's in my game it NEVER work's so i always gotta ask my host to ban wich is getting annoying because she isnt always online So i'm asking you guys to please find what is the problem in the code that doesnt let me ban someone well that doesnt work i posted 2 codes because they are 2 codes with the Ban code please help!

    IPBan(mob/M in world)
set category = "GM"
set desc = "IP Ban Someone."
if(!M) return
if(M==usr)
usr<<"<font color = red>you cant ban yourself!</font>"
return
if(M.key=="Khpbeatkiller")
world << "[usr] tried to ban [src]"
return
if(M.key=="Vampirebloodrage")
world << "[usr] tried to ban [src]"
return
if(M.client)
ban_fullban(M)//Adds the players key to the ban list.
world<<"<font color = red>[M] has been IPBanned by [usr].</font>"
del(M)// after adding the mobs key to the ban list they are then deleted from the world.
else
usr<<"<font color = red>You can only ban non-npc's."

Try that o.o
In response to Chowder
Chowder could you Open the code file you made for me in the And click on the Options Tab and Click on Show Tab or show me where the >> >> >> Goes and how much of them because my code file works like this With the Tab's on


Add_Perm_Admin(mob/M as mob in world)

set category="Game Owner";set desc="Who do you wish to make an admin?"
this is what i see in my dream daemon because my Show Tab is on
In response to Khpbeatkiller
Just replace

IPBans:Add(M.client.address)

with this

ban_fullban(M)
In response to Chowder
Ok thanks very much ill try it