Replication Difficulties with PlayerPawn and HUD

Discussions about Coding and Scripting
Post Reply
User avatar
comoestas
Average
Posts: 36
Joined: Tue Jan 04, 2011 12:33 am

Replication Difficulties with PlayerPawn and HUD

Post by comoestas »

Hey all,

I'm modifying an HUD class. The InputNumber function is overridden thus:

Code: Select all

simulated function InputNumber(byte F)
{
	Super.InputNumber(F);
	
	Log("PLZ WORK");
	ProcessInput(F);
}
This function is called by PlayerPawn when bShowMenu is true. ( I have verified that this variable is true on both offline and online play )
My problem is that this function doesn't get called when playing online(on neither client nor server). I know its some replication issue, but I have no workaround.

For more info, the PlayerPawn calls InputNumber from this:

Code: Select all

// The player wants to switch to weapon group numer I.
exec function SwitchWeapon (byte F )
{
    local weapon newWeapon;

    if ( bShowMenu || Level.Pauser!="" )
    {
        if ( myHud != None )
            myHud.InputNumber(F);
        return;
    }
    // Some code omitted
}
The only explanation I can come up with is that myHud is None on the client. :omfg:
Any work around? :???:

This is the most confusing problem I've had, it worked perfectly fine until I set up a LAN game. I hope someone can help me with this, I would really appreciate it.


P.S. I'm trying to modify sgHUD. You can only guess why I need to input numbers. (Hint: better constructor)

EDIT: Apparently, myHUD is not None on the client, its None on the server. :wth:
User avatar
comoestas
Average
Posts: 36
Joined: Tue Jan 04, 2011 12:33 am

Re: Replication Difficulties with PlayerPawn and HUD

Post by comoestas »

Okay, I used keybinds and an exec function and magically solved my problem. Well, this post was really helpful: http://www.ut99.org/viewtopic.php?f=15&t=2612#p22248

Lesson learned: Keybinds are awesome. :rock:

Here's a screenshot:
Image
Last edited by comoestas on Mon Feb 20, 2012 7:10 pm, edited 1 time in total.
User avatar
papercoffee
Godlike
Posts: 10451
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Replication Difficulties with PlayerPawn and HUD

Post by papercoffee »

Screenshot link is broken ...oh and please avoid double posts.
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: Replication Difficulties with PlayerPawn and HUD

Post by iloveut99 »

comoestas wrote:Okay, I used keybinds and an exec function and magically solved my problem. Well, this post was really helpful: http://www.ut99.org/viewtopic.php?f=15&t=2612#p22248

Lesson learned: Keybinds are awesome. :rock:
Hi guys,

Can I use that method to display some stats in hud using for example the f3 key of the player?
User avatar
comoestas
Average
Posts: 36
Joined: Tue Jan 04, 2011 12:33 am

Re: Replication Difficulties with PlayerPawn and HUD

Post by comoestas »

iloveut99 wrote: Can I use that method to display some stats in hud using for example the f3 key of the player?
Yes of course. You'll need to have your own HUDMutator, just add an exec function which turns on the display of stats, and use the function mentioned in that post to attach that function to the F3 key.
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: Replication Difficulties with PlayerPawn and HUD

Post by iloveut99 »

Ok awesome thanks! ;)
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: Replication Difficulties with PlayerPawn and HUD

Post by iloveut99 »

comoestas wrote: Yes of course. You'll need to have your own HUDMutator, just add an exec function which turns on the display of stats, and use the function mentioned in that post to attach that function to the F3 key.
I can't put the exec function directly in mutator right? Do I need to extend the HUD class to something like myCustomHUD class put the exec funtion in this one and then do:
C.Viewport.Actor.myHud = myCustomHUD;
(c is canvas)

Or I'm in the wrong way?
User avatar
comoestas
Average
Posts: 36
Joined: Tue Jan 04, 2011 12:33 am

Re: Replication Difficulties with PlayerPawn and HUD

Post by comoestas »

Yes, unfortunately you can't put an exec function in a mutator. My mistake. But an even better solution is to define the mutate function in your mutator. Then the command would look like "mutate <command> <parameters>"
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: Replication Difficulties with PlayerPawn and HUD

Post by iloveut99 »

I also thought in mutate but then I read this from antrax:
Keep in mind that a serverside method is in no way reliable though because it suffers from latency and network congestion.


I believe mutate function is serverside only plus introducing unnecessary lag? I'll try the HUD method that I explained.
Post Reply