Naming a player from the command line
by Yonatan Betzer · in Technical Issues · 03/17/2007 (3:21 pm) · 2 replies
I've got a silly problem I can't solve, I'm on it for the last 20 hours - any help would be welcome :
I am creating a game with a dedicated server. upon client connection, I would like to take the client directly into the game screen. This works fine, only I can't set the client's name from the command line !
I have tried to add this to my parseArgs() :
case "-connect":
$argUsed[%i]++;
if (%hasNextArg) {
$JoinGameAddress = %nextArg;
$argUsed[%i+1]++;
$Pref::Player::Name = $Game::argv[%i+2];
$argUsed[%i+2]++;
%i++;
%i++;
}
but it doesn't work like it should... It does not change the name on the Client level, nor do I have access to the changed $Pref::Player::Name from the client.
I have also tried using commandToClient, as well as a thousand other approaches, with no luck.
All other parts of my little scheme work fine - including setting the port from the command line - and this is the only part missing !
I am creating a game with a dedicated server. upon client connection, I would like to take the client directly into the game screen. This works fine, only I can't set the client's name from the command line !
I have tried to add this to my parseArgs() :
case "-connect":
$argUsed[%i]++;
if (%hasNextArg) {
$JoinGameAddress = %nextArg;
$argUsed[%i+1]++;
$Pref::Player::Name = $Game::argv[%i+2];
$argUsed[%i+2]++;
%i++;
%i++;
}
but it doesn't work like it should... It does not change the name on the Client level, nor do I have access to the changed $Pref::Player::Name from the client.
I have also tried using commandToClient, as well as a thousand other approaches, with no luck.
All other parts of my little scheme work fine - including setting the port from the command line - and this is the only part missing !
#2
changes connect($JoinGameAddress, "", $pref::Player::Name);
for :
%conn = new GameConnection(ServerConnection);
%conn.setConnectArgs($UserNameFromCommandLine);
%conn.connect($JoinGameAddress);
and :
case "-connect":
$argUsed[%i]++;
if (%hasNextArg) {
$JoinGameAddress = %nextArg;
$argUsed[%i+1]++;
$UserNameFromCommandLine = $Game::argv[%i+2];
$argUsed[%i+2]++;
%i++;
%i++;
}
03/20/2007 (9:55 am)
GOT IT !changes connect($JoinGameAddress, "", $pref::Player::Name);
for :
%conn = new GameConnection(ServerConnection);
%conn.setConnectArgs($UserNameFromCommandLine);
%conn.connect($JoinGameAddress);
and :
case "-connect":
$argUsed[%i]++;
if (%hasNextArg) {
$JoinGameAddress = %nextArg;
$argUsed[%i+1]++;
$UserNameFromCommandLine = $Game::argv[%i+2];
$argUsed[%i+2]++;
%i++;
%i++;
}
Torque Owner Yonatan Betzer
it seems, though, that the sample's GUI uses $Pref::Player::Name as a variable that controls the user's name. when I try to use it - I get the value stored on the server, and can not change it until the server is reloaded.