ID:139902
 
Code:
mob
GM1
verb
Rename(var/mob/M in world)
set category = "GM"
set desc = "Change A Mob's Name"
if(!M.key) continue
var/ID = input("What name do you want to rename [M] as?","Rename",M.name) as text
if(length(ID) <= 2)
src<<"<font color = red> Their name must be longer then 2 characters!"
else
src << "[M]'s name is now [html_encode(ID)]"
world << "[M]'s name is now [html_encode(ID)]"
M.name = "[html_encode(ID)]"


Problem description:

Well.. Hi everyone.. I'm getting a error.
Codes\Admin.dm:7:error: continue: not in a loop
I know when I make it
var/mob/M
for(M in world)
if(!M.key) continue
that would work.. but if I do that, I can't choose the mob I want to change name to...
"continue" can only be used in a loop. What mob type are you aiming for in particular, just players? If so, it's much easier to just draw them out of a list from client/C, or make your own list as they login and remove them from the list as they logout.
In response to Teh Governator
How do I make the list when they log in? Do I put something in the login proc or ???
In response to NarutoBleach
NarutoBleach wrote:
How do I make the list when they log in? Do I put something in the login proc or ???

Simple as this:

var
list
players=list()
client
New()
..()
players.Add(src)
Del()
players.Remove(src,null)
..()


mob
verb
Change_Name(client/C in players)
set category="GM"
set desc="Change a player's name"
if(players.len)
if((C in players))
if(ismob(C.mob))
var/mob/M=C
var/ID=input("What name do you want to rename [M.name] as?","Rename",M.name) as text|null
if(length(ID)<=2)
src<<"<font color = red> Their name must be longer then 2 characters!"
else
if(M)
players<< "[M.name]'s name is now [html_encode(ID)]"
M.name="[html_encode(ID)]"
In response to Teh Governator
mob
GM1
verb
Rename(client/C in players)
set category = "GM"
set desc = "Change A Mob's Name"
if(players.len)
if((C in players))
if(ismob(C.mob))
var/mob/M = C
var/ID = input("What name do you want to rename [M] as?","Rename",M.name) as text|null
if(length(ID) <= 2)
src<<"<font color = red> Their name must be longer then 2 characters!"
else
src << "[M]'s name is now [html_encode(ID)]"
world << "[M]'s name is now [html_encode(ID)]"
M.name = "[html_encode(ID)]"


okay.. so I did every as told. but in game when I try to use it, I get a runtime error.

NarutoBleach has logged in!
runtime error: undefined variable /client/var/name
proc name: Rename (/mob/GM1/verb/Rename)
source file: Admin.dm,11
usr: NarutoBleach (/mob)
src: NarutoBleach (/mob)
call stack:
NarutoBleach (/mob): Rename(NarutoBleach (/client))
In response to NarutoBleach
Whoops...forgot. Change that variable definition from:

var/mob/M=C



To:

var/mob/M=C.mob
In response to Teh Governator
Thank you, problem's fix. :)