Customise Text in End Game gui
by Shaun Evans · in Torque 3D Beginner · 07/09/2013 (8:48 am) · 6 replies
Hi, I am trying to work out how to put the player's score in the end game gui when it comes up via endgame(). I have tried to follow through the code to see where the gui has been called from but I cant find it, would somebody help me please?
#2
07/09/2013 (9:02 am)
oh brilliant thank you. Just need to work out to get the score from the player into it now :)
#3
07/09/2013 (2:37 pm)
in scripts/client/playerList.cs:function PlayerListGui::updateScore(%this, %clientId, %score, %kills, %deaths)
{
%text = PlayerListGuiList.getRowTextById(%clientId);
%text = setField(%text, 1, %score);
%text = setField(%text, 2, %kills);
%text = setField(%text, 3, %deaths);
PlayerListGuiList.setRowById(%clientId, %text);
PlayerListGuiList.sortNumerical(1, false);
PlayerListGuiList.clearSelection();
}In scripts/client/game.cs clientCmdGameEnd() the PlayerListGuiList object is referenced to fill the text lines.
#4
I have got the following code,
function StaticTorqueLogoItem::onCollision (%this, %obj, %col)
{
echo ("Collision with " @ %col.getClassName());
if (%col.getClassName() $= "Player")
{
echo ("Deleting " @ %obj.getClassName());
%obj.delete();
%client = %col.client;
%client.score++;
commandToClient(%client, 'SetScoreCounter', %client.score);
}
}
How do I send it to the right place, also how do I find what is the player's clientID is too please?
07/09/2013 (2:46 pm)
Thanks for this, but having trouble setting the score in the playerListGUI,I have got the following code,
function StaticTorqueLogoItem::onCollision (%this, %obj, %col)
{
echo ("Collision with " @ %col.getClassName());
if (%col.getClassName() $= "Player")
{
echo ("Deleting " @ %obj.getClassName());
%obj.delete();
%client = %col.client;
%client.score++;
commandToClient(%client, 'SetScoreCounter', %client.score);
}
}
How do I send it to the right place, also how do I find what is the player's clientID is too please?
#5
Essentially what you need to do is use this function call to have it send score to the system. To get the client from the player you can use two different routes:
To test for the end of game, you should do some research into the GameCore.cs file. Add a test to the incScore command to see if the score has reached a certain point and end the game if it has.
Good Luck!
07/09/2013 (3:00 pm)
The score in the playerListGUI is controlled by a message callback (See gameCore.cs)function GameCore::incScore(%game, %client, %score, %dontMessageAll)
{
%client.score += %score;
if( !%dontMessageAll )
messageAll('MsgClientScoreChanged', "", %client.score, %client.kills, %client.deaths, %client);
}Essentially what you need to do is use this function call to have it send score to the system. To get the client from the player you can use two different routes:
//Option 1: %client = %player.client; //Option 2: %client = %player.getControllingClient();
To test for the end of game, you should do some research into the GameCore.cs file. Add a test to the incScore command to see if the score has reached a certain point and end the game if it has.
Good Luck!
#6
07/10/2013 (9:36 am)
Quote:... or checkout when/where/how the default game tests against the "EndGameScore" variable with the current score to end a game.
Add a test to the incScore command to see if the score has reached a certain point and end the game if it has.
Torque Owner Richard Ranft
Roostertail Games
The EndGameGui object itself is defined in art/gui/endGameGui.gui.