Low Caliber Forum
How to make HUD?
Fri October 17 2003, 12:41 PM
ZisuHow to make HUD?
So... I dont seem to get any HUD I make to work in dedicated servers. Can someone paste a mutator that would write "Hello world" to all players? I would be eternally grateful.
Fri October 17 2003, 03:44 PM
Unter den UebrigenTell you what, dude; second best: I'll help you do it. Do you have any code handy, or are you starting from scratch?
Fri October 17 2003, 04:33 PM
ZisuOk, my situation is this:
I ripped some of MOTDcolors code so I can get functional HUD. I have made a replication like this:
class BMReplicationInfo expands ReplicationInfo;
Var int BMSavePlayerNumber;
Var string BMSavePlayerpassword;
Var bool PWGOOD;
Var bool HUDUP;
Var string PlayerName;
replication
{
unreliable if(Role == ROLE_Authority)
BMSavePlayerNumber,BMSavePlayerpassword,PWGOOD,PlayerName,HUDUP;
}
I have HUD from MOTDcolor, but I cant make it "interactive". I change values for the replication and they work fine in the actual functional mutator (BMadmin).
In "class BMInfo expands Mutator;" I have codes like this:
simulated event PostRender( canvas Canvas )
{
if (!PWGOOD)
{
DrawSomething(Canvas);
}
else DrawSomethingElse(Canvas);
if( nextHUDMutator != None )
nextHUDMutator.PostRender( Canvas );
}
simulated Function BMReplicationInfo GetBMReplicationInfo(pawn pawn)
{
local BMReplicationInfo VasRInfo, temp;
local int I;
for (i=0; i<ArrayCount(REPLINFO2); i++)
REPLINFO2[i] = None;
temp = none;
i=0;
foreach AllActors(class'BMReplicationInfo', VasRInfo)
{
REPLINFO2[i] = VasRInfo;
i +=1;
If (VasRInfo.owner == pawn)
{
temp = VasRInfo;
}
}
return temp;
}
simulated function Timer()
{
If (!foundREPL)
{
If (getBMReplicationInfo(pawn(Owner)) != NONE)
{
REPLINFO = getBMReplicationInfo(pawn(Owner));
foundREPL=true;
}
}
If (foundREPL)
{
HUDUP=REPLINFO.HUDUP;
PWGOOD = REPLINFO.PWGOOD;
}
}
simulated function Tick(float DeltaTime)
{
Super.Tick(DeltaTime);
If (!init)
nultime +=1;
If (nultime >= 10)
{
nultime =0;
RegisterHUDMutator();
}
}
What this does is that DrawSomething is done, but when I change variable PWGOOD=true elsewhere DrawSomethingElse wont come up. Im hopeless
Fri October 17 2003, 04:41 PM
ZisuI have lot of other code in there like in BMInfo:
simulated function RegisterHUDMutator()
in BMReplicationInfo:
function PostBeginPlay ()
{ SetTimer(1.0, true); }
function Timer ()
{
local PlayerReplicationInfo PRI;
If (owner == none)
{
self.destroy();
return;
}
}
Fri October 17 2003, 05:43 PM
Unter den UebrigenOriginally posted by Druid:
What this does is that DrawSomething is done, but when I change variable PWGOOD=true elsewhere DrawSomethingElse wont come up.
Render functions are in separate sand boxes from other simulated functions; variable changes within the chain of render functions will stick, but outside they won't be replicated. Try changing the variable within the render chain and see what happens (i.e. within PostRender and not Timer).
Fri October 17 2003, 06:20 PM
ZisuGot all to work but one thing. I call the function below from a funtion that is called from postrender (i.e. this is called from postrender). This dont seem to work when on dedicated server. How can I "bypass" this? It is a functionality to see list of all players and their PlayerIDs. All other things work fine, but this is the reason I decided to make this "GUI" so its quite important I get it to work.
simulated function DrawList(canvas canvas, float ypos, float xpos, float yl)
{
local Pawn PawnList;
for(PawnList = Level.PawnList; PawnList != None; PawnList=PawnList.NextPawn)
{
if(PawnList.bIsPlayer)
{
canvas.setpos(xpos, ypos);
canvas.drawText(PawnList.PlayerReplicationInfo.PlayerID$") "$PawnList.PlayerReplicationInfo.PlayerName);
ypos -= yl;
}
}
}
I tried this but it didnt help:
replication
{
unreliable if(Role < ROLE_Authority)
DrawList;
}
Fri October 17 2003, 06:38 PM
Unter den UebrigenLevel.PawnList isn't replicated inside render functions; you have to populate a list yourself using AllActors (which can be resource consuming). The trick is: populate your list at a significant event (login, logoout), and not on each render.
PS. You'll notice that the scoreboard accesses a list of PlayerReplicationInfo's; those
are replicated. If PlayerReplicationInfo is all you need, use that instead.
Sat October 18 2003, 03:22 AM
ZisuDon't read this, read the post below
--- obsolete ---
I get million "access non"s when doing this:
simulated function DrawList( canvas Canvas, float ypos, float xpos, float yl )
{
local PlayerReplicationInfo PRI;
local int PlayerCount, I;
for (i=0; i<32; i++)
{
if (PlayerPawn(Owner).GameReplicationInfo.PRIArray[i] != None)
{
PRI = PlayerPawn(Owner).GameReplicationInfo.PRIArray[i];
if ( !PRI.bIsSpectator || PRI.bWaitingPlayer )
{
canvas.setpos(xpos, ypos);
canvas.drawText(PRI.PlayerID$") "$PRI.PlayerName);
ypos -= yl;
}
}
}
}
Sat October 18 2003, 04:00 AM
ZisuOk, dont mind that upper post. I should be awarded of stupidity. I had left the
unreliable if... drawList in there so the server tried to replicate it.
The code works fine, thanks for pointing me to the Scoreboard direction.
Now that I'm on fire, is it possible to change the scoreboard via mutator, not defining a new gametype? If so, how to tell the game to use the new scoreboard?
Sat October 18 2003, 06:36 AM
Unter den UebrigenNotice the following from RuneHUD:
if ( thePlayer.bShowScores )
{
if ( (thePlayer.Scoring == None) && (thePlayer.ScoringType != None) )
thePlayer.Scoring = Spawn(thePlayer.ScoringType, thePlayer);
if ( thePlayer.Scoring != None )
{
thePlayer.Scoring.ShowScores(Canvas);
return;
}
}
Either switch out
thePlayer.ScoringType with your own; or use, say,
ModifyPlayer() in the mutator class to modify the player-pawn's
ScoringType.
Sun October 19 2003, 01:16 AM
ZisuJust realized that if making a hud, it means people have to download it when entering. And since it has so much admin functionality and it's my first mutator, I fear I left some loophole in there. So making HUD was only a good training for making scoreboard

. I probably strip the hud part off and make a separate scoreboard which has PalyerIDs displayed too, and server rules on the footer. I then add kick and ban functions this:
kickid # MOTDline#
so people know why hey are being kicked. I already have an "alive" counter in my player relication class that is toggled with a variable change, resulting counter == 0 --> kick. Now I use it to give players 10s time to enter password for a player witha protected name.
Just clearing my thoughs.
Sun October 19 2003, 09:18 AM
ZisuIt's more or less done, but i dont know how heavy it is to run :/
Also the scoreboards (DM+TDM) are done
Sun October 19 2003, 12:59 PM
ZisuI have to properly test it still. I saw one small flaw in it today
Mon October 20 2003, 05:06 AM
ZisuMy work is done now. i asked SecretLabs permission to publish BMadmin and if I get permission, i will send it to you. But I kinda want to keep it "limited" so I dont want it to end up to any web page, not yet at least. I also asked the same for "Critters Kicker +", and that has extra feature of force teamchange. That can be published
