Author Topic: Unable to find object in armor::onUnMount function  (Read 1171 times)

Today i have been working on some stuff of some add-on, but i ran into an error which i just can't trace.
Code: [Select]
Console output:
Add-Ons/Vehicle_MAS_PowerSuit/Vehicle_PowerSuit.cs (313): Unable to find object: '' attempting to call function 'getDataBlock'
BackTrace: ->armor::DoDismount->[Event_Vehicle]armor::onUnMount->[ControlledMounts]armor::onUnMount->[MASpowerSuit]armor::onUnMount


Add-Ons/Vehicle_MAS_PowerSuit/Vehicle_PowerSuit.cs (313): Unable to find object: '' attempting to call function 'getId'
BackTrace: ->armor::DoDismount->[Event_Vehicle]armor::onUnMount->[ControlledMounts]armor::onUnMount->[MASpowerSuit]armor::onUnMount
This is what the console tells me.
Code: [Select]
Package [ControlledMounts] code:
function Armor::onUnMount(%this,%player,%obj,%a,%b,%c,%d,%e,%f)
{
if(%this.controlOnMount) {
%player.onUnMountControlledMount(%obj);
}
Parent::onUnMount(%this,%player,%obj,%a,%b,%c,%d,%e,%f);
}
This is the first onUnMount override i actually added.
Code: [Select]
Package [MASpowerSuit] code:
function Armor::onUnMount(%this,%player,%obj,%a,%b,%c,%d,%e,%f)
{
Parent::onUnMount(%this,%player,%obj,%a,%b,%c,%d,%e,%f);
if(%obj.getDataBlock().getId() == PowerSuit.getId())
{
//Triggered when player exits PowerSuit
%obj.playThread(0 , sit);
}
}
And this being the last onUnMount override i added, which apparently can't find both %obj as well as the datablock PowerSuit.
Which is odd because this:
Code: [Select]
function Armor::onMount(%this,%player,%obj,%a,%b,%c,%d,%e,%f)
{
Parent::onMount(%this,%player,%obj,%a,%b,%c,%d,%e,%f);
if(%obj.getDataBlock().getId() == PowerSuit.getId())
{
//Triggered when player enters PowerSuit
%client = %player.client;
if(isObject(%client))
ServerCmdUnUseTool(%client);
%obj.playThread(0 , root);
}
}
Is located just above the onUnMount override in the same MASPowerSuit package.
And the onMount functions works perfectly fine while using %obj and Powersuit as well.

What is wrong?
I really can't seem to find what i did wrong.

After parent::onunmount(blah) %obj does no longer exist

After parent::onunmount(blah) %obj does no longer exist
I think i started off with the parent after my code.
Lemme test it again.

Edit:
Yep, still the error.
My Blockland even crashes now when unmounting, but that is most likely due to my usage of setControlObject. :P
« Last Edit: November 05, 2012, 05:56:43 PM by lordician »

Yep, still the error.
My Blockland even crashes now when unmounting, but that is most likely due to my usage of setControlObject. :P
Well, first off, use a schedule to delay it if it's crashing. %player.schedule(0,onUnMountControlledMount, %obj); should fix it.

Second, does your code still work? If so, you can just change your code so it reflects something like this:
if(%this.controlOnMount && isObject(%obj) && isObject(%player))
   %player.onUnMountControlledMount(%obj);


and

if(isObject(%obj) && isObject(PowerSuit)
   if(%obj.getDataBlock().getId() == PowerSuit.getId())
      %obj.playThread(0 , sit);
« Last Edit: November 05, 2012, 06:43:00 PM by Trinick »

Well, first off, use a schedule to delay it if it's crashing. %player.schedule(0,onUnMountControlledMount, %obj); should fix it.
Well, i shall try that, but that still doesn't solve this error i get.
Second, does your code still work? If so, you can just change your code so it reflects something like this:
if(%this.controlOnMount && isObject(%obj) && isObject(%player))
   %player.onUnMountControlledMount(%obj);


and

if(isObject(%obj) && isObject(PowerSuit)
   if(%obj.getDataBlock().getId() == PowerSuit.getId())
      %obj.playThread(0 , sit);

Well the code does work, but i don't want any other playerobject vehicle to play it's sit animation when you unmount, which is what happens now most likely (, most playerobject vehicles don't have a sit animation, so it is difficult to test).
I don't get why onUnMount doesn't even now what the PowerSuit datablock is, because it is used in the onMount as well as it's code is just above the package... >_<

There must be a way to fix this error.. :S