Game Development Community

Post Game Connect Character Selection

by Jon Jorajuria · in Torque Game Engine · 01/03/2006 (4:43 pm) · 6 replies

I have a team select/character select gui system in place based on Xavier "ExoDuS" Amado's and C2's resources. I have run into an issue that maybe somebody could point me in the direction of resolving. It works like this:

1. User connects to game and it then prompted to choose a team.
2. Based upon team selection, the user is presented with a set of Characters.
3. User chooses their character and then spawns in their respective team zone. (Here is the problem)

The player variable is set clientside under the following $pref::Player::Armor and is loaded during the following functions:

function SM_StartMission()
function JoinServerGui::join(%this)

I need to figure out a way to load the value from $pref::Player::Armor so that it will affect the following code post game connect:

%player = new Player() {
dataBlock = %this.armor;
client = %this; };

I tried to keep my explaination simple, but I am willing to explain in more detail and provide code snipets. I know that this is something very simple and I am just missing it. I am a programming noob and any help would be much appreciated. Thank you in advanced for your help.

#1
01/03/2006 (5:11 pm)
I'd be interested in the ability to change the model selection choice post-game-connect as well.
#2
01/03/2006 (5:20 pm)
I thought I had it working last night, but I was denied.
#3
01/04/2006 (2:55 am)
Well... seeing as it appears to be a variable on your client object... just change your %this.armor variable to whatever new datablock you want while in game...
#4
01/04/2006 (7:28 am)
Here is what I am doing, maybe somebody can tell me what I am doing wrong...

In the gui.cs I have this under one of the functions:

commandtoserver('spawnPlayer', Model01Armor);

In fps/server/scripts/commands.cs I have the following function:

function serverCmdspawnPlayer(%client,%armor)
{
%client.spawnPlayer(%armor);
}

In fps/server/scripts/game.cs here is GameConnection::spawnPlayer:

function GameConnection::spawnPlayer(%this, %armor)
{
// Combination create player and drop him somewhere
%spawnPoint = pickSpawnPoint(%this);
%this.createPlayer(%spawnPoint, %armor);
}

Finally it calls:

function GameConnection::createPlayer(%this, %spawnPoint, %armor)
{
if (%this.player > 0) {
// The client should not have a player currently
// assigned. Assigning a new one could result in
// a player ghost.
error( "Attempting to create an angus ghost!" );
}

// Create the player object
%player = new Player() {
dataBlock = %this.armor; //<---TRYING TO EFFECT THIS
client = %this;
};
MissionCleanup.add(%player);

// Player setup...
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);

// Starting equipment
%player.setInventory(Sword,1);
%player.setInventory(pistol,1);
%player.setInventory(pistolAmmo,10);
%player.mountImage(pistolImage,0);


// Update the camera to start with the player
%this.camera.setTransform(%player.getEyeTransform());

// Give the client control of the player
%this.player = %player;
%this.setControlObject(%player);
}

What am I doing wrong?
#5
01/04/2006 (8:33 am)
Isn't the player-selected variable you need the parameter passed into GameConnection::createPlayer? That would be %armor, not %this.armor, unless you actually set the value of %this.armor somewhere. I don't see any code that sets %this.armor.

So it would be
// Create the player object
%player = new Player() {
dataBlock = %armor; //<---TRYING TO EFFECT THIS
client = %this;
};
#6
01/04/2006 (8:49 am)
Thank you Gary...that did it.