ID:140834
 
Code:
Check_IDs()
set category = "GM"
for(var/client/C)
var/P=C.computer_id
if (P==)//if P the ID Matches another Client
del (P)// it would boot one key
//and here it would tell the other key that didn't get booted that they were caught multikeying
usr<<"([C]) ID ([P])"//here would tell you that they matched and was kicked


Problem description:

what im trying to do is make this find multi
keyers
Hows that o.o?

mob/verb/Check_IDs()
set category = "GM"
var/list/Id=list()
for(var/mob/A in world)
if(A.client)
var/C=A.client.computer_id
for(var/B in Id)
if(B==C)
del A
Id+=C
In response to Chowder
how would i get it say tthis

world<<"[A.key] was multi keying on the same pc as [C.key]"
In response to Espock
Here you go :D
mob/verb/Check_IDs()
set category = "GM"
var/list/Users=list()
for(var/mob/A in world)
if(A.client)
for(var/mob/B in Users)
if(B.client.computer_id==A.client.computer_id)
world<<"[A.key] was multi keying on the same pc as [B.key]"
del A
Users+=A
In response to Chowder
You are much better off using for(var/client/C) than mob and then checking if they have a client. When you use a for list and specify mob as the type loops through every mob in the world, which can get pretty resource intensive when you have a large number of mobs floating around.
In response to Chowder
You shouldn't loop through mobs.
var/list/players=list()

client
New()
..() //let the client connect
players+=src //add the client to the list
Del()
..() //let the client disconnect
players-=src //take them out of the list

mob/verb/Check_IDs()
set category="GM"
for(var/client/c in players) //only loop through clients in that list
for(var/client/cc in players-c) //this time take the original one out of the loop
if(c.computer_id==cc.computer_id) //if they have matching IDs
world<<"[c] ([c.key]) is the same person as [cc] ([cc.key])"
//then delete one of the people
In response to AJX
I will use it from now on :)
In response to Chowder
I had posted a fixed version of your snippet, Chowder. Look above.
In response to Vic Rattlehead
idk why it isnt working vic, but i find it eiser to make it a proc then call it when they try to login

heres what i got so far
mob/Login()
world<<"[src.key] Has logged in"
MKey_Check(usr)

proc
MKey_Check()
var/list/Id=list()
for(var/mob/A in world)
if(A.client)
var/C=A.client.computer_id
for(var/B in Id)
if(B==C)
usr<<"you were booted for Multi Keying on the same pc"
world<<"[usr.key] Was booted for Multi Keying"
del A
Id+=C
In response to Vic Rattlehead
The code you posted is nice but it had some bugs
var/list/players=list()

client
New()
..() //let the client connect
players+=src //add the client to the list
Del()
..() //let the client disconnect
players-=src //take them out of the list

mob/verb/Check_IDs()
set category="GM"
for(var/client/c in players) //only loop through clients in that list
for(var/client/cc in players-c) //this time take the original one out of the loop
if(c.computer_id==cc.computer_id) //if they have matching IDs
world<<"[c] ([c.key]) is the same person as [cc] ([cc.key])"
if(!(cc.mob==c.mob))
del(cc.mob)//then delete one of the people


I fixed it though...
I'm not sure why "if(!(cc.mob==c.mob))" is necessary but when I tested the code it was always deleting both of my mobs so I added it.
In response to Chowder
Why would you be looping through all mobs, why you're only ever interested in clients?

        Check_IDs()
var/list/id[] = new
for(var/client/c)
if(c.ckey)
if(id.len)
if(id.Find(c.computer_id))
var/client/d = id[c.computer_id]
if(d)
src << "[c.ckey] and [d.ckey] found to use the same computer_id [c.computer_id]."
else
id[c.computer_id] = c
else
id[c.computer_id] = c

(This code is not intended for copy and pasting, but to illustrate a design decision. It leaves the OP with the task of kicking the player on both clients as well.)

Edit:
*sighs* While I was still writing source code, there have been eight replies! God, I'm slow.
Maybe I should reload the posting before I click on submit ;)
In response to Espock
I have built this based on what I have learned from Vic :'3
Sorta. :)
var/list/players=list() 
client
New()
players+=src
..()
Del()
..()
players-=src

mob/Login()
MKey_Check(usr)
world<<"[src.key] Has logged in"
..()
proc/MKey_Check(var/mob/P)
if(P.client)
for(var/client/c in players)
if(c.computer_id==P.client.computer_id)
if(!(c.mob==P))
world<<"[c.mob.name]([c.key]) tried to multi-key!!!"
del(P)

In any case Espock this should work nicely :D
In response to Schnitzelnagler
The method you used is really different o.O