Game Development Community

Mysterious commandToClient failure

by DevinJ88AZ · in Torque Game Engine · 05/01/2012 (7:11 am) · 9 replies

I am trying to get an image in a GuiBitmapCtrl to show up after a collision with an object. I was using the the Torque logo, so here's the beginning of my code for logoitem.cs :

datablock StaticShapeData(TorqueLogoItem)
{
   category = "Items";
   shapeFile = "~/data/shapes/3dtorquelogo/torque_logo.dts";
};

function TorqueLogoItem::onCollision(%this, %obj, %col)
{
	
	
    if(%col.getClassName() $= "Player")
    {
        %client = %col.client;
        %obj.delete();
	commandToClient(%client,'DisplayWeaponGui',"~/client/ui/weaponui.jpeg");

    }
}

Now on the client side in my clientGame.cs file I simply put:

function clientCmdDisplayWeaponGui(%image)
{

	weaponDisplayGUI.setBitmap(%image);

}

weaponDisplayGUI being the name for my GuiBitmapCtrl I wish to output to. Upon collision the console spits out "clientCmdDisplayWeaponGui: Unknown command."

How can I get torque to recognize it?
Thanks.

About the author

Recent Threads

  • Cant Use Triggers

  • #1
    05/01/2012 (8:48 am)
    Did you check to see if you have any console errors relating to the compiling of the clientGame.cs file?
    #2
    05/01/2012 (4:46 pm)
    Hello,

    There aren't any syntax errors, but some other problems that may not be related to problem here. I'll put up the console log. It was too big to directly paste into the forums here, so I uploaded to a free text host. Sorry for the inconvenience:

    freetexthost.com/njlutqjmoe
    #3
    05/01/2012 (5:40 pm)
    It's loading compiled scripts. Did you make sure to clear those out before testing? If not, Torque tends to roll with what's compiled, and that's bit many people on the ass (myself included).
    #4
    05/01/2012 (8:45 pm)
    I've deleted all the compiled scripts and reloaded the engine. I still have the same problem. I am completely stumped over this. I've even gone as far to start with a fresh tutorial.base. Still the same problem with the engine not recognizing my clientCmdDisplayWeaponGui.
    #5
    05/02/2012 (3:09 am)
    commandToClient(%client,'DisplayWeaponGui',"~/client/ui/weaponui.jpeg");
    Just a thought, but try passing that last parameter as a full absolute path:
    commandToClient(%client,'DisplayWeaponGui',"tutorial.base/client/ui/weaponui.jpeg");
    #6
    05/02/2012 (3:55 am)
    Thanks for the help so far guys,

    I tried using an absolute path but still no go. The same error again; it's not recognizing the function.
    #7
    05/02/2012 (5:23 am)
    I checked the console again and realized after I put an absolute path in I get a syntax error.

    commandToClient(%client,'DisplayWeaponGUI',"C:\Torque1.4.2\SDK\example\RKR\client\ui\weaponui.jpeg");

    I am not sure why putting the full path in created an error.
    #8
    05/02/2012 (5:49 am)
    If you're going to write the path like that, then you need to write the string with escape characters for the back slashes ("\\" instead of "\"). I would turn off compiling scripts until you can figure out why your clientCmd isn't executing, or create a test clientCmd that takes no parameters and see if that executes. Also, if it's just that one function, check and see that it's not sharing a name with a non-clientCmd function, and if it is, change the name of your clientCmd.
    #9
    05/02/2012 (9:15 am)
    Not the full path that you show starting at C:, but the project level full path that I showed for you.

    Your code works for me, however it gave an error about not finding the image, until I changed the path as demonstrated.