Game Development Community

getSubStr troubles

by Wayne Eversole · in General Discussion · 07/14/2011 (1:01 pm) · 10 replies

Hello everyone.

I have info returning from my php like so

echo $players_name, "+++", $players_kills, "+++", $players_deaths, "+++", $players_score, " Verified";

witch output into torque like this.


Recaci+++10+++5+++0 Verified
Recaci+++10+++5+++0 Verified
ecaci+++10+++5+++0 Verified
caci+++10+++5+++0 Verified

Here is my getSubStr and echo's.

%posSep = strpos(%line, "+++");
if (%posSep == 0)
return;
%len = strlen(%line);
%players_name = getSubStr(%line, 0, %posSep);
%players_kills = getSubStr(%line, %posSep + 1, %len - %posSep + 1);
%players_deaths = getSubStr(%line, %posSep + 2, %len - %posSep + 2);
%players_score = getSubStr(%line, %posSep + 3, %len - %posSep + 3);



echo (%players_name);
echo (%players_kills);
echo (%players_deaths);
echo (%players_score);

What I need is to have each echo to contain its own value without the +++ and without all the other info.

Any tips?

Thanks

#1
07/14/2011 (1:05 pm)
Also , I tried my hand at modeling if anyone is interested.
There are some screen shots on my website.

http://recaci.freezoka.net/
#2
07/14/2011 (1:55 pm)
Would be much easier if your php returned spaces instead of "+++". With spaces you can directly use getWord().
#3
07/14/2011 (2:31 pm)
What would be the syntax to use getWord() ?
#4
07/14/2011 (2:40 pm)
// lets say
// %line = "Recaci 10 5 0 Verified"

%players_name = getWord(%line, 0);
%players_kills = getWord(%line, 1);
%players_deaths = getWord(%line, 2);
%players_score = getWord(%line, 3);

You can also use TABs instead of spaces and use getField(), or NL (new line) and use getRecord().

This is good to have at hand.
#5
07/14/2011 (2:44 pm)
Thanks. I will give this a shot.
#6
07/14/2011 (3:45 pm)
Works like a charm.

Thanks Novack
#7
07/14/2011 (3:51 pm)
Glad to help.
#8
07/14/2011 (5:08 pm)
Anything special I need to do in order to display those values in a gui?

Thanks
#9
07/14/2011 (8:05 pm)
Here, check this out for a better understanding of how the GUIs work in Torque.

You should look under the GUI Editor section, but dont hesitate on taking some time to read over the whole material, will help you save tons of time.
#10
07/15/2011 (9:03 am)
Sweet thank you.
I will give this a long look over.