Author Topic: Armor::onCollision spams console?  (Read 1014 times)

Hey, I'm working on a script to place items on the map and have them disappear when you walk over them, and it works, but it spams the console.
any idea how to fix this?

code:
Code: [Select]
function Armor::onCollision(%this, %obj, %col, %thing, %other, %other2)
{
if(%col.getDatablock().getName() $= "MyItem" && isObject(%obj.client))
{
if(isObject(%col))
{
if(%obj.client.minigame)
%col.minigame = %obj.client.minigame;

messageClient(%obj.client, '', "\c6The mysterious object dissappered as soon as you got close!");
%col.canPickup = false;
%col.delete();
}
else
{
%col.delete();
MissionCleanup.remove(%col);
}
}
parent::onCollision(%this, %obj, %col, %thing, %other, %other2);
}

What is the error spam saying?

function Armor::onCollision(%this, %obj, %col, %thing, %other, %other2)
{
   //Is the collision and object's client an object?
   if(isObject(%col) && isObject(%obj.client))
   {   
      //Is the name of the collision's datablock "myItem"?
      if(%col.getDataBlock().getName() $= "MyItem")
      {
         //Not sure why you put this but ok..
         if(%obj.client.minigame)
            %col.minigame = %obj.client.minigame;
      
         messageClient(%obj.client, '', "\c6The mysterious object dissappered as soon as you got close!");
         %col.canPickup = false;
         %col.delete();
      }
   }
}


What you had, you were trying to delete an object that wasn't there..

The error was simmilar to this, allthough i dont remember it exactly:
unable to find object(23536), trying to call function 'getTransform'

The script works, but it spams the console with 2 messages like that each time you walk over the item being deleted.

Look above... I fixed it for you.