Set Datablock crashes game?
by Michael Shah · in Torque Game Engine Advanced · 07/02/2010 (2:52 pm) · 1 replies
Hello, I am trying to SetDatablock in my networked game, and it crashes instantly. Below is some source.
My intention is to use the Set Datablock for a character selection screen. The characters being swapped have animations, and again, this is a networked game.
The host can successfully change characters, but none of the clients can or else the game will crash instantly.
What is going on here, or is there a better way to approach this problem?
Here is the code I have written:
// Example of choosing male character from male selection screen
function serverCmdchooseMaleCharacterServer(%client)
{
if(%client.player.getDataBlock() $="CasualMaleBody")
{
echo("Client "@%client@"is already Male");
}
else
{
if(isObject(%client.player))
{
%client.player.setDataBlock("CasualMaleBody");
}
}
}
Thank you for your help and concerns.
My intention is to use the Set Datablock for a character selection screen. The characters being swapped have animations, and again, this is a networked game.
The host can successfully change characters, but none of the clients can or else the game will crash instantly.
What is going on here, or is there a better way to approach this problem?
Here is the code I have written:
// Example of choosing male character from male selection screen
function serverCmdchooseMaleCharacterServer(%client)
{
if(%client.player.getDataBlock() $="CasualMaleBody")
{
echo("Client "@%client@"is already Male");
}
else
{
if(isObject(%client.player))
{
%client.player.setDataBlock("CasualMaleBody");
}
}
}
Thank you for your help and concerns.
About the author
Uses Torque for Research
Torque 3D Owner Caylo Gypsyblood
Datablocks are a chunk of information used to represent EVERY ONE of that object in the game, once the game is started the server sends this information to the clients, this information is not designed to be changed once it is defined and IN PLAY.
%this.setDataBlock is designed to work its best before the object is in the game, such as reconfiguring a default object by script. I do not believe it will work as expected in a network situation (All my attempts doing near exact the same thing you are try to do have failed).
The method i have used with success is to define one basic datablock, and use datablock inheritance to repopulate it with the specific game mechanics information it will need. I then use script objects to handle individual game player dynamic data.
See subjects such as this:
www.torquepowered.com/community/forums/viewthread/2666
And other forum searches on the subject like this one:
www.torquepowered.com/community/forums/viewthread/77072
And research about this:
www.torquepowered.com/community/forums/viewthread/32774
EDIT: Fixed a bad link