PDA

View Full Version : Unexcpected XPBar?



alvarofer0020
11-12-2010, 09:05 PM
Im getting this error everytime i define a new GFxObbject in my hud script

here is the script if anyone can try to help me



class SGFxHud extends GFxMoviePlayer;

var GFxObject XPBar;

var GFxObject level;



XPBar = GetVariableObject("_root.XPBar_mc");
level = GetVariableObject("_root.XPBar_leveltxt");

XPBar.SetText(XP);
TotalAmmoDisplay.SetText(Level);



function TickHud()
{
local ParkourController PC;
local SoldierPawn UTP;



UTP = SoldierPawn(PC.Pawn);

if(UTP == None) {
return;
} else {

if(UTP.HeadVolume != None && UTP.HeadVolume.bWaterVolume) {

} else {
UTP.BreathTime = UTP.UnderWaterTime;
}



}


DefaultProperties
{
bDisplayWithHudOff=True
MovieInfo=SwfMovie'SensitivityFLASH.XPTest'
bEnableGammaCorrection=false
bDrawWeaponCrosshairs=false
bAutoPlay=true;

bAllowInput=false;
bAllowFocus=false;
}

alvarofer0020
11-13-2010, 08:02 AM
well i fixed this but now i keep getting Bad or missing expression for token MyPlayerController , in =

Seriously this problem is getting me crazy i use the same method for getting xp killing bots and it works fine

but when i try to use it in the HUD file it gives me the error

here is the code


class SGFxHud extends GFxMoviePlayer;

var GFxObject XPBar_mc, xptxt_mc;
var float LastHealthpc, Lastxppc;


var WorldInfo ThisWorld;

function Init(optional LocalPlayer player)
{







super.Init(player);

lastxppc = -1337;



LastHealthpc = -1337;
LastOxygen = -1337;
Breaths = 20;


XPBar_mc = GetVariableObject("_root.XPBar_mc");
xptxt_mc = GetVariableObject("_root.XPBar_mc.leveltxt");





xptxt_mc.SetText("PC.Level");

}


function int roundNum(float NumIn)
{
local int iNum;
local float fNum;

fNum = NumIn;
iNum = int( fNum );
fNum -= iNum;
if ( fNum >= 0.5f )
return ( iNum + 1 );
else
return iNum;
}

function int GetPercentage( int Value, int MaxValue )
{
return roundNum( ( float( Value ) / float( MaxValue ) ) * 100.0f);
}

function TickHud()
{
local MyPlayerController PC;
PC = MyPlayerController(PlayerOwner);








if(lastxppc != GetPercentage( PC.Level, PC.MAX_LEVEL ))
{

lastxppc = GetPercentage( PC.Level, PC.MAX_LEVEL );

XPBar_mc.SetFloat( "_xscale", (lastxppc > 100) ? 100.0f : lastxppc );

}


if (LastHealthpc != GetPercentage( UTP.Health, UTP.HealthMax ))
{
LastHealthpc = GetPercentage( UTP.Health, UTP.HealthMax );


}
}


DefaultProperties
{
bDisplayWithHudOff=false
MovieInfo=SwfMovie'SensitivityFLASH.XPTest'
bEnableGammaCorrection=false
bDrawWeaponCrosshairs=false
bAutoPlay=true;

bAllowInput=false;
bAllowFocus=false;
}

Alucard384
11-14-2010, 06:44 PM
Use GetPC()

alvarofer0020
11-15-2010, 01:56 PM
now it perfectly compile but my textfield instead of showing the player level show a empty square

Matt Doyle
11-15-2010, 03:52 PM
Thats a missing font issue. Please see the Scaleform video tutorial on using fonts in UDK.

alvarofer0020
11-17-2010, 03:12 PM
thanks matt doyle but now i noticed that instead of only showing the player level it also adds this %

so in the hud instead of showing Level 1

it shows Level1%

maybe becouse i used the GetPercentage function to get the level information?

if i try ti use xptxt.SetText("PC.Level"); instead of showing player level it shows the text that i putted on the setext function

please help!

Matt Doyle
11-17-2010, 03:37 PM
You're passing a string value. Remove the double quotes around PC.Level

alvarofer0020
11-17-2010, 07:55 PM
thanks matt there is only one more thing that i havent figure out example i got a int value called AmmoCount inside my custom weapon system how i can get that reference to my scaleform hud? i know i can get the reference of the pawn and player controller but i havent figure out how to get values from oter classes apart from those two

i looked at GFxMinimapUI in the part that says Weapon = UTWeapon(UTP.Weapon)

then i tryed to use that on my hud script with this

Weapon = FFWeapon(UTP.Weapon) and when i tried to compile it it just sayd missing variable name

thanks for all the help if you could help me with this our whole hud would be done

thanks in advice

Matt Doyle
11-18-2010, 10:47 AM
I'm not entirely sure off the top of my head, as I don't know how your weapon class is set up, but I would say much of the logic you need to review is in the TickHud function of GFxMinimapHud.uc. Here is the important code to review. I've copied and pasted only what you need to review:


var UTWeapon LastWeapon;

function TickHud(float DeltaTime)
{
local UTPawn UTP;
local UTWeapon Weapon;
local int i;
local PlayerController PC;

PC = GetPC();

UTP = UTPawn(PC.Pawn);

Weapon = UTWeapon(UTP.Weapon);
if (Weapon != none)
{
if (Weapon != LastWeapon)
{
if (Weapon.AmmoDisplayType == EAWDS_None)
AmmoCountTF.SetText("");
i = (Weapon.MaxAmmoCount > 50 ? 50 : Weapon.MaxAmmoCount);
MaxAmmoMC.GotoAndStopI(51 - i);
WeaponMC.SetVisible(true);
WeaponMC.GotoAndStopI(Weapon.InventoryGroup);
LastWeapon = Weapon;
}
i = Weapon.GetAmmoCount();
if (i != LastAmmoCount)
{
LastAmmoCount = i;
AmmoCountTF.SetText(i);
if (i > 50)
i = 50;
AmmoBarMC.GotoAndStopI(51 - i);
AmmoBarMC.SetVisible(true);
}
}
}

alvarofer0020
11-18-2010, 03:36 PM
thanks a lot matt i copied some things to also show the reserve ammo and its working awesome!