Hello,
I've created a healthbar for several purposes. One of them is for Lapper CruiseInsims.
Features:
How to use it:
                
                
                
            I've created a healthbar for several purposes. One of them is for Lapper CruiseInsims.
Features:
-Choose your type of character: I ,| or dots or whatever you like:
-Colorscheme is easy to adjust,
-Length of the bar ( length of the characters you used).How to use it:
-Download the script:
-Rename the file to HealthBar.LPR with 'notepad' or other textediting applications
-Place the file in 'include' folder (Bin\Default\Includes)
-Add the following line in 'AddonsUsed.LPR' (Bin\Default\Includes\Addonsused.LPR)
 include( "./HealthBar.LPR");
-Type command !hb <0-100> Example: !hb 25
<?php 
#==================================================================================#
#Scriptname:     HealthBar.LPR
#Author:          Bass-Driver
#Version:          1.0
#VersionDate:     25-12-2017
#Description:     HealthBar, With automatic colored chars calculation
#==================================================================================#
CatchEvent OnMSO( $userName, $text ) # Player event
    $text = Tolower( $text );
    $idxOfFirstSpace = indexOf( $text, " ");
    IF( $idxOfFirstSpace == -1 ) THEN
      $command = $text;
      $argv = "";
    ELSE
      $command = subStr( $text,0,$idxOfFirstSpace );
      $argv = trim( subStr( $text,$idxOfFirstSpace ) );
    ENDIF
    SWITCH( $command )
        CASE "!hb":
            #Check is Argv is a numeric value
            IF (IsNum($argv) == 1) THEN
                $Health = $argv;
                $HealthBar = "IIIIIIIIIIIIIIIIIIII";                     #Kind of chars for the bar (count even chars) 10/20/40/50/100)
                $CurrentHealth = "".CalculateHealth($Health,$HealthBar);#Get Calculated string  
                
                #IF health is equal or below 15% , it will blink.
                IF (ToNum($Health) <= 15) THEN
                    openButton($userName,"statusbar",178,100,22,4,5,-1,80,"^0Health: ".$HealthBar." ^0(".$Health."%) %at%^0Health: ".$CurrentHealth." ^0(".$Health."%)");
                ELSE
                    openButton($userName,"statusbar",178,100,22,4,5,-1,80,"^0Health: ".$CurrentHealth." (".$Health."%)");
                ENDIF
            ENDIF
        BREAK;
    ENDSWITCH
EndCatchEvent
Sub CalculateHealth($Health,$HealthBar)
            #Get length of the healthbar
            #Calcalate how many chars need be colored ((LenghtOfChars/100%) * Health)
            $LengthOfBar = StrLen( $HealthBar );
            $GetStatus = ToNum(Round((($LengthOfBar/100)*$Health),0));
            
            #Get length of string that need to be colored.
            $GetString = substr( $HealthBar,0,$GetStatus );
            #And rhe rest of the string
            $GetOtherChars = substr( $HealthBar,$GetStatus,$LengthOfBar-$GetStatus );
            
            #Which color need the calculate string have at a particular Health%
            IF (ToNum($Health) >= 50) THEN
                $NewHealth = "^2".$GetString;
            ENDIF
            IF (ToNum($Health) >= 20 && ToNum($Health) < 50) THEN
                $NewHealth = "^3".$GetString;
            ENDIF
            IF (ToNum($Health) < 20) THEN
                $NewHealth = "^1".$GetString;
            ENDIF
            #Calculate how many chars are colored , the rest will be black. Total chars = 20, Health = 50% = 10 colored chars, rest of the 10 chars will be black.
            $GetLength = StrLen( $NewHealth );
            $NewHealthBar = Insert($NewHealth,$GetLength,"^0".$GetOtherChars);
            
            #Create new string when health is below 5 %
            IF (ToNum($Health) < 5) THEN
                $NewHealthBar = "^1".$HealthBar;
            ENDIF    
        #Return value/string.    
        Return($NewHealthBar."");
EndSub
?>