Author Topic: Showing damage for a player  (Read 1209 times)

To start it's already established I'm utter stuff at scripting. I've looked through the current playertypes on RTB and the show health player is the closest I can find to help me, but it only shows the percentage of damage. I was wondering if there was a simple function to call for the health, and if not how would I apply the math of 100 minus the presented number in the code down there.

function PlayerShowHealth::onDamage(%client, %obj)
{
commandToClient(%obj.client,'centerPrint',"\c6Health \c3" @ %obj.getHealth() @ "%", 3);
parent::onDamage(%client, %obj);
}

Also I know there is a <just:right> feature when presenting center print client, but I was too lazy with experimenting with it to work, so how could I get this code working? Thanks...
« Last Edit: November 12, 2012, 11:30:02 AM by Peggworth the Pirate »

PlayerShowHealth isn't a class.

However, there might be an Armor::OnDamage function. The main way we usually check is by running a console trace. Open a new copy of Blockland, go into singleplayer, do trace(1);, then damage your player and quit. Then read the console log and find the function that was called when you were damaged, remember to keep the same number of arguments that are displayed in the trace.

If Armor::OnDamage really is a function, then here is an example of what you probably would be doing.

Code: [Select]
function Armor::OnDamage(%this, %player, %that, %andthat, %thatthatthat) //Note the ambiguous variables are because I actually don't know what they are.
{
   %player.client.centerprint("\c6Health: \c3" @ %player.getdatablock().maxdamage-%player.getdamagelevel() @ "%", 3); //There is no such 'gethealth' function, the one I know of is getdamagelevel, so we can use that.
    parent::OnDamage(%this, %player, %that, %andthat, %thatthatthat);
}

Also remember that you have to package this.
« Last Edit: November 12, 2012, 12:09:02 PM by pecon98 »

PlayerShowHealth isn't a class.


that's not even my code that's the show health player on rtb

I re-read your post and understood it better the second time.

%player.getdatablock().maxdamage-%player.getdamagelevel() is what you are looking for.

Solved this for him over steam.