Health Patch problem - Dedicated server
by Scottie Sirius · in Torque 3D Professional · 02/03/2010 (2:53 am) · 5 replies
When running a dedicated server I log in and start blasting away at another player or AI and when I kill them they don't drop the red vial from the healthkit. The server logs an error stating:
scripts/server/health.cs (60): Unable to find function ItemData::create
Set::add: Object "" doesn't exist
scripts/server/health.cs (75): Unable to find object: '' attempting to call function 'setTransform'
scripts/server/health.cs (76): Unable to find object: '' attempting to call function 'applyImpulse'
scripts/server/health.cs (77): Unable to find object: '' attempting to call function 'setCollisionTimeout'
scripts/server/health.cs (79): Unable to find object: '' attempting to call function 'schedulePop'
Line 60 in scripts/server/health.cs looks like this:
%item = ItemData::create(HealthKitPatch);
I see this function being created in art/datablocks/health.cs on about Line 51:
datablock ItemData(HealthKitPatch)
{
// Mission editor category, this datablock will show up in the
// specified category under the "shapes" root category.
category = "Health";
className = "HealthPatch";
// Basic Item properties
shapeFile = "art/shapes/items/patch/healthpatch.dts";
mass = 2;
friction = 1;
elasticity = 0.3;
emap = true;
// Dynamic properties defined by the scripts
pickupName = "a health patch";
repairAmount = 50;
};
So what could the problem be?
Any help would be appreciated!
scripts/server/health.cs (60): Unable to find function ItemData::create
Set::add: Object "" doesn't exist
scripts/server/health.cs (75): Unable to find object: '' attempting to call function 'setTransform'
scripts/server/health.cs (76): Unable to find object: '' attempting to call function 'applyImpulse'
scripts/server/health.cs (77): Unable to find object: '' attempting to call function 'setCollisionTimeout'
scripts/server/health.cs (79): Unable to find object: '' attempting to call function 'schedulePop'
Line 60 in scripts/server/health.cs looks like this:
%item = ItemData::create(HealthKitPatch);
I see this function being created in art/datablocks/health.cs on about Line 51:
datablock ItemData(HealthKitPatch)
{
// Mission editor category, this datablock will show up in the
// specified category under the "shapes" root category.
category = "Health";
className = "HealthPatch";
// Basic Item properties
shapeFile = "art/shapes/items/patch/healthpatch.dts";
mass = 2;
friction = 1;
elasticity = 0.3;
emap = true;
// Dynamic properties defined by the scripts
pickupName = "a health patch";
repairAmount = 50;
};
So what could the problem be?
Any help would be appreciated!
About the author
Creating the AlterVerse! www.AlterVerse.com
#2
(I just hate it when people start gnashing their teeth, the rest I can put up with...lol)
03/19/2010 (9:32 am)
Anyone have any ideas on this? I'm about to put up my first level and allow people to download the client and hop on to check it out but I really need to get the health kit thing fixed or there will be people dying everywhere, pain, sorrow, misery and gnashing of teeth!(I just hate it when people start gnashing their teeth, the rest I can put up with...lol)
#3
03/19/2010 (10:09 am)
Looks like someone decided to reuse some code from the objectBuilderGui. Which I believe won't be executed on the dedicated server. Just replace%item = ItemData::create(HealthKitPatch);with
%item = new Item()
{
datablock = HealthKitPatch;
};The rest of that code will take care of positioning it.
#4
scripts/server/health.cs (46): Unable to find object: '6703' attempting to call function 'UpdateHealth'
What does that mean?
Here's the function in server/health.cs
function HealthPatch::doHealthUpdate(%this, %obj)
{
if (%obj.healthTimer < 40) // 40 = 10 seconds at 1 iteration per 250 ms.
{
%obj.UpdateHealth(); //This is line 46
%this.schedule(250, doHealthUpdate, %obj);
%obj.healthTimer++;
}
else
%obj.healthTimer = 0;
}
EDIT: Apparently 'I' was object '6703' and it kept trying to update me even tho I had exited. I commented out all but %obj.healthTimer = 0;
and I'm not getting the console spam anymore. It's just a temporary health thing for me anyway. Once we get the rest of the mechanics in place I doubt we'll even use the health kit as it sits, but for now, for testing...it was needed.
So, thanks for all of your help! Just think of the many lives you've saved not to mention the dental bills!
03/19/2010 (12:25 pm)
Hey! That cured the health kit problem but now I'm getting massive console spam saying scripts/server/health.cs (46): Unable to find object: '6703' attempting to call function 'UpdateHealth'
What does that mean?
Here's the function in server/health.cs
function HealthPatch::doHealthUpdate(%this, %obj)
{
if (%obj.healthTimer < 40) // 40 = 10 seconds at 1 iteration per 250 ms.
{
%obj.UpdateHealth(); //This is line 46
%this.schedule(250, doHealthUpdate, %obj);
%obj.healthTimer++;
}
else
%obj.healthTimer = 0;
}
EDIT: Apparently 'I' was object '6703' and it kept trying to update me even tho I had exited. I commented out all but %obj.healthTimer = 0;
and I'm not getting the console spam anymore. It's just a temporary health thing for me anyway. Once we get the rest of the mechanics in place I doubt we'll even use the health kit as it sits, but for now, for testing...it was needed.
So, thanks for all of your help! Just think of the many lives you've saved not to mention the dental bills!
#5
It is a good practice to use when dealing with objects that may not be there from one moment to the next.
03/19/2010 (2:12 pm)
Ok, I had a feeling it was something like that. All you have to do is put a test at the top of the function to see if the object is valid. Like:function HealthPatch::doHealthUpdate(%this, %obj)
{
if(!isObject(%obj))
return;It is a good practice to use when dealing with objects that may not be there from one moment to the next.
Torque Owner Henry Todd
Atomic Walrus
I will mention that the format I'm seeing here,
ItemData::create(HealthKitPatch);
is kind of new to me. I'm used to using the "new whatever" functionality to bring in a new object, not Class::create();. This makes sense logically, but clearly it's related to the problem.
Weapons create new projectiles like so:
%p = new (%this.projectileType)() { dataBlock = %this.projectile; initialVelocity = %muzzleVelocity; initialPosition = %obj.getMuzzlePoint(%slot); sourceObject = %obj; sourceSlot = %slot; client = %obj.client; }; MissionCleanup.add(%p); return %p;and this is generally how I create new objects of other types as well. Obviously something's wrong in the DS.. but I have no idea what. :P