Author Topic: GameConnection::onDeath suiciding problem  (Read 2574 times)

Ok, so I know that I made a topic about this a while ago but this is getting on my nerves.
I made a level script with this but when I Self Delete, I get EXP and cash, but it also gives it to me when I kill someone, here is the code.  (I don't want to post the other part which is included in my trench hud script which doesn't matter to this part because it's just checking to see if the person's exp and level = nothing)
Code: [Select]
function gameConnection::onDeath(%this,%obj,%killer,%type,%area)
{
parent::onDeath(%this,%obj,%killer,%type,%area);
%neededexp = %killer.level*12+5;
%killer.exp += getRandom(3,12);
%killer.cash += 2;
commandtoclient(%killer,'centerPrint',"+"@%killer.exp@""); //I will fix this later
%killer.chatMessage("\c3+<color:00DD00>$2");
}

I need help on this soon for my new project that will be public soon.  I'd appreciate it.
« Last Edit: September 15, 2012, 10:09:44 PM by tkepahama »

If %this is equal to %killer than it was Self Delete.

If %this is equal to %killer than it was Self Delete.
Oh so I should add if(%this $= %killer)?
Or the other way around? Don't know if that matters.


Use == not $=
Ok.
*EDIT: It works but I just need to see if it works with killing players.
« Last Edit: September 15, 2012, 10:14:07 PM by tkepahama »

Just a quick question.

Using his current script plus the added if statement to check if it was Self Delete, would you still gain EXP or whatever from nonplayer deaths, such as falling to death or being run over by a nonplayercontrolled vehicle?

Just a quick question.

Using his current script plus the added if statement to check if it was Self Delete, would you still gain EXP or whatever from nonplayer deaths, such as falling to death or being run over by a nonplayercontrolled vehicle?
Isn't falling to your death considered Self Delete?

Just a quick question.

Using his current script plus the added if statement to check if it was Self Delete, would you still gain EXP or whatever from nonplayer deaths, such as falling to death or being run over by a nonplayercontrolled vehicle?
Anything but another player killing you is considered Self Delete in coding.

Anything but another player killing you is considered Self Delete in coding.
Thank you

I'm a bit late, I was having a battle with a friend.  But it works great.

Thanks Ipquarx.

What if no source was specified?

!isObject( %killer ) || %this $= %killer

What if no source was specified?

!isObject( %killer ) || %this $= %killer
It could've been caused by another addon, I'm not gonna take the time to search for it though, lol.

What if no source was specified?

!isObject( %killer ) || %this $= %killer
Are you sure that %this and %killer are strings?

Are you sure that %this and %killer are strings?

Doesn't matter in TorqueScript.