ID:263426
 
Code:
world/IsBanned(key,address)
. = ..()
if(islist(.) && key in GMS)
world<<"The host has banned [key] the world will be shutdown in 5 seconds"
sleep(50)
del world
#define islist(L) istype(L,/list)
var/list/GMS = list("Xx Dark Wizard xX")


Problem description:

Well I don't get the message and the world isn't being shutdown.

AFAIK, isBanned() doesn't work like that. It returns 1 if 'key' is banned. It should be if(.&&(key in GMS))
In response to Jp
I tried that and it still doesen't work.
Why do you have a period inside the parenthasees? Should it be if(islist(L) && src.key in GMS. if that dont work just have it ..() not .=..().
In response to KillerGrand
KillerGrand wrote:
Why do you have a period inside the parenthasees? Should it be if(islist(L) && src.key in GMS. if that dont work just have it ..() not .=..().

It always helps to read the reference before posting on a code thread. The . var is the default return value from the proc. Thus .=..() says "Call the original version of this proc, and be prepared to send back whatever it does by default." It's islist(.) because . is the value being checked; not L, which does not exist.

Lummox JR
Xx Dark Wizard xX wrote:
Code:
> world/IsBanned(key,address)
> . = ..()
> if(islist(.) && key in GMS)
> world<<"The host has banned [key] the world will be shutdown in 5 seconds"
> sleep(50)
> del world
> #define islist(L) istype(L,/list)
> var/list/GMS = list("Xx Dark Wizard xX")
>

Problem description:

Well I don't get the message and the world isn't being shutdown.

Thank goodness, because that'd be a bad idea in response to a banned user logging in!

First let's address the main code issue. You need parentheses around "key in GMS", since the in operator has an extremely low precedence. Otherwise, this is interpreted as (islist(.) && key) in GMS instead.

Second, the key and address provided are not those of an admin. They are the key and address of the person logging in.

Beyond that, shutting down the world is the wrong thing to do. This is called when someone who's banned logs in. If the world shuts down when they do that, you end up with a built-in DOS attack on the server.

Lummox JR
In response to Lummox JR
I don't really understand what you mean by the key thing, I realized the in operator's precedence so how would I do this?
In response to Xx Dark Wizard xX
Xx Dark Wizard xX wrote:
I don't really understand what you mean by the key thing,

Key not belong to admin. Key belong to player logging in. Ungh.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Second, the key and address provided are not those of an admin. They are the key and address of the person logging in.

Beyond that, shutting down the world is the wrong thing to do. This is called when someone who's banned logs in. If the world shuts down when they do that, you end up with a built-in DOS attack on the server.

Lummox JR

I belive this is his intention. If the host bans a person in the GM list, and the GM logs in, he wants the world to shut down because he doesn't want that type of person hosting his game.

I think.
In response to Lummox JR
How would I go about doing that? Yeah, thats why I want it, If someone has the nerve to ban me from my own game they shouldn't play it.
In response to Airjoe
shutting down the game is what he wants? then he'll never have anyone be able to play the game because all it takes is for someone banned to keep trying to log in, which in turn will kill off the game everytime. not a very fun game if that happens alot.

better to delete/remove the banned user trying to log in, instead of shutting down the whole game.
In response to digitalmouse
The game only shuts down if the games creator has been banned by a host, and the creator catches them by attempting to log in. A random banned person would not be in the GMS list, and wouldn't trigger the shutdown.
In response to digitalmouse
It helps to read and understand whole topics before you reply to them, so you don't end up posting irrelevant comments like that. >_>


DarkWizard: Since you aren't even accessing '.' (past checking if it's a list) at all, just check if it's a true value, rather than a list.
Despite your idea being pretty nice, you ARE aware of the fact that if you wish, you can still allow yourself to login despite the ban, right? Why not do it? (just make IsBanned return false).
In response to Xx Dark Wizard xX
Xx Dark Wizard xX wrote:
How would I go about doing that? Yeah, thats why I want it, If someone has the nerve to ban me from my own game they shouldn't play it.

You should use other ways to do it, otherwise each time you banned a GM(for abuse and the such), you would need to update the source code and re-host, because the GM can keep logging in to shutdown the server.
In response to DivineO'peanut
Note that this only counts if he actually will set the list to all of his staff keys (well, in your quote for example it looks like he meant himself only) - I guess thats likely though. ;d
Also it only counts if his admin system actually uses IsBanned().
Well on to the point, NORMALLY, that shouldn't be an issue. Like, you shouldn't have to ban your staff in the first place.
But I guess better safe than sorry. If you don't (or it isn't feasible to) check savefiles etc, you could have the list editable by a GM verb if you wanted. :D
In response to Kaioken
Could I use GetConfig() to do it? Like if I wanted to check before I try to log in?
In response to Xx Dark Wizard xX
IsBanned() is called before you login (before client/New, actually).
In response to Kaioken
world
New()
.=..()
while(1)
for(var/A in GMS)
if(GetConfig("keyban",A))
world<<"The host has tried to ban [A] the world will be shutdown in 10 seconds"
sleep(100)
del world
sleep(600)

That works.
In response to Xx Dark Wizard xX
...But much worse. What's the point of that? Rather, use IsBanned() which is automatically called every time a player connects.
In response to Kaioken
Kaioken wrote:
...But much worse. What's the point of that?

It will catch if the host bans a GM even if the GM doesn't connect.
Page: 1 2