Author Topic: GameConnection::onDeath(read last post, variable issue)  (Read 1779 times)

gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)

What do each of these mean and what can they possibly be?



In the CityRP mod when parent:: is called, it passes %damageLoc as %unknownA. Why shouldn't Blockland know what the last one is?




parent::onDeath(%this, %this, %killer, %damageType, %unknownA);

Also why is %this repeated?

Or just explain the top one ^.^


Code: (Torque) [Select]

function gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)
{
if(isObject(%this.CityRPTrigger))
{
%this.CityRPTrigger.getDatablock().onLeaveTrigger(%this.CityRPTrigger, %this.player);
}

if(isObject(%this.CityRPLotTrigger))
{
%this.CityRPLotTrigger.getDatablock().onLeaveTrigger(%this.CityRPLotTrigger, %this.player);
}

%this.CityRP(1);

if(getWord(CityRPData.getData(%this.bl_id).valueJailData, 1) < 1)
{
if(%this.player.currTool)
{
serverCmddropTool(%this, %this.player.currTool);
}

if(isObject(%killer) && %killer != %this)
{


    else {
commandToClient(%killer, 'centerPrint', "\c6You have commited a crime. [\c3Murder\c6]", 1);

%killer.CityRP(2, $CityRP::demerits::murder);
    }
}
}

parent::onDeath(%this, %this, %killer, %damageType, %unknownA);
}
« Last Edit: January 12, 2009, 04:49:12 PM by Kalphiter »

gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)

What do each of these mean and what can they possibly be?



In the CityRP mod when parent:: is called, it passes %damageLoc as %unknownA. Why shouldn't Blockland know what the last one is?




parent::onDeath(%this, %this, %killer, %damageType, %unknownA);

Also why is %this repeated?

Or just explain the top one ^.^

%client is who
%killerPlayer is what
%killer is unkown lol
%damageType is damage type?
%damageLoc damage location?
and why is there an unkownA?

Who is who?

Killer, killed, or what?

Who is who?

Killer, killed, or what?

The first argument in any method is always the object the method is being called for.
So, in this case, "who" would be the GameConnection that onDeath'd.

The first argument in any method is always the object the method is being called for.
So, in this case, "who" would be the GameConnection that onDeath'd.
And who is calling that connection?

I under stand the use of the first argument.

Wait, it's the killed isn't it?
Because the killed is calling onDeath, being that they died.

THIS TOPIC IS NOT FINISHED! I need a full explanation of all of the parameters.
« Last Edit: January 11, 2009, 08:17:20 PM by Kalphiter »

Tom

All of them (except for the last one) are self explanatory except for the last one, figure it out yourself. Have you tried echo(%damageLoc) so you could at least see what it is?

gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)

What do each of these mean and what can they possibly be?
%client is the client object that had their player die.
%killerPlayer is actually the object that damaged the player, which is often a projectile or a brick (by event).
%killer is the client that killed %client.
%damageType is the type of weapon used. This is to determine which message to display in the chat when someone dies.
%damageLoc has never been used in the history of Blockland.

damageloc always returns as "Body" for me.

damageloc always returns as "Body" for me.

Depends on the hitbox settings for the player datablock, they're incorrect by default.

In the CityRP mod when parent:: is called, it passes %damageLoc as %unknownA. Why shouldn't Blockland know what the last one is?
People can name the function parameters whatever they like. If I define the second argument to be "%cow", then it will be. It'll have the same value and won't affect anything except the script's readability. Jookia/whoever may not have known what the damage location argument was/did and so named it that.

parent::onDeath(%this, %this, %killer, %damageType, %unknownA);

Also why is %this repeated?

Or just explain the top one ^.^

This part of the script was probably to make it appear that %this Self Deleted or something. Or a copying mistake, which is likely. What is the function of the code around it?

Here is the complete function:

Code: (Torque) [Select]
function gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)
{
if(isObject(%this.CityRPTrigger))
{
%this.CityRPTrigger.getDatablock().onLeaveTrigger(%this.CityRPTrigger, %this.player);
}

if(isObject(%this.CityRPLotTrigger))
{
%this.CityRPLotTrigger.getDatablock().onLeaveTrigger(%this.CityRPLotTrigger, %this.player);
}

%this.CityRP(1);

if(getWord(CityRPData.getData(%this.bl_id).valueJailData, 1) < 1)
{
if(%this.player.currTool)
{
serverCmddropTool(%this, %this.player.currTool);
}

if(isObject(%killer) && %killer != %this)
{


    else {
commandToClient(%killer, 'centerPrint', "\c6You have commited a crime. [\c3Murder\c6]", 1);

%killer.CityRP(2, $CityRP::demerits::murder);
    }
}
}

parent::onDeath(%this, %this, %killer, %damageType, %unknownA);
}
« Last Edit: January 12, 2009, 03:22:06 PM by Kalphiter »

That doesn't make any sense, "%this" isn't defined at all in the function and neither is %unknownA. I'm guessing it's a copying error.

That doesn't make any sense, "%this" isn't defined at all in the function and neither is %unknownA. I'm guessing it's a copying error.
So, I'll feel free to fix it!

%unkownA being first declared would mean it's equal to 0 or null. That's what confused me.

Locked until further needs.
Nevermind, I'll just keep it open

One more question, I'm having trouble with a global variable.

I have a cmd with a variable declared there as %client.whatever.

I have GameConnection::onDeath find %client.whatever and do some stuff.
It appears the two variables are not in the same scope, how is this fixable?

$Variables are global scope. %variables are local.

I'd imagine in your instance you're just not setting it to the right object or just plain screwing something up. Variables of objects are always available.