16.04.2012, 15:13
You should avoid having to call slow functions or larger calculations on every call. Doing them once in a while won't hurt. Functions don't hurt either, but I would recommend you not to run heavy calculations or such.
But the actual reason I decided to post is that I found that you can replace some of your code with even native callbacks!
For detecting interior changes, use OnPlayerInteriorChange. Also, I'm quite sure your script can control when players change virtual worlds, so why not use function hooking (look around! :P) for that so you can assign it once SetPlayerVirtualWorld is called rather than use it in OnPlayerUpdate or a timer.
I don't know about the position storing, but I can't think of any code of mine which could benefit from having the position updated very very often.
But the actual reason I decided to post is that I found that you can replace some of your code with even native callbacks!
For detecting interior changes, use OnPlayerInteriorChange. Also, I'm quite sure your script can control when players change virtual worlds, so why not use function hooking (look around! :P) for that so you can assign it once SetPlayerVirtualWorld is called rather than use it in OnPlayerUpdate or a timer.
I don't know about the position storing, but I can't think of any code of mine which could benefit from having the position updated very very often.