ID:262660
 
Code:
mob
proc
Multi_Key()
for(var/mob/M in world)
if(M != src)
if(M.client.address == src.client.address)
alert(M,"Multikeying is not allowed...")
alert(src,"Multikeying is not allowed...")
del(src)

mob
Login()
src.Multi_Key()


Problem description: I've been trying to figure out a way to stop multikeying since it seems so simple. I keep getting errors even though I've tried it several different ways. The errors are :

runtime error: Cannot read null.address
proc name: Multi Key (/mob/proc/Multi_Key)
usr: HellzFire92 (/mob)
src: HellzFire92 (/mob)
call stack:
HellzFire92 (/mob): Multi Key()
HellzFire92 (/mob): Login()
runtime error: Cannot read null.address
proc name: Multi Key (/mob/proc/Multi_Key)
usr: HellzFire92 (/mob)
src: HellzFire92 (/mob)
call stack:
HellzFire92 (/mob): Multi Key()
HellzFire92 (/mob): Login()


mob/proc/Multi_Key()
for(var/mob/M in world)
if(M != src && M.client)
if(M.client.address == src.client.address)
alert(M,"Multikeying is not allowed...")
alert(src,"Multikeying is not allowed...")
del(src.client)
else continue


Try that.
The main problem is that you're looping through all mobs instead of all clients. It's possible to have mobs without clients, so why not just go right to the clients?

Lummox JR
In response to Lummox JR
On that note, wouldn't it be easier just to keep a listof connected clients so that when a new client connects, it checks the address against the clints addresses in the list and boots them if someone w/ the same address is already connected?
In response to Jmurph
Yes thats the first method I tried, but it didn't work becuz I guess I didn't check for clients. This is probably one of the only times I didn't. Thanks.
In response to Jmurph
Jmurph wrote:
On that note, wouldn't it be easier just to keep a listof connected clients so that when a new client connects, it checks the address against the clints addresses in the list and boots them if someone w/ the same address is already connected?

I actually don't think it makes much difference whether you keep a list or not. I prefer to keep a list of player mobs handy, though.

Lummox JR
In response to CaptFalcon33035
Don't use alerts. The proc doesn't finish unless the okay button is presses so if you press the map you can still move and talk and do everything.