Teleport()
set category="Staff"
switch(input("What would you like to Teleport to?","Teleport",text)in list("Enemy","Player","Close"))
if("Enemy")
for(var/mob/enemies/M in world)
usr.loc=M.loc
if("Player")
var/list/Players=new()
for(var/mob/M in world) if(M.client) Players+=M
Players-=src
var/mob/M=input(usr,"Who would you like to teleport to?","Teleport/Player")as null|anything in Players
usr<<"<B><font face= verdana><font size=1>You have appeared infront of <u>[M]</u>.";usr.loc=M.loc;M<<"<B><font face= verdana><font size=1><u>[usr]</u> appeared in a flash."
Problem description:
When I click the Teleport verb it works fine, but when I Select Enemy or Player It dosn't prompt which enemy or player to go to. It just send me to a Random player or enemy. Please help.
For the player one, most likely it's because there are no other players besides yourself, or only one player (in which case input() just immediately selects that player). You need to also handle the case where M is null when you cancel the input().