Ai Bot Score Problems
by Abdullah Bade · in Torque Game Engine · 10/03/2006 (10:21 am) · 23 replies
I'm trying to add score for bot using GameOne tutorial. But it doesnt work? Any idea why? This is the code.
function Nos::onCollision(%this,%obj,%col)
{
if(%col.getClassName() $="AIWheeledVehicle")
{
%client=%col.client;
%client.score++;
commandToClient(%client,'SetScoreCounter',%client.score);
%obj.delete();
%nosCount=Noss.getCount();
if(%nosCount>0)
return;
commandToClient(%client,'ShowVictory',%client.score);
}
}
And also what is SPC in clientGames.cs?
function clientCmdSetScoreCounter(%score)
{ ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdShowVictory(%score)
{ MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
"loadMission();",
"quit();");
}
function Nos::onCollision(%this,%obj,%col)
{
if(%col.getClassName() $="AIWheeledVehicle")
{
%client=%col.client;
%client.score++;
commandToClient(%client,'SetScoreCounter',%client.score);
%obj.delete();
%nosCount=Noss.getCount();
if(%nosCount>0)
return;
commandToClient(%client,'ShowVictory',%client.score);
}
}
And also what is SPC in clientGames.cs?
function clientCmdSetScoreCounter(%score)
{ ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdShowVictory(%score)
{ MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
"loadMission();",
"quit();");
}
About the author
#2
10/06/2006 (2:19 am)
Same thing with me cant get the score gui to work. Typed the same code as you for GameOne but doesnt work. well anyway im going to stick to this thread so i can hear for an answer.
#4
Im stuck on the getting started tutorial with the score code. I wrote it exactly how it said but even though i bang in to things my score doesnt go up. anyone got an solution?
10/06/2006 (4:26 am)
Hi, you answered his problem but not myn.Im stuck on the getting started tutorial with the score code. I wrote it exactly how it said but even though i bang in to things my score doesnt go up. anyone got an solution?
#5
Im stuck on the getting started tutorial with the score code. I wrote it exactly how it said but even though i bang in to things my score doesnt go up. anyone got an solution?
10/06/2006 (4:39 am)
Hi, you answered his problem but not myn.Im stuck on the getting started tutorial with the score code. I wrote it exactly how it said but even though i bang in to things my score doesnt go up. anyone got an solution?
#6
My guess is that %client is not valid for the AI player because usually they don't use the GameConnection class and therefore don't have an associated client object.
Try putting after the line
If the client object is zero, then you should read the link I posted above. In those posts I describe how to "fake" a client object for AI players.
edit: semicolon missing...
10/06/2006 (5:30 am)
Well, one problem after the other... :-)My guess is that %client is not valid for the AI player because usually they don't use the GameConnection class and therefore don't have an associated client object.
Try putting after the line
%client=%col.client;
echo("client id: " @ %client);and you will see if the client object is 0 (what my guess is).If the client object is zero, then you should read the link I posted above. In those posts I describe how to "fake" a client object for AI players.
edit: semicolon missing...
#7
10/06/2006 (6:52 am)
If you are talking to me thats not what i ment but. i ment ... well first of all if youve done the getting started tutorial then you know what i mean i ment that when i create the file clientGame.cs and all those code that i have to put it doesnt make my score that i made with an play gui. This might help you understand better.
#8
10/06/2006 (7:38 am)
Are talking about player or AIplayer. If u talkin about player, you should read the tutorial carefully , bcoz at first i cant make it it work to. If i'm not mistaken what i did wrong was load the object from starter.racing not Items. You also should be sure to apply name to the GUI "Score:0" to ScoreCounter
#9
im going to study the code one more time then im going to need some answers.
10/06/2006 (8:09 am)
Im talking about player and the code not the gui making.im going to study the code one more time then im going to need some answers.
#10
function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdShowVictory(%score)
{
MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
"loadMyMission();",
"quit();");
}
then i edit the main.cs and put in this following code on the bottom of the list of // Client scripts:
exec("./client/clientGame.cs");
then i edit the file in server/scripts/logoitem.cs and add:
function TorqueLogoItem::onCollision(%this,%obj,%col)
{
if(%col.getClassName()$="Player")
{
%client = %col.client;
%client.score++;
commandToClient(%client,'SetScoreCounter*,%client.score);
%obj.delete();
%logoCount = logos.getCount();
if(%logoCount>0)
return;
commandToClient(%client,'ShowVictory',%client.score);
}
}
Now will you please show me what i did wrong?
10/06/2006 (8:19 am)
Ok now im going to give info of the code. I create a file in client/scripts called clientGame.cs it contains:function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdShowVictory(%score)
{
MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
"loadMyMission();",
"quit();");
}
then i edit the main.cs and put in this following code on the bottom of the list of // Client scripts:
exec("./client/clientGame.cs");
then i edit the file in server/scripts/logoitem.cs and add:
function TorqueLogoItem::onCollision(%this,%obj,%col)
{
if(%col.getClassName()$="Player")
{
%client = %col.client;
%client.score++;
commandToClient(%client,'SetScoreCounter*,%client.score);
%obj.delete();
%logoCount = logos.getCount();
if(%logoCount>0)
return;
commandToClient(%client,'ShowVictory',%client.score);
}
}
Now will you please show me what i did wrong?
#11
function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdShowVictory(%score)
{
MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
"loadMyMission();",
"quit();");
}
then i edit the main.cs and put in this following code on the bottom of the list of // Client scripts:
exec("./client/clientGame.cs");
then i edit the file in server/scripts/logoitem.cs and add:
function TorqueLogoItem::onCollision(%this,%obj,%col)
{
if(%col.getClassName()$="Player")
{
%client = %col.client;
%client.score++;
commandToClient(%client,'SetScoreCounter*,%client.score);
%obj.delete();
%logoCount = logos.getCount();
if(%logoCount>0)
return;
commandToClient(%client,'ShowVictory',%client.score);
}
}
Now will you please show me what i did wrong?
10/06/2006 (8:21 am)
Ok now im going to give info of the code. I create a file in client/scripts called clientGame.cs it contains:function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdShowVictory(%score)
{
MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
"loadMyMission();",
"quit();");
}
then i edit the main.cs and put in this following code on the bottom of the list of // Client scripts:
exec("./client/clientGame.cs");
then i edit the file in server/scripts/logoitem.cs and add:
function TorqueLogoItem::onCollision(%this,%obj,%col)
{
if(%col.getClassName()$="Player")
{
%client = %col.client;
%client.score++;
commandToClient(%client,'SetScoreCounter*,%client.score);
%obj.delete();
%logoCount = logos.getCount();
if(%logoCount>0)
return;
commandToClient(%client,'ShowVictory',%client.score);
}
}
Now will you please show me what i did wrong?
#12
function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdShowVictory(%score)
{
MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
"loadMyMission();",
"quit();");
}
then i edit the main.cs and put in this following code on the bottom of the list of // Client scripts:
exec("./client/clientGame.cs");
then i edit the file in server/scripts/logoitem.cs and add:
function TorqueLogoItem::onCollision(%this,%obj,%col)
{
if(%col.getClassName()$="Player")
{
%client = %col.client;
%client.score++;
commandToClient(%client,'SetScoreCounter*,%client.score);
%obj.delete();
%logoCount = logos.getCount();
if(%logoCount>0)
return;
commandToClient(%client,'ShowVictory',%client.score);
}
}
Now will you please show me what i did wrong?
10/06/2006 (8:24 am)
Ok now im going to give info of the code. I create a file in client/scripts called clientGame.cs it contains:function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdShowVictory(%score)
{
MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
"loadMyMission();",
"quit();");
}
then i edit the main.cs and put in this following code on the bottom of the list of // Client scripts:
exec("./client/clientGame.cs");
then i edit the file in server/scripts/logoitem.cs and add:
function TorqueLogoItem::onCollision(%this,%obj,%col)
{
if(%col.getClassName()$="Player")
{
%client = %col.client;
%client.score++;
commandToClient(%client,'SetScoreCounter*,%client.score);
%obj.delete();
%logoCount = logos.getCount();
if(%logoCount>0)
return;
commandToClient(%client,'ShowVictory',%client.score);
}
}
Now will you please show me what i did wrong?
#13
10/06/2006 (8:24 am)
Lol srry for the tripple post whenever i press back on my browser it does another post so hope it doesnt mind
#14
logos,have put your logo inside simGroup name logos?
10/06/2006 (8:30 am)
%logoCount = logos.getCount();logos,have put your logo inside simGroup name logos?
#15
10/06/2006 (8:54 am)
Hmm ill try that
#16
10/06/2006 (9:07 am)
God, not working still! i made an simgroup named logos as it asked and then dragged all the logo items in the simgroup then i saved the mission and closed torque then ran it again. same problem wait let me check the console. otherwise have any other idea?
#17
commandToClient(%client,'SetScoreCounter*,%client.score);
do you notice anything wrong with the syntax if you do tell me please and fast <:)
once i get this working my parents will be so proud :) im only 10 years old by the way.
but dont worry i understand what your saying.
10/06/2006 (9:11 am)
Ahh found the error but dont know whats wrong i looked in the console when the game was running it said it had an syntax error in line 18 in logoitem.cs line 18 is:commandToClient(%client,'SetScoreCounter*,%client.score);
do you notice anything wrong with the syntax if you do tell me please and fast <:)
once i get this working my parents will be so proud :) im only 10 years old by the way.
but dont worry i understand what your saying.
#18
10/06/2006 (9:12 am)
Is the problem that it has to be %player and not %client?
#19
10/06/2006 (9:59 am)
CommandToClient(%client,'SetScoreCounter',%client.score);
#20
10/06/2006 (10:00 am)
Look carefully
Torque Owner Abdullah Bade