ID:155162
 
Hello,

I'm trying to code a Ban verb which asks for a key to ban in an input rather than selecting a mob to Ban from the world and I'm using IP Ban too, meaning that once a GM types a key to ban in the input, his key and IP, both will be banned from the server.

The problem is with banning the IP, since my code takes input as a variable. Adding the key to the Banned Keys list is easy since I just have to add the returned variable from input, but how to Ban the key's IP is my problem.

Is this even possible to do? If yes, then how? Sorry for my english, but I'm not in full condition right now. :(

[EDIT] I just thought of storing all the IPs and Keys of the players who log in the game in a savefile, so it can be accessed later. This way, perhaps I would be able to accomplish what I'm trying to do. But is there any other "Better" way to do this?

Any help is appreciated.

Regards,
using datum like this would be better
var/list/BanList=list()
datum/PlayerInfo
var/name//Name
var/Key//Key
var/IP//IP
var/Reason//Reason
var/Expires//When it expire
var/ExpireText//Msg showing after expire

now proc
proc/ExecuteBan(var/NameN,var/KeyN,var/IPN,var/ReasonN,var/ExpiresN,var/ExpireT)
var/datum/PlayerInfo/P=new//Create new Player Info Datum Every time
P.name=NameN;P.Key=KeyN;P.IP=IPN//Store Their IP,Key,Name
P.Reason=ReasonN;P.Expires=ExpiresN//Store Reason and Expire Time
P.ExpireText=ExpireT//Their exipre Text
BanList+=P//Add it to Ban List

then you could create A proc for logging their IP like
proc/CheckMyBan(mob/M)
for(var/datum/PlayerInfo/P in BanList)//Loop Through All Player Info's
if(!P.IP&&P.Key==M.key) P.IP=M.client.address//if no IP in there and Their PlayerInfo stored key is M's key
//Player Info will store that key
//then checks
if(P.IP==M.client.address)//Player Info stored IP is similar to M.client.adress
src<<"This IP Address is Banned.<br>Reason: [P.Reason]"//Tell Them
del M;return//Delete M
if(P.Key==M.key)//Same Ting Just Checking Key
M<<"This Key is Banned.<br>Reason: [P.Reason]"
del M;return

and now Run That Proc at login() like this
mob/Login()
//WhatEver
CheckMyBan(src)//Running Proc

Oh and using CheckMyBan proc will also Help if you are trying to ban person form IP and Player is keep changing IP
In response to Hassanjalil
nice hassan =D
In response to Mrfreakanime94
Hey hassan,you forgot the Expire script,without that,the player is banned forever.
In response to Nakano15
Why you're using datums when you can easily do a list with lists inside?

Bans = list("Ocean King" = list("IP" = "127.0.0.1", "ComputerID" = "Lalalal", "Reason" = "Idk", "Expiration" = "Never"))
In response to Ocean King
Wow that's cool. Thanks.
In response to Nakano15
well i was just giving him idea he have to create it self
In response to Ocean King
Ocean King wrote:
Why you're using datums when you can easily do a list with lists inside?

Bans = list("Ocean King" = list("IP" = "127.0.0.1", "ComputerID" = "Lalalal", "Reason" = "Idk", "Expiration" = "Never"))

Sorry for bumping the same topic, but how can I loop inside a sublist?

I tried:

for(var/text in Keys = list(IPs)))
usr << text


And:

for(var/text in Keys = list(IPs = list())))
usr << text



But these are giving compile errors, any help?

Regards,
In response to Hashir
 
for(var/V in Keys)
usr<<V
In response to Hassanjalil
Hassanjalil wrote:
> for(var/V  in Keys)
> usr<<V


I guess you mis-understood, I meant a sublist i.e, how will I loop through a list which is already inside a list?

Example of Sublist:

var/list/Keys = list( IDs = list())
In response to Hashir
thats why i said using Datum Ban but any way
mob
verb
LoopThroughList()
var/Keys=list("Hassanjalil"=list(123456789,894523121),"Hashir"=list(987654321,81536185721),"Kakarot"=list(152148121,84136458132))
for(var/A in Keys)
src<<"[A] =[Keys[A]]"

i think this is what you want
In response to Hassanjalil
Hassanjalil wrote:
thats why i said using Datum Ban but any way
> mob
> verb
> LoopThroughList()
> var/Keys=list("Hassanjalil"=list(123456789,894523121),"Hashir"=list(987654321,81536185721),"Kakarot"=list(152148121,84136458132))
> for(var/A in Keys)
> src<<"[A] =[Keys[A]]"

i think this is what you want


Ah, thank you.