On choose team, change skin problem
by Rafael Marques · in Technical Issues · 04/10/2007 (7:04 pm) · 4 replies
Hello,
I'm creating a game (king of the hill/CTF) and in the game the auto-join choose automatically the team with less players. Working fine.
But when i try to change the skin based on the variable $Team1 and $Team2, it don't change.
when i create the player %player.setSkinName('red'); works fine.
function GameConnection::createPlayer(%this, %spawnPoint)
{
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 = PlayerBody;
client = %this;
};
MissionCleanup.add(%player);
// Player setup...
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
if($Team1 == %player.team)
{
%player.setSkinName('red');
}
// Starting equipment
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,10);
%player.mountImage(CrossbowImage,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);
}
is not working.. but if i can get the client ID, i could do 1587.setSkinName('red'); (where 1587 is the client ID)
Can you help me?
I'm creating a game (king of the hill/CTF) and in the game the auto-join choose automatically the team with less players. Working fine.
But when i try to change the skin based on the variable $Team1 and $Team2, it don't change.
when i create the player %player.setSkinName('red'); works fine.
function GameConnection::createPlayer(%this, %spawnPoint)
{
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 = PlayerBody;
client = %this;
};
MissionCleanup.add(%player);
// Player setup...
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
if($Team1 == %player.team)
{
%player.setSkinName('red');
}
// Starting equipment
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,10);
%player.mountImage(CrossbowImage,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);
}
is not working.. but if i can get the client ID, i could do 1587.setSkinName('red'); (where 1587 is the client ID)
Can you help me?
#2
Well, last night, with a lot of coffee e've figured out a way to get the ID from the player and change the skin creating a function and calling setskinname when the player join the group.
The real problem was finding the ID from the client, it's solved.
But thanks a lot! If you have somebody have interest in see how i'll be glad to share the solution.
Rafael Marques
04/11/2007 (9:27 am)
Thanks for the reply John, thats because I love this community!Well, last night, with a lot of coffee e've figured out a way to get the ID from the player and change the skin creating a function and calling setskinname when the player join the group.
The real problem was finding the ID from the client, it's solved.
But thanks a lot! If you have somebody have interest in see how i'll be glad to share the solution.
Rafael Marques
#4
somebody did it or can give a light?
04/11/2007 (2:22 pm)
Nope, was %client.player, now i'll try to change some other attributes of the player on the fly.. shape, jump height and etc..somebody did it or can give a light?
Torque Owner John Doppler Schiff
I've run into the same problem. It may be that you're trying to set the skin before the engine has had time to create the player. Try scheduling setSkinName with a hefty delay for starters. For example:
if($Team1 == %player.team) { player.schedule(5000, 'setSkinName', 'red' ); }If that works, you can try decreasing the delay.
Good luck,
-- JohnDopp