ID:145646
 
Hi. I am making an rpg and I am looking for a code which would allow players to teleport. Other players sees player teleport, then players see other player teleport back. Any help?
Use the Enter() proc. So if the player Enters the turf then he gets located to somewhere else. usr.loc=locate(1,1,1)

->Calus CoRPS<-
In response to Calus CoRPS
Yeah...usr in Enter is wrong. Sometimes, usr might not be who you think it is, especially in movement procs. Also, Enter is wrong here. Enter is more for permission to go in the turf, Entered is what happens when you enter it.

turf/teleport
Entered(O)
if(ismob(O))
var/mob/P = O // You typecast because O might not always be a mob.
P.loc=locate(1,1,1)
In response to Kalzar
If you check for it's being of a mob, you don't need to typecast. You've used ismob(O), so you should be fine. That is, unless of course, you need to alter mob-specific variables. Then by all means, typecast.
In response to CaptFalcon33035
In Kalzar's example, he had to typecast because he didn't initially typecast the argument.

If he would have used Entered(atom/movable/O), instead of Entered(O), he wouldn't have needed the typecast.

Hiead
In response to Hiead
In response to Joseph Constantine
Um.. yeah, okay. Anyway, I simply overlooked that part. Why he just didn't place atom/movable/O as the argument is just weird. It intrigues me.
In response to Calus CoRPS
Entered(), not Enter(). And don't suggest to a newbie that they use usr in a MOVEMENT proc. It's bad in most procs, it's AWFUL in a movement proc.
In response to Kalzar
After you've just done ismob(o), it's quite safe to use the : operator to access mob-specific variables and procs. It saves a bit of space, and because you KNOW it's a mob, it's safe. Possibly a little encouraging of bad habits, but if you keep it under control it should be fine.
In response to Jp
Jp, I thought the same thing a while back. Lummox obviously had other ideas. =/ See:
[link]
[link]

Hiead
In response to Hiead
Ah.

Well, I didn't say it was good. Just that it was safe.
In response to CaptFalcon33035
is there a code where the player can teleport freely, like walking but he is in teleport and can go over stuff ect? like clicks teleport, icon happens the player is disappeared , but he is in the same space, just invisible, then he can move about, but if there is an object in the way, he can teleport over it?
In response to Jonatjan135
So you actually mean that he will be able to walk over objects/turfs that have dens?