Author Topic: I know you can! Post and get stuff from web/SQL ingame.  (Read 2180 times)

So can someone fix this code for me?
Code:

Code: [Select]
new tcpObject(blocklandConnect);
$connectionAddress = "blockland.us:80";

blocklandConnect::onConnect()
{
echo("Connected!");
}

blocklandConnect::onConnectFailed()
{
echo("Failed!");
}

function serverCmdconzs(%client, %message)
{
blocklandConnect.connect($connectionAdress);
}

You also need a %this for each first arg in all the blocklandConnect functions.

Edit: What would be the issue if I specify it to get a file and it returns me with a 301 error giving me a link to the exact same file I tried to get?
It's case sensitive.  Are you sure you typed it in right?

@Azjherben, add a function before the blocklandConnect like serverCmdconzs

Like this:

Code: [Select]
new tcpObject(blocklandConnect);
$connectionAddress = "blockland.us:80";

function serverCmdconzs(%client, %message)
{
blocklandConnect.connect($connectionAdress);
blocklandConnect::onConnect()
{
echo("Connected!");
}

blocklandConnect::onConnectFailed()
{
echo("Failed!");
}
}




It's case sensitive.  Are you sure you typed it in right?

@Azjherben, add a function before the blocklandConnect like serverCmdconzs
It's all lower case in Blockland and on the web server.

No, you keep them like they were before.  There's a "function" before serverCmdconzs - well do the same thing with the blocklandConnect::onConnect() and ::onConnectFailed()

Here, let me fix it up for ya.

Code: [Select]
new tcpObject(blocklandConnect);
$connectionAddress = "blockland.us:80";

function blocklandConnect::onConnected(%this)
{
echo("Connected!");
}

function blocklandConnect::onConnectFailed(%this)
{
echo("Failed!");
}

function serverCmdconzs(%client)
{
blocklandConnect.connect($connectionAddress);
}

Then go and type /conzs

It sais connected!
Thanks!

So what am I doing wrong?
It connects, so then I send this:
Code: [Select]
"GET /shifta/testfileVer.txt HTTP/1.1\r\nHost: freewebtown.com\r\nUser-Agent: Torque/1.0\r\n\r\n"to try and get a file at:
Code: [Select]
http://www.freewebtown.com/shifta/testfileVer.txtbut instead it gives me this:
Code: [Select]
HTTP/1.1 301 Moved Permanently
Date: Fri, 26 Jun 2009 17:32:20 GMT
Server: Apache
Location: http://www.freewebtown.com/shifta/testfileVer.txt
Content-Length: 257
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.freewebtown.com/shifta/testfileVer.txt">here</a>.</p>
</body></html>


So what am I doing wrong?
It connects, so then I send this:
Code: [Select]
"GET /shifta/testfileVer.txt HTTP/1.1\r\nHost: freewebtown.com\r\nUser-Agent: Torque/1.0\r\n\r\n"to try and get a file at:
Code: [Select]
http://www.freewebtown.com/shifta/testfileVer.txtbut instead it gives me this:
Code: [Select]
HTTP/1.1 301 Moved Permanently
Date: Fri, 26 Jun 2009 17:32:20 GMT
Server: Apache
Location: http://www.freewebtown.com/shifta/testfileVer.txt
Content-Length: 257
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.freewebtown.com/shifta/testfileVer.txt">here</a>.</p>
</body></html>

Depending on some server configurations, you need to prefix the host with "www." which I am going to assume is the case here.

That was the case. Worked.
Thanks a bunch.

So how do I recive now.
I belive I put "it" after "blocklandConnect.send($comman);" but what is "it"?

Code: [Select]
new tcpObject(blocklandConnect);
$connectionAddress = "blockland.us:80";

function blocklandConnect::onConnected(%this)
{
echo("Connected!");
}

function blocklandConnect::onConnectFailed(%this)
{
echo("Failed!");
}

function serverCmdconzs(%client)
{
blocklandConnect.connect($connectionAddress);
$comman = "GET /index.php HTTP/1.1\r\nHost: blockland.us\r\nUser-Agent: Torque/1.0\r\n\r\n";
blocklandConnect.send($comman);
}

Code: [Select]
function blocklandConnect::onLine(%this,%line)
{
//do stuff
}

So....


Code: [Select]
new tcpObject(blocklandConnect);
$connectionAddress = "blockland.us:80";

function blocklandConnect::onConnected(%this)
{
echo("Connected!");
}

function blocklandConnect::onConnectFailed(%this)
{
echo("Failed!");
}

function serverCmdconzs(%client)
{
blocklandConnect.connect($connectionAddress);
$comman = "GET /index.php HTTP/1.1\r\nHost: blockland.us\r\nUser-Agent: Torque/1.0\r\n\r\n";
blocklandConnect.send($comman);
}

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


Would that echo the code of index.php back to me?

Why don't you try it out?

(Tip: Change $line to %line)