PDA

View Full Version : Server/Client Timers


SoSilencer
9th Oct 2001, 07:32 PM
I know what I need to do, but I'm not quite sure how to do it. I'll try to explain as best I can.

.5 second timer
{
do code only on server/host of game
replicate/update variables to clients
}

.1 second timer
{
do this code on all machines, using variables from server
}

That is it really. It's for my rockets. Every half second the server calculates the changes and tells the clients "fly here". Every .1 seconds the rockets figure out by themselves how to fly there (which should be the same on all clients since they are all using the same variables in the same calculations). I can't quite figure out how to tell the code that "this should be done every half second and only on the server" and "this should be done every tenth of a second on all machines". Anyone know how to do that?

Wormbo
29th Dec 2001, 09:46 AM
Use an int variable as a counter:
class ... extends ...;
...
var int Counter;
...

simulated function PostBeginPlay()
{
...
SetTimer(0.1, True);
...
}

simulated function Timer()
{
if ( Counter % 5 == 0 && Role == ROLE_Authority )
DoServerStuff();

DoAllMachinesStuff();
Counter = ++Counter % 5; // increase counter
}


You had to wait long enough! :D