Author Topic: health display for server? - Solved  (Read 1094 times)

i found an interesting block of code in Ghille's Pixel Spells playertype

Quote
function PlayerPixArmor::onDamage(%client, %obj)
{
   if(%obj.getDamageLevel() > 50)
   {
   bottomPrint(%obj.client,"\c3Health\c6: \c0 "  @ %obj.dataBlock.maxDamage - %obj.getDamageLevel() @ "\c6/\c3" @ %obj.dataBlock.maxDamage @ "",1,3);
   parent::onDamage(%client, %obj);
   }
   else
   {
   bottomPrint(%obj.client,"\c3Health\c6: \c3 "  @ %obj.dataBlock.maxDamage - %obj.getDamageLevel() @ "\c6/\c3" @ %obj.dataBlock.maxDamage @ "",1,3);
   parent::onDamage(%client, %obj);
   }
}

it displays your current health out of your max health for a bit after your health gets changed. (damage, healing)

is it possible to adapt this code so that it effects everyone in a server instead of just a playertype? in a server.cs
« Last Edit: February 05, 2016, 02:20:06 PM by The Resonte! »

package the Armor::Damage function
Code: [Select]
package YourHealthMod
{
   function Armor::Damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
   {
     Parent::Damage(%this, %obj, %sourceObject, %position, %damage, %damageType)

     if(%obj.getDamageLevel() > 50)
       bottomPrint(%obj.client,"\c3Health\c6: \c0 "  @ %obj.dataBlock.maxDamage - %obj.getDamageLevel() @ "\c6/\c3" @ %obj.dataBlock.maxDamage @ "",1,3);
     else
       bottomPrint(%obj.client,"\c3Health\c6: \c3 "  @ %obj.dataBlock.maxDamage - %obj.getDamageLevel() @ "\c6/\c3" @ %obj.dataBlock.maxDamage @ "",1,3);
    }
};
activatePackage(YourHealthMod);

package the Armor::Damage function
Code: [Select]
syntax error on line 12
  if(%obj.getDamageLevel() > 50)

note: i copied and pasted it into a server.cs

oops, forgot a semi-colon on the parent.

Parent::Damage(%this, %obj, %sourceObject, %position, %damage, %damageType);

oops, forgot a semi-colon on the parent.

Parent::Damage(%this, %obj, %sourceObject, %position, %damage, %damageType);
this is great!

thank you very much!


You could also just THIS health bar mod.

You could also just THIS health bar mod.
from what it says, it only works if you have the client mod on a server that has the server mod

so is this like, you enable it on your server and everyone can see their healthbar?
If they have the client mod, yes. I didn't change anything in the server.cs so it should be fine like it was before.



this is just a raw server script for all players on the server, i believe

You could have requested me to put a mode to where if they don't have the health GUI it could bottomprint the health, lol. How should it look?