how do i make an area that allows the user to be moved to a different area but not a mob. the code i have...
turf/Enter_Forest
icon = 'forest.dmi'
Entered(usr/M)
usr.loc = locate(1,99,7)
usr<<"it looks like an empty forest.."
..()
moves the mob and user. if a mob happens to walk over it, it moves the mob to that area. is there a way i can make it so mobs aren't moved but the user is?
ID:178905
Mar 20 2002, 6:43 pm
|
|
You can check to see if a mob is owned by a player by checking to see if the variable "key" is not null.
turf/Enter_Forest icon = 'forest.dmi' Entered(mob/M) if(M.key) M.loc = locate(1,99,7) M << "it looks like an empty forest.." else ..() Some points to note: It's not safe to reference "usr" here at all. You've already declared M as the pointer to the mob in question, so use that variable. Another way to test if a mob is owned by a player is the test if(M.client). This will return true if a client is currently connected to the mob, but will fail if that person lags out at that moment. By the way, "usr" is usually a mob too. Mob does not necessarily mean NPC. |
Alienman22774 wrote:
how do i make an area that allows the user to be moved to a different area but not a mob. the code i have... You're misusing usr here. Remember, the player is also a mob. What you really want is for player mobs to be moved, but monster mobs to stay put. usr is always the last player to use a verb; this might actually work in your code, at least in single-player mode, but it's really bad form. The rule of thumb is: Never use usr, except in a verb. Another problem is this: Entered(usr/M) usr is not a type path. That shouldn't even work at all. The Entered() proc actually will take any atom/movable as an argument. Therefore, your proc should look like this: Entered(atom/movable/A) Now, A can be an obj or a mob (because it's atom/movable, the base type for both). If it's an obj, it doesn't pass the first if() check. If it's a mob but has no client (that is, it's not a player), it doesn't pass the second if() check. If it passes both, it's a player, so then you can teleport them. Lummox JR |
Then you can check to see if the mob has that var and if they do let them through
area
Place
Enter(mob/M)
if(M.var>=1)
usr.loc=locate(1,1,1)
usr<<"Hey look you moved."
else
return ..()