Game Development Community

ServerCmds

by Fredulus Ripplinger · in Torque Game Engine · 06/16/2008 (12:06 pm) · 6 replies

I got my start in scripting in Blockland. The first things I scripted were ServerCmds, used by typing (for example) /kill Bob. I tried to script a serverCmd in starter.fps. I made sure it got exec'd and everything, but it wouldn't work, so I just deleted it. My question is, are serverCmds activated with a / in TGE, or was that something specific to Blockland?

#1
06/16/2008 (12:21 pm)
ServerCmd's work just fine. I'll need a little more context on what you were trying to do and how you were trying to use it before I can help you any further.
#2
06/16/2008 (7:56 pm)
Nah, it's fine, I just wondered if they were /'s.
#3
06/17/2008 (8:55 am)
Fredulus - ServerCmds are called by running the function CommandToServer() passing in the function name as a tagged parameter.. For example:

On the server
function serverCmdDoSomethingNeat(%client, %param1, %param2)
{
...blah blah
}

To then call that function on the client run:
CommandToServer('DoSomethingNeat', %param1, %param2);

Of course there is nothing to stop you adding things to the engine so that issuing a "/" doesn't run this commandtoserver function.
#4
06/18/2008 (2:32 pm)
"Of course there is nothing to stop you adding things to the engine so that issuing a "/" doesn't run this commandtoserver function."

Wait, DOESN'T run this commandtoserver function? I want it to; now you've confused me. Let's use that code you put up. If I typed /dosomethingneat, would it run the serverCmd or not?
#5
06/18/2008 (3:55 pm)
No, it will not.

CommandToServer is simply a TorqueScript function that, when executed, will send a network event from a client to the server.

If you want to have this code run when the user types in a command, you will need to write the TorqueScript code to interpret the typed command(s), and execute the appropriate TorqueScript commands.
#6
06/20/2008 (8:21 am)
Sorry Fredulus I meant to have said:

Of course there is nothing to stop you adding things to the engine so that issuing a "/" does run this commandtoserver function.