Author Topic: Custom Damage Types and Kill Messages [SOLVED]  (Read 565 times)

Tom

I'm trying to replace the kill message used with the player.kill(); command.

The damage type code:
Code: [Select]
AddDamageType("Hunger",   '%1 Has died of hunger',    '%2 lol how can you kill someone else of hunger? %1',1,1);
I found this code: Player.kill($DamageType::Hunger);

But when I use it, it still gives me the default Self Delete message.
« Last Edit: June 19, 2009, 05:00:52 PM by Tom »

Show us the context in which it is used.

Tom

Code: [Select]
function hungerDecay(%client)
{
if($Hungeron == 0)
{
return;
}

%hungerl = %client.hunger;
%client.hunger = %hungerl - 10;
if(%client.hunger <= 0)
{
%client.Player.kill($DamageType::Hunger);
//messageAll("", %client.getPlayerName() @ " has died of hunger."); //old.
%client.hunger = 70;
}
else
{
showhunger(%client, 0);
}
And the AddDamgeType is at the top of the script.

The kill() method just calls damage() on the object with the Self Delete damagetype. You need to learn how to call damage() and then use that instead of kill() while supplying your damage type.

Kill used to be able to accept a damage type before v9. Now it doesn't and always does Self Delete.

Tom

Got it working now, thanks for the help.

Also learned a better way to apply damage then player.addHealth(-10);

Code: [Select]
function hungerDecay(%client)
{
if($Hungeron == 0)
{
return;
}

%hungerl = %client.hunger;
%client.hunger = %hungerl - 10;
if(%client.hunger <= 0)
{
//%client.Player.kill();
//messageAll("", %client.getPlayerName() @ " has died of hunger.");
%client.player.damage(%client.player, %client.player.getTransform, 1000, $DamageType::Hunger);
%client.hunger = 70;
}
else
{
showhunger(%client, 0);
}
}

You haven't checked if their player is alive before injuring or killing them. AFK players will cause console errors.

Tom

You haven't checked if their player is alive before injuring or killing them. AFK players will cause console errors.
I fixed that.