
Originally Posted by
King Scotty
Okay I'm trying to make my own HUD and i can can't get this error to go away "...... .uc(79) : Error, Call to 'getpercent':missing or bad parameter 2" please can someone help?:
Class Antova_SWFWrapper extends GFxMoviePlayer;
//Create a HEALTH Catche var
var float LastHealthpc;
var int LastAmmoCount;
//Crerate variables to hold flash movieclips
var GFxObject HealthMC, HealthBarMC;
var GFxObject AmmoMC;
// Function to round a float value to an int
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 to return a % from a value and a max
function int getpercent(int val, int max)
{
return roundNum((float(val) / float(max)) * 100.0f);
}
function Init(optional LocalPlayer PC )
{
//start and load the swf movie
super.start();
Advance(0.f);
//set health cahce calue so updates on first tick
LastHealthpc = -201;
LastAmmoCount = -201;
//refrance the swf
HealthMC = GetVariableObject("_root.Healtharea");
HealthBarMC = GetVariableObject("_root.Healthbar");
AmmoMC = GetVariableObject("_root.Mana");
super.Init(PC);
}
//called every update tick
function TickHUD( float dt )
{
local UTpawn UTP;
local UTWeapon UTW;
//talk to pawn
UTP = UTPawn(GetPC().Pawn);
if (UTP == None)
{
return;
}
UTW = UTWeapon(UTP.Weapon);
if( UTW == none)
{
return;
}
//if health % isnt = to current
if (LastHealthpc != getpercent(UTP.Health, UTP.HealthMax))
{
//make is so
LastHealthpc = getpercent(UTP.HealthMax);
//update bar's xaxis but not over 100
HealthBarMC.SetFloat("_xscale", (LastHealthpc > 100) ? 100.0f : LastHealthpc);
}
}
defaultproperties
{
//hud off means off
bDisplayWithHUDOff=false
//path for swf
MovieInfo=SwftMovie'file location"
bGammaCorrection = false
}
try like this
Code:
function int GetPercent( int Value, int MaxValue )
{
return roundNum( ( float( Value ) / float( MaxValue ) ) * 100.0f);
}
and next time wrap your code because i can't really understand anything there
EDIT
actually before you take the code i wrote up there try this one
Code:
Class Antova_SWFWrapper extends GFxMoviePlayer;
//Create a HEALTH Catche var
var float LastHealthpc;
var int LastAmmoCount;
//Crerate variables to hold flash movieclips
var GFxObject HealthMC, HealthBarMC;
var GFxObject AmmoMC;
// Function to round a float value to an int
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 to return a % from a value and a max
function int getpercent(int val, int max)
{
return roundNum((float(val) / float(max)) * 100.0f);
}
function Init(optional LocalPlayer PC )
{
//start and load the swf movie
super.start();
Advance(0.f);
//set health cahce calue so updates on first tick
LastHealthpc = -201;
LastAmmoCount = -201;
//refrance the swf
HealthMC = GetVariableObject("_root.Healtharea");
HealthBarMC = GetVariableObject("_root.Healthbar");
AmmoMC = GetVariableObject("_root.Mana");
super.Init(PC);
}
//called every update tick
function TickHUD( float dt )
{
local UTpawn UTP;
local UTWeapon UTW;
//talk to pawn
UTP = UTPawn(GetPC().Pawn);
if (UTP == None)
{
return;
}
UTW = UTWeapon(UTP.Weapon);
if( UTW == none)
{
return;
}
//if health % isnt = to current
if (LastHealthpc != getpercent(UTP.Health, UTP.HealthMax))
{
//make is so
LastHealthpc = getpercent(UTP.HealthMax);
//update bar's xaxis but not over 100
HealthBarMC.SetFloat("_xscale", (LastHealthpc > 100) ? 100.0f : LastHealthpc);
}
}
defaultproperties
{
//hud off means off
bDisplayWithHUDOff=false
//path for swf
MovieInfo=SwftMovie'filelocation' bGammaCorrection = false
}
you had some syntax error before compilation
Bookmarks