I have a function that is called client side and returns a bool after checking something serverside:
Code: Select all
Replication
{
reliable if(role
Code: Select all
Replication
{
reliable if(roleRep/Sim Function SummaryNow the above will always return false as far as I can tell
A replicated function call doesn't imply waiting for a response from the other end by design. The control returns to the caller immediately.What happens if a function is called, but doesn't meet the conditions for execution, either because it was replicated to the other end, or because it does not meet the conditions for running client-side. In that case, it is as if the function never ran in the first place. The return value of such a function is 0, "", or None, depending upon the context. Any out parameters defined by the function are passed back exactly as they were entered.
Replication Data ApproximationAdditionally, I can't recall if we could replicate static arrays like MailInbox[30]. Can we?
Arrays of variables can be replicated, but only of the size of the array (in bytes) is less than 448 bytes.
Code: Select all
replication
{
reliable if role == role_authority;
SendDataFromServer;
}
function SendDataFromServer(int i, whatever input) //call this from the server when the client needs/requetsts data
{
array[i] = input;
}
Code: Select all
var Array Mailbox;
var bool bRepMail;
Replication
{
reliable if(roleCode: Select all
replication
{
reliable if (role < ROLE_Authority)
CheckForMail;
reliable if (role == ROLE_Authority)
HandleReceivedMail;
}
// called client-side, executed server-side
function CheckForMail()
{
HandleReceivedMail(Game.GotMail(self));
}
// called server-side (see above), executed clients-side
function HandleReceivedMail(bool bMailReceived)
{
// handle the response from the server here
}
So far I've got this:I would be very interested in knowing if you're working on a multiline text input box in uwindow to go with this.
Code: Select all
//=============================================================================
// UNR_EditControl.
//=============================================================================
class UNR_EditControl expands UWindowEditControl;
function Created()
{
Super(UWindowDialogControl).Created();
EditBox = UNR_EditBox(CreateWindow(class'UNR_EditBox', 0, 0, WinWidth, WinHeight));
EditBox.NotifyOwner=Self; EditBoxWidth=WinWidth;
SetEditTextColor(LookAndFeel.EditBoxTextColor);
}
function BeforePaint(Canvas C, float X, float Y)
{ Super(UWindowDialogControl).BeforePaint(C, X, Y); }
Code: Select all
//=============================================================================
// UNR_EditBox.
// Value is split at Char(EnterUnicode).
//=============================================================================
class UNR_EditBox expands UWindowEditBox;
const EnterUnicode=13;
function Created()
{
Super.Created();
bSelectOnFocus=False;
}
function KeyDown(int Key, float X, float Y)
{
local PlayerPawn P;
local string S;
if(!bCanEdit) { Super.KeyDown(Key,X,Y); return; }
else P=GetPlayerOwner();
if(Key==P.EInputKey.IK_Enter){ InsertUnicode(EnterUnicode); return; }
if(Key==P.EInputKey.IK_Up)
{
S=Left(Value,CaretOffset);
if(InStr(S,Chr(EnterUnicode))!=-1) CaretOffset=InStr(S,Chr(EnterUnicode))+1;
else CaretOffset=0; return;
}
if(Key==P.EInputKey.IK_Down)
{
S=Mid(Value,CaretOffset);
if(InStr(S,Chr(EnterUnicode))!=-1) CaretOffset+=InStr(S,Chr(EnterUnicode))+1;
else CaretOffset=Len(Value); return;
}
Super.KeyDown(Key,X,Y);
}
function Paint(Canvas C, float X, float Y)
{
local array Lines;
local float LineX, LineY, XL,YL;
local string S;
local int I,J;
Lines[I]=Value;
if(!bHasKeyboardFocus||!bCanEdit) bShowCaret=False;
else
{
if((GetLevel().TimeSeconds>LastDrawTime+0.3) || (GetLevel().TimeSeconds=WinWidth-8) { LineX=0; LineY+=YL; }
ClipText(C, 4+LineX, 4+LineY, Left(S,1));
S=Mid(S,1); LineX+=XL;
}
LineY+=YL;
}
}