No other external tools or programs are required except Game
Maker and a dll.
Firstly to
connect to the internet and use the HTTP protocol in Game Maker. You can either use the readily made mplay_ functions avaliable, but there a bit slow. I recommend using 39dll (
GMC topic) to handle all your winsock calls.
So basically download the dll and scripts for 39dll.
Once you have them heres the code to execute a HTTP protocol:
01 | // HTTP(host, GET/POST,POST variables) |
02 | if !bufferexists(global.HTTP_buffer) |
03 | global.HTTP_buffer=createbuffer(); |
04 | //if !tcpconnected(global.HTTP_sock) |
06 | global.HTTP_sock = tcpconnect(argument0, 80, 0); |
09 | show_message("Unable to connect to "+argument0); |
14 | setformat(global.HTTP_sock, 1, chr(13) + chr(10)); |
15 | newLine = chr(13) + chr(10); |
16 | clearbuffer(global.HTTP_buffer); |
17 | writechars(argument1+" HTTP/1.0" + newLine,global.HTTP_buffer); |
18 | writechars("Host: "+argument0 + newLine,global.HTTP_buffer); |
19 | writechars("User-Agent: Shadow Zone/1.0" + newLine,global.HTTP_buffer); |
20 | if is_string(argument2) |
22 | writechars("Content-Type: application/x-www-form-urlencoded"+newLine,global.HTTP_buffer); |
23 | writechars("Content-Length: "+string(string_length(argument2))+newLine,global.HTTP_buffer); |
24 | writechars(newLine+argument2,global.HTTP_buffer); |
26 | //show_message(argument1+" HTTP/1.0" + newLine+"Host: "+argument0 + newLine+newLine+argument2); |
27 | sendmessage(global.HTTP_sock,"",0,global.HTTP_buffer); |
31 | receivemessage(global.HTTP_sock,0,global.HTTP_buffer); |
32 | firstWord = readsep(newLine,global.HTTP_buffer); |
36 | processHeader = false; |
39 | //read important stuff from header... |
42 | clearbuffer(global.HTTP_buffer); |
43 | setformat(global.HTTP_sock, 2); |
47 | size = receivemessage(global.HTTP_sock, 6000,global.HTTP_buffer); |
49 | retVal += readchars(size,global.HTTP_buffer); |
This is how you would use the above code once 39dll and the scripts are implemented into your game.
To open www.nilbd.tk/index.
php:
2 | HTTP("www.nilbd.tk","GET /index.php"); |
This function will return the HTML code of the webpage. I’m not sure how you would parse the HTML code to display it as a webpage but that is how you access a webpage.
~Ad
PS: If you meant to play your games in a web browser refer to csmanoj’s post, but if you wanted to turn your game into a web browser use this post and reply if more help is required.
0 comments:
Post a Comment