A note on Triggers to newbs like me....
by Richard Ranft · in Torque 3D Professional · 09/01/2011 (4:22 pm) · 8 replies
It took me almost three hours to remember that Triggers happen on the server.
At first this is obvious and right, but the details are where I got hung up. I wanted to make sure that I was performing trigger-related actions on the server (naturally) so I set up several serverCmd functions and then called them with commandToServer() from my trigger callbacks. This was dumb.
commandToServer() fails silently when called from the server side. So I just ended up calling my serverCmd functions directly, passing in the required client (%triggeringObject.client) as my first argument and all started working properly.
Anyway, a Tale from the Slightly Stupid Side to learn from. Hope this saves someone a few minutes of bug hunting.
At first this is obvious and right, but the details are where I got hung up. I wanted to make sure that I was performing trigger-related actions on the server (naturally) so I set up several serverCmd functions and then called them with commandToServer() from my trigger callbacks. This was dumb.
commandToServer() fails silently when called from the server side. So I just ended up calling my serverCmd functions directly, passing in the required client (%triggeringObject.client) as my first argument and all started working properly.
Anyway, a Tale from the Slightly Stupid Side to learn from. Hope this saves someone a few minutes of bug hunting.
About the author
I was a soldier, then a computer technician, an electrician, a technical writer, game programmer, and now software test/tools developer. I've been a hobbyist programmer since the age of 13.
#2
Useful things to note for those of us limited to "boxes".
09/02/2011 (11:40 am)
Richard, I take it your on some sort of external server (dedicated server I think the cool kids call it) rather than playing it off of someones desktop?Useful things to note for those of us limited to "boxes".
#3
Yeah, Steve - this is intended to be a multiplayer game out of the gate, so I have to ensure it functions properly no matter how it's hosted. It all worked fine in single player mode.... lol
09/02/2011 (11:41 am)
Good point, Ted - fortunately (?) for me I'm all hats on this one. I can con my buddies into testing once in a while (and then can't get them to stop) but I end up doing everything else myself.Yeah, Steve - this is intended to be a multiplayer game out of the gate, so I have to ensure it functions properly no matter how it's hosted. It all worked fine in single player mode.... lol
#4
Would this work if called from the server?
09/03/2011 (9:05 am)
Richard, just thought...schedule(50, %client, "commandToServer", 'Your_Server_Command');
Would this work if called from the server?
#5
Interesting thing - we found that hosting from within the game allows you to issue console commands from the "host client" as if you were an administrator. I'm wondering if there is some way to achieve this on a dedicated server.
09/03/2011 (5:17 pm)
You know, it might have. I can test it, but I've got that problem licked since the trigger gives me the %client and I just pass it along.Interesting thing - we found that hosting from within the game allows you to issue console commands from the "host client" as if you were an administrator. I'm wondering if there is some way to achieve this on a dedicated server.
#6
I'm very new to T3D myself and surfing these forums has proven to be one of the better resources so far for "what if" and "how to" scenarios.
10/13/2011 (7:25 pm)
Though I haven't gotten there myself yet, I just wanted to say how much things like this are appreciated. I'm very new to T3D myself and surfing these forums has proven to be one of the better resources so far for "what if" and "how to" scenarios.
#7
At least I think this is what you're asking...
Like you say, games should work in all hosted environments. For the Star Trek game I always test it on the dedicated server (which can easily run on the same machine as the connecting client, even running the exact same executable), and then a standard game with "host" enabled, and finally single player with no hosting.
Quite funny how things behave slightly different depending on which of the above methods is used, it's a real good way to see if you've nailed down the client-server methodology. So far our game performs well in all situations which makes me feel I've done my job :)
10/13/2011 (8:20 pm)
I've played with the dedicated server before... You essentially just create a batch file that launches T3D as dedicated, then it sits there in a CMD prompt window, displaying console events as they happen. If you want to do something as an admin, you just type in that window the full command with closing semi-colon and then hit enter, and the server will perform the action.At least I think this is what you're asking...
Like you say, games should work in all hosted environments. For the Star Trek game I always test it on the dedicated server (which can easily run on the same machine as the connecting client, even running the exact same executable), and then a standard game with "host" enabled, and finally single player with no hosting.
Quite funny how things behave slightly different depending on which of the above methods is used, it's a real good way to see if you've nailed down the client-server methodology. So far our game performs well in all situations which makes me feel I've done my job :)
#8
On the up-side, this appears to have been fixed in 1.2.
10/31/2011 (3:14 pm)
@Paul - Yes, you can do that from the dedicated server cmd window, but if you go to "Play" and then host the game (a client/host setup) the client that hosted in this fashion can issue commands from the ~ console as if they had been typed in the cmd window. Not all commands work, but some do.On the up-side, this appears to have been fixed in 1.2.
Torque 3D Owner Ted Southard