ID:1617360
 
Keywords: 2, always, away, obj, units
(See the best response by GhostAnime.)
Code:
obj    
skill
icon = 'skills.dmi'
src.loc=locate(usr.x+2,usr.y,usr.z)


My problem is simple. I would like the obj known as 'skills.dmi' to always be 2 units to the right of the user, but my code obviously doesn't work. I get 4 errors saying that src.loc, usr.x, usr.y, and usr.z are undefined vars. How can I go about fixing my code?

Best response
It is simple, there is no usr defined.

You see, usr is defined to a client's mob when an explicit action is taken by the client (ex: Click()); hence why people tell you not to use usr in most pros like Move() as usr is not defined.

The reason why it is giving you an error here is you are trying to set the loc of the item at compile time - where there is no usr. You need to put it under something that will call it at runtime.

I highly advise looking up HUD, screen_loc and client.screen in the DM Reference as that may be more suited to your needs (output to the client themselves, no one else sees the skills, and you can locate where it an be placed.
Thanks, I searched up some HUD demo's and got it working for me.