Mmh I made an "internet" plugin for a test game (an online chess game...). The plugin is not yet finished, but 5 functions are operational:
void InitPostContent();
void AddPostContent(string variable, string content);
string SendWebPostMethod(string url, string action);
string ReadWebContent(string url, string action);
string SaveWebImage(string url, string action, string destFile);The first three functions work the way an html form works, with the POST method:
-
InitPostContent will initialize variables and values.
-
AddPostContent will add a variable containing a value.
Example:
AddPostContent("test", "a value"); would work the same way as a form object in a web page :
<input type="hidden" name="test" value="a value">-
SendWebPostMethod simply submit variables and values to an url, the same way a form works, and then returns the page content as a string.
Example:
SendWebPostMethod("http://www.test.com/score.php", "?action=newscore"); would work the same way as if you submited a form with these parameters:
<form action="http://www.test.com/score.php?action=newscore" method="POST">-
ReadWebContent returns the content of a web page.
Example:
String buffer;
StrCopy(buffer, ReadWebContent("http://www.test.com/ags/agssave.001", "") );
File *output = File.Open("agssave.001", eFileWrite);
output.WriteRawLine(buffer);
output.Close();This will copy the agssave from a website into the game folder.
Note: You could do the same thing with
SendWebPostMethod as it also returns the url content.
-
SaveWebImage will copy an image from an url into your game folder :
Example:
DynamicSprite * avatar;
SaveWebImage("http://www.test.com/images/avatar.bmp", "", "data/avatars/avatar.bmp");
avatar = DynamicSprite.CreateFromFile("data/avatars/avatar.bmp");
if (avatar != null) {
RawDrawImage(150, 100, avatar.Graphic);
avatar.Delete();
}You'll find more info in the zip file.
ags_filenet.zip, 145ko
Download
(http://www.digitalmindstudio.ch/fichiers/divers/ags_filenet.zip)
Wow, fantastic work!
What else did you have planned?
Wow Dorcan, thats awesome!!!
That plugin is great. I will try it out. Also I'm curious how this will develop. There's quite a lot potential in this plugin.
Man, I think I will try to learn to make plugins, too. This increases everybodys options to the max...
Well, I think I'm busy now... Thank you
I've tried this plugin. It seems good but if I try a simple script
String name=lblName.Text;
String p=lblPunteggio.Text;
AddPostContent("name", name);
AddPostContent("points",p );
SendWebPostMethod("http://pexta.altervista.org/score.php");
there is the error
"Cannot convert String* to string"
I can't use "string" because this data type is not supported in 2.72
What can I do?
Is there a way to edit the plugin?
Uncheck "Enforce new-style Strings" in the Game Editor which will allow you to use strings.
string name, p;
StrCopy(name, lblName.Text);
StrCopy(p, lblPunteggio.Text);
AddPostContent("name", name);
AddPostContent("points", p);
SendWebPostMethod("http://pexta.altervista.org/score.php");
Thanks, but now it says
"cannot convert from const string to string"Ã, ???
I hate all these string types :-[
What line gives you that error (what code is on the line)?
All these two
>AddPostContent("name", name);
>AddPostContent("points", p);
And the next was wrong (One parameter instead of two) but if I put two parameters
>SendWebPostMethod("http://pexta.altervista.org/score.php","?random=3");
there is still the const string problem ;__;
Try:
string name, p, lname, lpoints, url, thingy;
StrCopy(name, lblName.Text);
StrCopy(p, lblPunteggio.Text);
StrCopy(lname, "name");
StrCopy(lpoints, "points");
StrCopy(url, "http://pexta.altervista.org/score.php");
StrCopy(thingy, "random=3");
AddPostContent(lname, name);
AddPostContent(lpoints, p);
SendWebPostMethod(url, thingy);