PlayerType is only defined for smart game objects. You should use As_SmartGameObj to test whether you can call GetPlayerType on an object.
Hex's solution is cleaner though.
[edit]
Oh, I see it already does As_SoldierGameObj... It's probably the As_SoldierGameObj call crashing. For TT it calls As_ScriptableGameObj prior to calling As_SoldierGameObj:
GameObject *As_SoldierGameObj(GameObject *obj)
{
if (!Commands->Get_ID(obj) || !obj)
return 0;
ScriptableGameObj* o2 = ((BaseGameObj *)obj)->As_ScriptableGameObj();
if (!o2)
return 0;
return (GameObject *)o2->As_SoldierGameObj();
}
For older versions it probably does not call As_ScriptableGameObj and therefore crash when calling As_SoldierGameObj on a nonscriptable game object.
[Updated on: Wed, 09 July 2008 16:55]
Report message to a moderator