Is there a mechanism for specifying that some global variables should only be instantiated on the client, or only instantiated on the server in a Mutator that runs in both contexts and has some communication between the two?
This is a separate issue to replication - I'm not talking about variables that will or won't have their state updated - but that actually won't be created at all on one end or the other.
As an example: suppose I declare a global array with a very large number of slots, but the array will only be used within the server-side portion of the script - can I tell clients not to create the array, since they won't ever use it?
Thanks in advance
Variable delcarations -> client side/server side
Re: Variable delcarations -> client side/server side
Maybe such as (untested)
Code: Select all
if (Role == ROLE_Authority)
spawn(ServerActorWithBigArray)
else
spawn(ClientActorWithBigArray)
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Re: Variable delcarations -> client side/server side
Separate the client-side and server-side logic into different classes. Spawn objects of the client-side class in the client's entrylevel. Spawn objects of the server-side class in the actual level (if they are subclasses of actor) but don't make them relevant to any clients.
Re: Variable delcarations -> client side/server side
Appreciate the input guys - it's an inherited script, so I've sort of been going along with the existing design up to this point. But this gives me some ideas for future direction
- sektor2111
- Godlike
- Posts: 6410
- Joined: Sun May 09, 2010 6:15 pm
- Location: On the roof.
Re: Variable declarations -> client side/server side
A note.
If client has a variable specific for client side probably at a moment you will want to make sure about it. I can give an example, using replication I keep player's TimeDilation aligned to TimeDilation from server. In some default setup this might result in game rammed in client: "Classic Setup" and map having default "TimeDilation=3". I found a way for aligning player properly because Level from client should run identically with level from Server (this guess has been proven true). It looks like UT doesn't update client if value = "default class value" making a mess in this case, then any new comer which was not witnessing Speed change probably will get screwed too...
Function GameSpeed rewritten and called ONLY ONCE
Then we attack startup message (this is for player entered) injecting something
And class quoting
For this case I have a common variable used by both Client and Server in purpose to work together in the same way.
If client has a variable specific for client side probably at a moment you will want to make sure about it. I can give an example, using replication I keep player's TimeDilation aligned to TimeDilation from server. In some default setup this might result in game rammed in client: "Classic Setup" and map having default "TimeDilation=3". I found a way for aligning player properly because Level from client should run identically with level from Server (this guess has been proven true). It looks like UT doesn't update client if value = "default class value" making a mess in this case, then any new comer which was not witnessing Speed change probably will get screwed too...
Function GameSpeed rewritten and called ONLY ONCE
Code: Select all
function SetGameSpeed(Float T)
{
local AlignSPP Ali;
GameSpeed=FMax(T,0.1);
Level.TimeDilation=GameSpeed;
SetTimer(Level.TimeDilation, True);
// SaveConfig(); //Nah, won't screw initial setup any so called Admin
if ( Level.NetMode != NM_StandAlone ) //Track speed changing
{
foreach AllActors (class'AlignSPP', Ali)
{
Ali.Speed = GameSpeed; //All aligners from clients will get authority data
}
}
}
Code: Select all
function PlayStartUpMessage(PlayerPawn NewPlayer)
{
local int i;
local AlignSPP Ali;
local color ColorGold, ColorPink;
local string tmp;
local StatLog SL;
NewPlayer.ClearProgressMessages();
ColorGold.R = 254;
ColorGold.G = 254;
ColorPink.R = 254;
ColorPink.G = 128;
ColorPink.B = 254;
if (MapMessage == "")
{
SL = Spawn(class'StatLog');
if ( SL != None )
{
tmp = SL.GetMapFileName();
SL.Disable('Timer');
SL.Destroy();
}
// MapMessage = "Running Map:"@Level.GetURLMap();
if ( tmp != "" )
MapMessage = "Running Map:"@tmp;
else
MapMessage = "Bork > Unknown Map Name!!!";
}
if ( Level.NetMode != NM_StandAlone ) //Hack for client's TimeDilation when Level is rammed + NetSpeed
{ //Using a setup Classic with 1.000000 that crap seems not replicated to client
Ali = Spawn(class'AlignSPP',NewPlayer); //And client remains screwed - so we force tracking Dilation from server
if (Ali != None)
Ali.Speed = GameSpeed; //Match them
}
.....
Code: Select all
Class AlignSPP expands Info;
var float LastCheckTime;
var Pawn Mp;
var float Speed; //This is updated acording to Level's Speed from Server - see replication bellow
replication
{
reliable if ( Role == ROLE_Authority )
Speed, AlignSpeed; //This is important !!!
}
....
simulated event tick(float DeltaTime)
{
if ( Owner == None )
{
Destroy();
GoTo JL63;
}
if ( bDeleteMe ) GoTo JL63;
else
{
/*
if ( ( LastCheckTime + 5 ) < Level.TimeSeconds )
{
// log(Self$" check owner "$Owner.GetHumanName());
LastCheckTime=Level.TimeSeconds;
AlignSpeed();
}
*/
if ( ROLE < ROLE_Authority ) //Client will screw Level with data from server
{
if ( Level.TimeDilation != Speed ) //Is different ?
Level.TimeDilation = Speed; //Setup a refresh - the rest of stuff doesn't need any touch
// log ("Time Dilation ="@Level.TimeDilation); //Amazingly, problem solved :|
// log ("Speed ="@Speed);
}
}
JL63:
}