Results 1 to 7 of 7
  1. #1

    Default PLEASE HELP missing or bad parameter code

    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?:



    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'file location"
    bGammaCorrection = false
    }
    Last edited by King Scotty; 04-04-2012 at 02:09 PM.

  2. #2
    Redeemer
    Join Date
    Jul 2011
    Location
    London, UK
    Posts
    1,749

    Default

    Quote Originally Posted by King Scotty View Post
    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
    Last edited by reinrag; 04-04-2012 at 11:33 AM.

  3. #3
    Redeemer
    Join Date
    Jul 2011
    Location
    London, UK
    Posts
    1,749

    Default

    ok you won't get the bad parameter error normally
    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()
    
    {
      local int maxValue;
      local int value;
      return roundNum( ( float( Value ) / float( MaxValue ) ) * 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
     }

  4. #4

    Default

    thx I'll try to code tomorrow and let you know if it worked regardless thank you

  5. #5
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    ...it will not work...

  6. #6
    Redeemer
    Join Date
    Jul 2011
    Location
    London, UK
    Posts
    1,749

    Default

    Quote Originally Posted by VendorX View Post
    ...it will not work...
    i know it will give out another syntax error whatever i do even if i write local or var on top it will still give syntax error so i don't know how to fix his script

  7. #7
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Don't know about any "syntax error", but this:
    Code:
    //function to return a % from a value and a max
    function int GetPercent()
    {
      local int maxValue;
      local int value;
      return roundNum( ( float( Value ) / float( MaxValue ) ) * 100.0f);
    }
    ...is going nowhere.

    @King Scotty:
    You don't need roundNum to round a float value to an int - simply use int(SomeFloat).
    As for current error:
    Code:
    function int GetPercent( int Value, int MaxValue )
    {
    	return (100 / MaxValue) * Value;
    }
    ...
    	//if health % isnt = to current
    	if (LastHealthpc != getpercent(UTP.Health, UTP.HealthMax))
    	{
    		//make is so
    		LastHealthpc = getpercent(UTP.Health, UTP.HealthMax);
    		//update bar's xaxis but not over 100
    		HealthBarMC.SetFloat("_xscale", (LastHealthpc > 100) ? 100.0f : LastHealthpc);
    	}
    ...
    Last edited by VendorX; 04-04-2012 at 03:28 PM.


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.