For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Replication Questions

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
User avatar
Bleeder91[NL]
OldUnreal Member
Posts: 1062
Joined: Sun Oct 04, 2009 7:22 pm

Replication Questions

Post by Bleeder91[NL] »

My nemesis returns.

I have a function that is called client side and returns a bool after checking something serverside:

Code: Select all

Replication
{
      reliable if(role
Image
User avatar
Masterkent
OldUnreal Member
Posts: 1469
Joined: Fri Apr 05, 2013 12:41 pm

Re: Replication Questions

Post by Masterkent »

Now the above will always return false as far as I can tell
Rep/Sim Function Summary
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.
A replicated function call doesn't imply waiting for a response from the other end by design. The control returns to the caller immediately.
Additionally, I can't recall if we could replicate static arrays like MailInbox[30]. Can we?
Replication Data Approximation
Arrays of variables can be replicated, but only of the size of the array (in bytes) is less than 448 bytes.
User avatar
[]KAOS[]Casey
OldUnreal Member
Posts: 4497
Joined: Sun Aug 07, 2011 4:22 am
Location: over there

Re: Replication Questions

Post by []KAOS[]Casey »

you can work around the array byte size problem by making functions that replicate individual values as inputs to a function

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;
}
if its a large array, you should probably slowly tick over updates, combine this with bNetOwner and such if you need to replicate to multiple clients or if you dont care just rereplicate whenever.
User avatar
han
Global Moderator
Posts: 686
Joined: Wed Dec 10, 2014 12:38 am

Re: Replication Questions

Post by han »

I think especially for cases like a mail inbox, one should probably rather sent the server a request at some point, and the server upon this returns the results by function calls.

At a least a pattern of that sort I have in mind for using with datavault notes in HX.
HX on Mod DB. Revision on Steam. Löffels on Patreon.
User avatar
Bleeder91[NL]
OldUnreal Member
Posts: 1062
Joined: Sun Oct 04, 2009 7:22 pm

Re: Replication Questions

Post by Bleeder91[NL] »

Alright, some tinkering with Casey's code gave me the following.

Code: Select all

var Array Mailbox;
var bool bRepMail;

Replication
{
      reliable if(role
Last edited by Bleeder91[NL] on Mon Feb 06, 2017 8:18 am, edited 1 time in total.
Image
User avatar
Masterkent
OldUnreal Member
Posts: 1469
Joined: Fri Apr 05, 2013 12:41 pm

Re: Replication Questions

Post by Masterkent »

I guess, you need something like this

Code: 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
}
Last edited by Masterkent on Mon Feb 06, 2017 9:49 am, edited 1 time in total.
User avatar
Bleeder91[NL]
OldUnreal Member
Posts: 1062
Joined: Sun Oct 04, 2009 7:22 pm

Re: Replication Questions

Post by Bleeder91[NL] »

Yey that works! I'm having a similar issue in a tick function but I think I can sort that one out.
Last edited by Bleeder91[NL] on Mon Feb 06, 2017 6:09 pm, edited 1 time in total.
Image
User avatar
[]KAOS[]Casey
OldUnreal Member
Posts: 4497
Joined: Sun Aug 07, 2011 4:22 am
Location: over there

Re: Replication Questions

Post by []KAOS[]Casey »

Great! happy mailboxing.

p.s. : I would be very interested in knowing if you're working on a multiline text input box in uwindow to go with this. I wanted a thing for users to send suggestions to my server through some kind of uwindow interface, but I gave up on the text box, since it would only scroll to the right. I was far too lazy to figure out how to hack the fuck out of create a subclass of textinput that would have multiple lines, such as in this posting box im writing in, or email clients, etc.
User avatar
Bleeder91[NL]
OldUnreal Member
Posts: 1062
Joined: Sun Oct 04, 2009 7:22 pm

Re: Replication Questions

Post by Bleeder91[NL] »

I would be very interested in knowing if you're working on a multiline text input box in uwindow to go with this.
So far I've got this:
[img][/img]
It still lacks:
- Setting the Caret's location with the mouse.
- Text selection.
- Navigating up and down with the arrows properly.
- Bugfixing.

But it can already be navigated with the arrow keys somewhat, and consists of a single string seperated by char(13). No idea what this one is but it's used in one of the wrappedtextarea thingies and doesn't show up in the text itself so I assume it's safe to use.

Source:

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;
      }
}
Image
User avatar
Bleeder91[NL]
OldUnreal Member
Posts: 1062
Joined: Sun Oct 04, 2009 7:22 pm

Re: Replication Questions

Post by Bleeder91[NL] »

Alright, moving this over to its own thread since I'll be making this a stand-alone thing for other servers to use: http://www.oldunreal.com/cgi-bin/yabb2/YaBB.pl?num=1488151579/0#0
Image

Return to “UScript Board”