Game Development Community

how to get the data from php to torque 3d game

by mafan · in Torque 3D Beginner · 08/03/2011 (7:51 pm) · 3 replies

currently, i can connect to the php server and successful pass the value from game to the php server, now i wan the reverse, i wan to know how to get the value from php and send to the game engine?

my coding is like the following.

function gameOver()
{
// $isEndGame = true;
$httpObject = new HTTPObject(HTTP);
$httpObject.get("localhost:80", "/webmyTest/sample2.php", "v=1");
echo("gameOverAgain");


}

function HTTP::onLine( %this, %line ){
echo(%line);
}


and my php coding
<?php

require_once("db.php");
$theData = 103;
$a = $_GET['v'];
$sql="INSERT INTO shop_user02 (password, bday) VALUES($a,$theData)";
mysql_query($sql,$con);

echo $a;
?>

i successful send the value from game to php, but now, i want to know how to send the value from php to the torque 3d game engine?

#1
08/04/2011 (8:18 am)
You want to use the HTTPObject::onLine(%obj, %line) callback to parse and use the lines of data that you echo.
#2
08/12/2011 (6:31 am)
Thanks very much, i know how to do already...
#3
08/12/2011 (11:01 am)
Easy, if you use the TCP Object example I showed in one of your earlier posts, you will notice that you have a "POST" request in the argument for the TCP connection. flip it to "GET" and make use of getLine().