ID:2331780
 
(See the best response by Kaiochao.)
Code:
mob/Staff/verb
Teleport(mob/M in world)
set name = "Teleport"
set category = "Admin"
if(M != src)
src.x = M:x
src.y = M:y-1
src.z = M:z
src.dir = NORTH


Problem description:
So I've been programming our game for quite some time now, and its been going smoothly, but all of a sudden one morning i started getting this error when i use certain Admin Commands.

"runtime error: Undefined variable /client/var/x

proc name: Teleport (/mob/Staff/verb/Teleport)
source file: Admin Verbs.dm,459
usr: the zxc (/mob)
src: Anime HQ (/client)
usr.loc: the floor4 (36,40,6) (/turf/Buildings/Inside/Classroom/floor4)
call stack:
Anime HQ (/client): Teleport(Raiji Sensei (/mob/NPCs/Quest/Tutorial/Combat_Teacher))"

It says undefined variable, /client/var/x but thats quite weird. Any idea what could be wrong?
Best response
The verb was added to your client.verbs instead of your mob.verbs, so src actually ended up being a reference to your client.

"src: Anime HQ (/client)"
Oh! I am so stupid. I made the mistake of calling the addition of admin verbs in the client/New() proc, rather than mob.

But i believe I am better off making the admin verbs under client instead o mobs anyway since it'll only be used by actual players of the game.
You shouldn't be using the colon (:) operator like that. It's generally bad practice, especially when it isn't necessary. There's very few scenarios where it would be okay. This isn't one of them.

Also some food for thought - what if you try to teleport to someone who is standing at the bottom edge of the map? What do you think happens?
    Teleport(mob/M in world)
set category="Admin"
M<<"Admin: [usr] teleports next to you"
usr << "You teleport next to [M]"
usr.loc = locate(M.x,M.y-1,M.z)
In response to Zanoroku
Not sure who you wrote that in response to, or if you were just updating whatever snippet you were using... but you never answered my question.

Well anyways, I'm sure you'll encounter the problem soon enough.