Game Development Community

Post data from t3d game engine to external location http://myserver.etc/myfile.php file .. please help me..

by SETTIMO EUGEN CRISTIAN · in Torque Developer Network · 08/27/2012 (9:15 am) · 5 replies

if (%this.team.result == 1000)
{
web data send to web page example www.yousitestats.etc/webresult.php

}

The php page request this data:(playername,playerteam,playerdeads,playerkills,teamscore and server id)
Now i have build very small php page sample...i post here code from the 2 page.. resultput.php e and makesql.php "but my problem is not php or mysql"...

<?php
// the php page put the record from t3d to mysql resultput.php

mysql_connect("localhost", "admin", "admin") or die(mysql_error());
mysql_select_db("yourdb") or die(mysql_error());

mysql_query("INSERT INTO gameresult VALUES ('','$_POST[playername]','$_POST[playerteam]','$_POST[playerdeads]',
'$_POST[playerkills]','$_POST[teamscore]','$_POST[serverid]')";

printf("Last inserted game record has id %d\n", mysql_insert_id());

// php file end after next line
?>

Require mysql server and table..

example: php script for table creation

<?php
// Make sql table form game result makesql.php
mysql_connect("localhost", "admin", "admin") or die(mysql_error());
mysql_select_db("yourdb") or die(mysql_error());

// Create a MySQL table in the selected database
mysql_query("CREATE TABLE gameresult(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
playername VARCHAR(155),
playerteam VARCHAR(2),
playerdeads VARCHAR(2),
playerkills VARCHAR(10),
teamscore VARCHAR(10),
serverid VARCHAR(155)")
or die(mysql_error());

echo "Table Gameresult Created!";
// after next link (?>) end of php file...
?>

*********************************************************************

Now the my real problem is to post data from torque to another http location...
Please please help me..

ps: the php example script i know is very basical but in automatic mode can update player record put the data time etc.. and many many info....

#1
08/28/2012 (2:42 pm)
Take a peek at my resource on TCPObjects here:

http://www.garagegames.com/community/resources/view/21123

This should point you in the right direction.
#2
08/28/2012 (3:01 pm)
T3D does have an HTTPObject built in, it's derived from TCPObject and meant specifically for doing gets and posts over http.
#3
08/29/2012 (6:55 am)
Thank you very much.
#4
09/06/2012 (7:36 am)
@Scott: The documentation on how to properly use the POST function for the HTTPObject is highly lacking in example code, unfortunately I could not figure out how to connect it to even the simplest of PHP pages.

Either the HTTPObject or the TCPObject can handle this task, I personally prefer the TCPObject as it is much more versatile and can handle more tasks than a standard HTTPObject.
#5
10/04/2012 (7:25 am)
I am personally using a Direct Socket Connection to Socket Listener on a Java based ESB (Enterprise Service Bus) ... from there it routes the message and performs the necessary actions and then returns a response if required.

For things like chat messages and non-crucial messages ... I pump those messages (in JSON format) to an ActiveMQ system and my same ESB monitors the queue and performs actions on that.

For the last things like Updated News Windows and Authentication, I use a combination of various systems on the ESB.

All my messages are in JSON format and are encrypted ... I am busy looking at Diffie-Hellman for some added security and this may replace the encryption.

This is all part of my Game Stream system. 8-}