ID:163927
 
Is there some way I could only boot players instead of looking at every mob in the world?

I know there is one way, but I wonder if there was a simplier or a smaller way to do this.
Make a universal players list, add players to it at Login(), and remove them from it at Logout(). Then you can get a list of all players by accessing that list, so instead of:

mob/verb/Boot(mob/M as mob in world)


You can use:

mob/verb/Boot(mob/M as mob in players)


If you don't understand how to do that, search the forums. I've probably written it out a dozen times.
In response to Foomer
Or just have players be of a different mob path. Like mob/players, then just cycle through the players.
In response to Dession
Dession wrote:
Or just have players be of a different mob path. Like mob/players, then just cycle through the players.

But doing it that was requires a for() and isn't compatible with verbs!

Unless you make it more complicated and add this proc:

proc/Players()
var/list/players = list()
for(var/mob/player/M in world)
players += M
return players

mob/verb/Boot(var/mob/M as mob in Players())
In response to Foomer
I mean like it would show every player's name if the player is a cilent.
In response to Foomer
Yeah, heh with me I do for()'s in all my Admin verbs, but I guess it's just personal preference =P.
In response to DadGun
DadGun wrote:
I mean like it would show every player's name if the player is a cilent.

That's not what it does?
In response to DadGun
You can try something like foomer told you..except

proc/Players()
var/list/players = list()
for(var/mob/M in world)
if(M.key) //if the mob has a key
players += M
return players

Just set it up that only mobs with a key are added to the list. You will also want to add "Cancel" so you're not forced to kick someone if you change ur mind.

Here's my version:

mob/verb
Boot()
set category = "GM"

var/list/players=new()
for(var/mob/M in world)
sleep(-1)
if(M.key)
players+=M
players+="Cancel"
var/mob/choice=input("Who do you want to kick?")in players
if(choice=="Cancel")
return
choice.Logout()


that one is recommended let me know how it turns out
I generally like to loop through clients, adding the name of the mob atom they are controlling.

proc/PlayerList()
var/list/L = list()
for(var/client/C) L[C.mob.name] = C
return L

mob/verb/Boot()
var/list/L = PlayerList()
var/i = input("Who would you like to boot?")as null|anything in L
if(!i || !L[i]) return
del(L[i])


Sending the client as an associative value avoids having to look up the value by name. When you delete a client, all of the necessary functions are calling, like mob.Logout() and the deletion of the mob the client controlled.
In response to Learned
Learned wrote:
You can try something like foomer told you..except

> proc/Players()
> var/list/players = list()
> for(var/mob/M in world)
> if(M.key) //if the mob has a key
> players += M
> return players
>

Just set it up that only mobs with a key are added to the list. You will also want to add "Cancel" so you're not forced to kick someone if you change ur mind.

Here's my version:

> mob/verb
> Boot()
> set category = "GM"
>
> var/list/players=new()
> for(var/mob/M in world)
> sleep(-1)
> if(M.key)
> players+=M
> players+="Cancel"
> var/mob/choice=input("Who do you want to kick?")in players
> if(choice=="Cancel")
> return
> choice.Logout()
>

that one is recommended let me know how it turns out

Much simpler this way, plus you can type the whole command it and you're not forced to go through an input box.
mob/verb/Boot(mob/M as mob|null in Players())
set category = "GM"

if(M)
M.Logout()


You definitely don't want to have a function like Players() programmed directly into a single verb like Boot(), considering there's a ton of ways you can use a function like that!
In response to Learned
I got it working, thanks.