Getting the client name?
by Anthony · in Torque Game Engine · 01/31/2006 (1:56 am) · 8 replies
I am trying to grab the clients name, but it is returning a number, here is the code I am using:
I cannot find a sprintf like command, did a search and found one who wrote one, but it does not seem to work very well.
Thanks!
for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) {
%cl = ClientGroup.getObject( %clientIndex );
commandToClient(%cl, 'GameEnd');
// at this point we need to establish a connection with the BBiGames database
// and send all the players deaths and kills
%userid = %cl.name;
echo(%userid);
%result = DB::Select("*","users","userid = '" @ %userid @ "'");
...
$db.Execute(%update);
}I cannot find a sprintf like command, did a search and found one who wrote one, but it does not seem to work very well.
Thanks!
#2
this is the code I got
Any ideas?
01/31/2006 (6:10 am)
Thank you very much for the help. I have it returning the name, but it has some artifacts attached to the begenning and end:Anthony
this is the code I got
for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) {
%cl = ClientGroup.getObject( %clientIndex );
commandToClient(%cl, 'GameEnd');
// at this point we need to establish a connection with the BBiGames database
// and send all the players deaths and kills
%userid = detag(getTaggedString(%cl.name));
echo(%userid);
%result = DB::Select("*","users","userid = '" @ %userid @ "'");
%kills = %result.kills + %cl.score;
echo(%kills);
...
$db.Execute(%update);
}Any ideas?
#3
01/31/2006 (6:11 am)
P.S. The artifacts don't seem to show on the board.
#4
I cleaned my strings up with this:
01/31/2006 (6:16 am)
Oh, I ran into that too. I think it's formatting code for the chat HUD, etc...I cleaned my strings up with this:
%username = StripMLControlChars(%username);
#5
It seems that there is a hard time retrieving integers from the db. The id returns perfect, but for some reason all other numbers are not being read (they return blank). They are defined as int(11) in the database.
????
01/31/2006 (2:53 pm)
Thank you, it works now, I only have one more problem though.It seems that there is a hard time retrieving integers from the db. The id returns perfect, but for some reason all other numbers are not being read (they return blank). They are defined as int(11) in the database.
????
#6
I guess I'd start by throwing in a few Con::printf's after the C++ code that reads the results, and verify that you're actually pulling the values from the database (or not) before passing them to the scripts.
01/31/2006 (3:27 pm)
I don't know what database nor what 'Torque adapter code' you are using, so I have no idea. I'm using SQLite plus the SQLiteObject resource code for the single player portion of what I'm working on, and haven't seen anything like that. I guess I'd start by throwing in a few Con::printf's after the C++ code that reads the results, and verify that you're actually pulling the values from the database (or not) before passing them to the scripts.
#7
TTYL
- Anthony
02/04/2006 (2:37 pm)
I was using the odbc code from before, I now noticed that a new version has just been released, so I will see if I can add that in. I am running 1.3 right now and am not sure if I want to try to port to 1.4 as last time it messed stuff up (then again I was using a cvs version 1.4 rc2 I believe).TTYL
- Anthony
#8
Seems as though the resource did not want to work with integers or floating point variables. So my solution was to use varchar's for the kills, deaths, ect. It works fine as torque script treats the values as numbers even though they are stores as a character array.
Anyway, just thought I would post my solution.
02/18/2006 (10:32 am)
Just to let anyone who cares know what I found:Seems as though the resource did not want to work with integers or floating point variables. So my solution was to use varchar's for the kills, deaths, ect. It works fine as torque script treats the values as numbers even though they are stores as a character array.
Anyway, just thought I would post my solution.
Torque Owner Brian Hill
I couldn't just use 'detag' as I'd initially expected, since it just returned an empty string.