Hi, I can't seem to figure out how to make it so that a piece of code is only run by the Daemon server hosted game.
IE: A global variable called year that only ticks over on the server, then outputs it to the clients every 10 minutes.
ID:160586
Aug 17 2008, 9:12 pm
|
|
Aug 17 2008, 10:38 pm
|
|
ALL code is server-side only. What are you trying to do?
|
In response to Kaioken
|
|
If I put it into the code like this
mob/Stat() Then won't that happen for all clients? I just want to make the years var increase for the server as a whole so everyone has the same year at the same time. Also I just tried overwriting the move() proc (For movement delay based on speed) and it infinite loops my game. mob/Move() |
In response to Sweep
|
|
Sweep wrote:
If I put it into the code like this mob/Stat() Then won't that happen for all clients? It will, but that code runs on the server. That specific proc is simply called by client/Stat(), which is called internally for every player every few ticks. This is not much different from, say, a softcoded loop such as this: proc/Tick() This runs a Proc() for all mobs every 3 ticks, but like all code it runs on the server only. Only very little built in stuff does some processing client-side, and custom code can't run client-side. I just want to make the years var increase for the server as a whole so everyone has the same year at the same time. What is the problem with that? You could use a global var, then make an infinite loop similar to the above code to increase it. Also I just tried overwriting the move() proc (For movement delay based on speed) and it infinite loops my game. That may happen by some other code that calls Move() in a loop, and also is the wrong way to implement delayed movement anyway: first, sleep() shouldn't be used inside procs like these or movement system procs. Also, what you want is to cancel the movement if the player is attempting to move too soon, instead of make him automatically move a few moments later, which ends up being bad since players will always hold down or spam movement macros. You should also do this by overriding client/Move(), which is called every time a player attempts to move his mob and is more suitable. Also, when overriding procs with return values (such as Move()) remember to pass on the return value for the caller, so it isn't lost which can break other code: ..() //bad |
In response to Kaioken
|
|
Thanks I figured it all out now
|