How should I write a blood volume display?

Avatar

By SuperSkidder_ 21 August 2019 09:17

Member · 5 comments

I wrote a blood volume display but it didn't work. I don't know how to get the player's blood volume.(I use Google translate)

var scriptName = "Health";
var scriptVersion = 1.0;
var scriptAuthor = "SuperSkidder";
var Module = new Module();
var client;

script.import("lib/glFunctions.js");
script.import("lib/systemFunctions.js")

function Module() {
  
   var interval;
    this.getName = function() {
        return "Health";
    };

    this.getDescription = function() {
        return "Render";
    };

    this.getCategory = function() {
        return "Render";
    };
	
	this.onRender2D = function (){
		var mcHeight = getScaledHeight();
        var mcWidth = getScaledWidth();
		//var health = mc.theplayer.getHealth;   When I use this code, the next code will not take effect.
		mc.fontRendererObj.drawStringWithShadow('20' , mcWidth-mcWidth /2- 5, mcHeight - mcHeight/2 -16, 0xf7f7f7);
		
	}
    
}
function onLoad() {}

function onEnable() {
    client = moduleManager.registerModule(Module);
}

function onDisable() {
    moduleManager.unregisterModule(client);
}

Im a bad guy

Avatar

By Virus 21 August 2019 13:17

Member · 316 comments
var scriptName = "Health";
var scriptAuthor = "SuperSkidder";
var scriptVersion = 1.0;

script.import("lib/glFunctions.js");
script.import("lib/systemFunctions.js")

function ExampleModule() {
    this.getName = function() {
        return "Health";
    }
    this.getDescription = function() {
        return "Render";
    }
    this.getCategory = function() {
        return "Render";
    }
    this.onEnable = function() {
       

    }
    this.onDisable = function() {

    }
    this.onUpdate = function() {
 
    }

    this.onRender2D = function() {
        var mcHeight = getScaledHeight();
        var mcWidth = getScaledWidth();
        mc.fontRendererObj.drawStringWithShadow('Health ' + mc.thePlayer.getHealth() + '  ' , 5, mcHeight - 220, 0xff0000);


    }

}
var exampleModule = new ExampleModule();
var exampleModuleClient;

function onLoad() {}

function onEnable() {
    exampleModuleClient = moduleManager.registerModule(exampleModule);
}

function onDisable() {
    moduleManager.unregisterModule(exampleModuleClient);
}