stamina and HUD code

hey im still new to unrealscript and i am having a difficult time getting this stamina regen to work and show in the HUD. can someone guide me to where is the problem.

class StaminaPawn extends UTPawn;

//Variables for movement speed
var const float WalkSpeed;
var const float SprintSpeed;

//Variables for controlling and displaying Stamina
var float Stamina;//log(stamina) var const float MaxStamina; var array<string> StaminaMsgArray; var string StaminaMsg;//log(stamina)

//Variables for how stamina is affected by different activities
var const float StamRegenRate;
var const float StamWalkRegenRate;
var const float StamRunPenalty;
var const float StamJumpPenalty;

enum E_MoveState
{
EMS_Idle,
EMS_Walking,
EMS_Running,
EMS_Jumping,
};
var E_MoveState move_state;

simulated function PostBeginPlay()
{
super.PostBeginPlay();
Stamina = MaxStamina;
}

exec function StartSprint()

{
PlayerController(Controller).bRun = 0x01;
}
exec function StopSprint()
{
PlayerController(Controller).bRun = 0x00;
}

function bool DoJump( bool bUpdating )
{
if (Stamina - StamJumpPenalty > 0 && super.DoJump(bUpdating))
{
Stamina -= StamJumpPenalty;
return true;
}
return false;

}

function CalculateStamina(float DeltaTime)
{
//if player controller is walking, take away from stamina
if(move_state == EMS_Walking)
{
Stamina -= Stamina + DeltaTime * StamWalkRegenRate;
}
//if player controller is jumping, take away from stamina
if(move_state == EMS_Jumping)
{
Stamina -= DeltaTime * StamJumpPenalty;
}
//If player controller is running, take away from stamina.
if (move_state == EMS_Running)
{
Stamina -= DeltaTime * StamRunPenalty;
}
//If player is running and stamina reaches zero, stop them from running
if (Stamina <= 0.0 && move_state == EMS_Running)
{
StopSprint();
}
//If player not moving, regenerate stamina at full speed
if (move_state == EMS_Idle)
{
Stamina = Stamina + DeltaTime * StamRegenRate;
}
//Cap the stamina to MaxStamina, when regenerating
if(Stamina < MaxStamina)
{
Stamina = MaxStamina;// `log(Stamina)

}

	//stamina value
if(Stamina >= 0 && Stamina < 25)
{
	StaminaMsg = StaminaMsgArray[1];
}
if(Stamina >= 25 && Stamina < 50)
{
	StaminaMsg = StaminaMsgArray[2];
}
if(Stamina >= 50 && Stamina < 75)
{
	StaminaMsg = StaminaMsgArray[3];
}
if(Stamina >= 75 && Stamina <= 100)
{
	StaminaMsg = StaminaMsgArray[4];

}

}

/**

  • Small function to affect speed depending on if the player is running or not.
    */
    function CalculateSpeed()
    {
    local PlayerController PC;
    PC = PlayerController(Controller);
    GroundSpeed = WalkSpeed;

    {
    GroundSpeed = SprintSpeed;
    }
    }

event Tick(float DeltaTime)
{
local PlayerController PC;
local bool moving;

super.Tick(DeltaTime);

//Work out how player moving, store in a variable for convenience, this is used in "CalculateStamina"
PC = PlayerController(Controller);
move_state = EMS_Idle;
moving = Physics == PHYS_Walking && (VSize(Velocity * vect(1,1,0)) > (WalkSpeed/2));
if(moving && PC.bRun == 0x00)
{
	move_state = EMS_Walking;
}
if(moving && PC.bRun > 0x00)
{
	move_state = EMS_Running;
}

// `log(“Movement:”@move_state);

//If we're not dead, calculate the stamina, and affect the player's speed.
if (Health &gt; 0)
{
	CalculateStamina(DeltaTime); // `log(CalculateStamina(DeltaTime);
	CalculateSpeed();
	
}

}

/**

  • Default values for all the class variables
    */
    DefaultProperties
    {
    MaxStamina=100

    WalkSpeed=140
    SprintSpeed=480

    StamRegenRate=10.0
    StamWalkRegenRate=5.0
    StamRunPenalty=10.0
    StamJumpPenalty=20.0

    StaminaMsgArray=(“Exhausted”, “Tired”, “Puffed”, “Fully rested”)
    }

Sorry I must be sadly mistaken, are you using UDK?

Because UnrealScript hasn’t been around for a while now, UE4 is purely C++ or Blueprint based, and UTPawn…

I would have never guessed people still use UDK, makes no sense to me.

Good luck anyway!

It is for free and UE4 is in an early stage.

It isn’t really in such an early stage I’d say (well, not taking in account the crashes). Closing this thread as it’s not ue4 related, go to these forums instead:
https://forums.epicgames.com/forums/366-UDK