Game Development Community

RPGdialog and commandToClient is driving me nuts

by Marcus Fernstrom · in Torque Game Engine · 04/09/2009 (4:30 pm) · 4 replies

I'm using the RPGDialog and I'm trying to make it work with a 3D arrow resource I implemented.

They both work, but I can't get my head around the commandtoClient functions....

The RPGDialog runs the answer-function server-side, so I'm trying to implement a simple commandToClient in order to execute a command that sets the arrow point at a certain object.

The command for the arrow is $aimTarget = (towncenter.GetID());

It's that simple but damnit I can't get the command to run.

In the server side I have:

function showtown()
{
commandToClient(%client, 'towncenter');
}

and on the client side I have:

function clientCmdtowncenter()
{
echo("So far so good");
$aimTarget = (towncenter.GetID());
}

I put that echo in there just to see if it triggers at all, and it doesn't.

In the RPGdialog I put towncenter as the command to run when I click that answer, and in the RPGDialogs scripts I've put that function towncenter.

Anyone know what I'm doing wrong?

I get no errors in the console, it just doesn't trigger and I can't figure out why not.

--EDIT--

No surrender!
I got it working.

I'm not sure *why* this works, but it does.

All I really did was adding %client and %sender in the function showtown() so now it reads function showtown(%client,%sender) and it works ^_^

#1
04/10/2009 (12:27 am)
function showtown()
{
commandToClient(%client, 'towncenter');
}
Well, with this function, %client is not defined anywhere. You need to provide some value for %client.

If you add %client and %sender, these values will exist so something will happen. However, how are you calling the function showtown? If you don't pass values for %client and %sender, it may not work the way you expect.
#2
04/10/2009 (6:30 am)
I'm not sure what you mean Daniel, I saw that in the other functions in RPGDialog, the values %client and %sender were always present, so I just added that and it works (Haven't tried on dedicated server though).

All I really needed was for the answer to send a commandToClient to trigger a function client-side and this *seem* to have done the trick.

If you can think of a better solution I'm all ears, I'm new to this so I don't really know what's the best way to do things, or difference between ways to do things etc.
I just found that this seems to work for me to call a commandToClient.

The showtown function is called from the RPGDialog, I just modified the test dialog that came with it to try out the function I wanted, so when I click the answer "Show me the way to town" it triggers the function showtown, which sends the commandToClient and sets the 3D arrow pointing at a rock in the middle of town. (I know I know... but the map I'm using I just use to test out functions and stuff like that so a rock in the smack middle of town worked. lol)

RPGDialog is an old resource but it seems to work nicely for what I need :) I'm just going to modify it like I do with all the resources I use (Yuck, never use a "standard" resource in a pro release...)
#3
04/10/2009 (12:52 pm)
Ah, okay, sorry - I didn't register you were working within the framework of an existing resource. If you're passing values into showtown(...) like any other function the resource uses, then you should be fine ;).
#4
04/10/2009 (2:08 pm)
Oh!

I think I should have been more clear on that, yeah I'm using a resource from the forum here.

I've ran into another problem (Of course) though I made a new thread about that since this was stupidly specifically named according to the help I needed.

I want to thank you for your input Daniel, you seem to be around a lot when I need help, I'm so gonna send you a cookie some day. hehe