Forum Multiplayer Saving Data with Player.IO?

Discussion and help relating to the PlayerIO Multiplayer API.

Saving Data with Player.IO?

Postby flash_mmo » May 25th, 2010, 2:47 am

Is there any way to save my players data (xp, gold, etc.) with the current state of Player.IO?

I'd like to create a smaller sandbox mmo whereas my players can achieve things, and come back later with kept progress. So I'm guessing the Player.IO SimpleRegister would register them for me, or via the facebook API. I am yet to find any way to keep the data though! :(
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 25th, 2010, 3:01 am

There is no safe way to save data at the moment. There is data persistance being developed, but it's not here yet.
If you REALLY want to persist data and still want to use playerio you have to keep the data in an external web server (with MySQL or something).
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 25th, 2010, 12:34 pm

fox1980 wrote:There is no safe way to save data at the moment. There is data persistance being developed, but it's not here yet.
If you REALLY want to persist data and still want to use playerio you have to keep the data in an external web server (with MySQL or something).

I've seen other MMO's do this, such as Fantasy Online (give it a search on google!).
Uses facebook api to quickly generate login, then saves character progress by each step (I believe).

Although the game is unsimilar to what I want to create, I can see it being clearly functional to create MMO's in Flash, which is an oppurtunity of fast development of which I won't miss being an indie developer.

It lagged a bit, for me, but that might just be their server or where I'm located.
Any ideas on what these guys used?

And how would I go about saving data in MySQL from flash?
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 25th, 2010, 1:18 pm

That's what i'm doing at the moment. You can check my game here: http://apps.facebook.com/soltris
Altough it's just a Tetris clone i do persist data like high-scores, player rankings and a couple of other data.
I'm having my flash client communicate with my PHP server with amfphp. But bear in mind that this method is vunerable to hacking, there is a firefox plugin that can intercept data sent from flash and change it. That's why i said there is no "safe" way to persist data at the moment.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 25th, 2010, 1:44 pm

fox1980 wrote:That's what i'm doing at the moment. You can check my game here: http://apps.facebook.com/soltris
Altough it's just a Tetris clone i do persist data like high-scores, player rankings and a couple of other data.
I'm having my flash client communicate with my PHP server with amfphp. But bear in mind that this method is vunerable to hacking, there is a firefox plugin that can intercept data sent from flash and change it. That's why i said there is no "safe" way to persist data at the moment.

Thank you very much for your quick answers.
I have past experience with hacking both on the front end and securing for it, I can say there's several ways to protect from altering the SQL injections, albeit them being not a hundred percent safe, it's safe to say by an average hacker there wouldn't be much of a threat.

By holding much of the stuff on the client, hacking is always at risk, but you can invent server checks for this, to see if the user is hacking, or if he is gaining an abnormal amount of gold, xp, or traveling too fast. These are all things that could be either implemented in the server end or the flash client. First being most secure, obviously.

I have minor experience with Player.IO as I just tried tweaking some in the examples as of yet, but I plan on making an thorough project with a few friends in a group to develop something of worth during the summer off and on. (as I graduate my Game Dev. college this year).

Would you say writing multiple times per second would work with Flash -> PHP -> SQL? (obviously all at the same computer)
I mean, just by having a PHP MMO up I've experienced that if there's too many online there'll be some nice spike lags if the server doesn't like the idea of so many online. :P

So, for an MMO to be developed on in the future - would a flash->php->sql approach be acceptable for a matter of 100~ users maybe? I'm guessing it will for a while, but the server DB grows etc. Any approach on that you have experience with?
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 25th, 2010, 2:49 pm

I would say any MySQL server on a shared host would handle 100 concurrent connections perfectly fine. Facebook farmville works with a Flash -> amfphp -> PHP approach, and has millions of concurrent users any time. But it's a webserver we're talking about, the response time is way slower than sockets connections. If you're gonna write an MMO that has turn based battles like Dofus online a web server would fit nicely, but if you need fast paced action like World of Warcraft then a sockets server like PlayerIO is totally required. Maybe you can do a combination of both, store the importante variables in the MySQL database, and use PlayerIO for player movement, and other stuff that requires fast response times.
My advice to you: try and focus on other parts of your game, and wait till PlayerIO integrates persistent data. Even if you can get by with a web server, you'll always have bigger latency, it will be easier to hack, and you'll have a harder time scaling it if it get's successfull. Remember PlayerIO takes care of all hardware issues for you.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 25th, 2010, 3:36 pm

fox1980 wrote:I would say any MySQL server on a shared host would handle 100 concurrent connections perfectly fine. Facebook farmville works with a Flash -> amfphp -> PHP approach, and has millions of concurrent users any time. But it's a webserver we're talking about, the response time is way slower than sockets connections. If you're gonna write an MMO that has turn based battles like Dofus online a web server would fit nicely, but if you need fast paced action like World of Warcraft then a sockets server like PlayerIO is totally required. Maybe you can do a combination of both, store the importante variables in the MySQL database, and use PlayerIO for player movement, and other stuff that requires fast response times.
My advice to you: try and focus on other parts of your game, and wait till PlayerIO integrates persistent data. Even if you can get by with a web server, you'll always have bigger latency, it will be easier to hack, and you'll have a harder time scaling it if it get's successfull. Remember PlayerIO takes care of all hardware issues for you.

As I was thinking of setting it up was about this model;

Player connects to Flash, which connects to two parts. The Player.IO server architecture and MySQL.
Player.IO handles everything that is necessary to be seen by other players, like x/y movement, players movement or all in all - everything that can be seen by other players.
The only thing MySQL will handle is the dynamic data which is given persistance at start for the player such as XP, Gold, Last known location (notice that this may as well be a timed update, or an update upon triggered log out so it won't be performance heavy at all) etc. Nothing will be "massively" pummeled into the database as Player.IO will handle this temporarily until the user logs out, saves his/hers location and logs in next time perfectly fine from his/hers last known position! (Thus players will also see the logged in player in his correct position?)

Anyway, I've been thinking a lot and might be missing out on some critical parts. But I value progress over statistics as for now, and if MySQL is the only solution right now - I guess we will try to go for that.
Maybe we can easily port over from MySQL into Player.IO Persistance API when it comes out... I'd love for some easy port to happen there! :) Maybe the devs are even thinking about that as they are completing the API.
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 25th, 2010, 4:23 pm

Even a simple MMO is far more complex than that. Make a good design document on paper first, you'll avoid many roadblocks in the future. The solution you mentioned will make you duplicate a lot of work, you'll have to replicate some functions in both the C# Server and the PHP Server, and you'll have a nightmare of a job keeping them both synced.
I'm in the same situation as you are at the moment, and i also hope for some easy port between MySQL and PlayerIO persistance, i have 5 years experience in MySQL, i hope i don't have to throw all that knowledge away and learn something new.
What i'm doing on the MMO i'm developing is using only PlayerIO without persistance. I'm implementing moving, trading, chatting and i know i'll be busy with that for quite a while. When persistance is released, most of my work will still be usable, i just have to tell the server to keep the data.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 25th, 2010, 4:40 pm

fox1980 wrote:Even a simple MMO is far more complex than that. Make a good design document on paper first, you'll avoid many roadblocks in the future. The solution you mentioned will make you duplicate a lot of work, you'll have to replicate some functions in both the C# Server and the PHP Server, and you'll have a nightmare of a job keeping them both synced.
I'm in the same situation as you are at the moment, and i also hope for some easy port between MySQL and PlayerIO persistance, i have 5 years experience in MySQL, i hope i don't have to throw all that knowledge away and learn something new.
What i'm doing on the MMO i'm developing is using only PlayerIO without persistance. I'm implementing moving, trading, chatting and i know i'll be busy with that for quite a while. When persistance is released, most of my work will still be usable, i just have to tell the server to keep the data.

Well I've seen a few MMO's based on flash out there, how are they doing it then? There's got to be a solution other than using Player.IO Persistance API and for the easy use of SQL I'm thinking that it's the friendliest way you can get around it. So?..
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 25th, 2010, 5:23 pm

What MMO's are you talking about ?
Most slow paced facebook games are using the Flash -> amfphp.
Dofus Online uses a custom socket server.
The rest is using either Electroserver or SmartFoxServer, both of wich are socket servers written in Java. They both have the ability to store data in a MySQL/MSSQL server, and they're both free until 20 concurrent users, up from there they get really expensive, but worst of all, they just provide the server software. You'll have to host the server yourself, and no way any shared hosting provider will let you run a socket server. You'll have to get a private virtual server, or a dedicated server plan in order to host it, and the monthly fees for those aren't cheap either.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 25th, 2010, 6:15 pm

fox1980 wrote:What MMO's are you talking about ?
Most slow paced facebook games are using the Flash -> amfphp.
Dofus Online uses a custom socket server.
The rest is using either Electroserver or SmartFoxServer, both of wich are socket servers written in Java. They both have the ability to store data in a MySQL/MSSQL server, and they're both free until 20 concurrent users, up from there they get really expensive, but worst of all, they just provide the server software. You'll have to host the server yourself, and no way any shared hosting provider will let you run a socket server. You'll have to get a private virtual server, or a dedicated server plan in order to host it, and the monthly fees for those aren't cheap either.

Wouldn't Flash -> PHP (hosted on a webserver, isn't server software rather unimportant?) -> MySQL do for just saving those persistent data I need to keep? I cannot see how it would involve the need of a standalone socket server, if I'm not going to do realtime procedures?
Our MMO idea is targeted somewhere towards the general "farming mmo" idea, but with more user interaction, seeds on an "auction house" for example, meeting up, and basically more social interaction, which I thought would be pretty solvable using the Player.IO socket server as a movement box, and persistant data towards SQL which updates on just the very necessary times?

The server is not a problem. We have a 100mbit connection lined in a DualCore 3.2ghz / 4gb RAM currently, so unless we get a ridiculous amount of users, we will have it done with this to begin with! :)
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 25th, 2010, 7:12 pm

Ok, i got the impression you were going to do something that would require "true" realtime communication. PlayerIO as it is would be perfect then to enhance the interaction, like implementing player movement, chatting, etc...
Look into amfphp: http://www.amfphp.org/ if you haven't already for Flash->PHP communication.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 25th, 2010, 7:16 pm

fox1980 wrote:Ok, i got the impression you were going to do something that would require "true" realtime communication. PlayerIO as it is would be perfect then to enhance the interaction, like implementing player movement, chatting, etc...
Look into amfphp: http://www.amfphp.org/ if you haven't already for Flash->PHP communication.

That's okay, I'm not natively speaking English so I might've put it wrong.
But yes, that's the general idea to enhance and make something unique!

And I was looking at AMFPHP before but there was no kind of "what is AMFPHP" anywhere and I'm kind of interested in what it is to begin with? What use do I have for it? I get it is a communicator, but what if I already got a web server up and running which does this for me?..^^
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 25th, 2010, 7:37 pm

Amfphp is a remoting utility for Flash->PHP communication. You don't actually need to use it, you can talk to your webserver with urlrequests in flash. But what you get in return is an HTML page. You have to manually parse it to get back the info you need and then cast it into the object type you want.
Amfphp does all this for you, it's like calling a PHP function inside Flash. Amfphp respect data types, so if you return a PHP array, it will be treated as an AS array, you don't have to worry about parsing. So far it has supported all the formats i needed, strings, integers, arrays, arrays of arrays, xml, you name it. By using the AMF3 protocol it also means communication is sent in a compressed binary format, wich saves bandwith, communication delay, and helps keeping the script kiddies at bay.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 25th, 2010, 7:51 pm

fox1980 wrote:Amfphp is a remoting utility for Flash->PHP communication. You don't actually need to use it, you can talk to your webserver with urlrequests in flash. But what you get in return is an HTML page. You have to manually parse it to get back the info you need and then cast it into the object type you want.
Amfphp does all this for you, it's like calling a PHP function inside Flash. Amfphp respect data types, so if you return a PHP array, it will be treated as an AS array, you don't have to worry about parsing. So far it has supported all the formats i needed, strings, integers, arrays, arrays of arrays, xml, you name it. By using the AMF3 protocol it also means communication is sent in a compressed binary format, wich saves bandwith, communication delay, and helps keeping the script kiddies at bay.

Easy to set up? It sounds nice tbh, afaik it's possible to draw data directly from GET and why would it then return a HTML page?
Anyway AMFPHP sounds good, I will look into that as well! So any examples would be nice as well.

Thx for all the time you spent helping me here! :)
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 25th, 2010, 8:06 pm

Cheers mate. I don't know how to draw data directly from GET, all i got when i used an urlrequest was the source HTML. At the time i was searching the best way to do Flash->PHP communication and everyone i asked advised me to use amfphp, i tried it, tought it was fast and easy and was convinced quickly.
If you do want a better answer than the one i gave you, you can read a compreensive description about amfphp here:
http://www.amfphp.org/amfphprocks.html
I'll post and example in a while (not at home atm).
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 25th, 2010, 9:05 pm

fox1980 wrote:Cheers mate. I don't know how to draw data directly from GET, all i got when i used an urlrequest was the source HTML. At the time i was searching the best way to do Flash->PHP communication and everyone i asked advised me to use amfphp, i tried it, tought it was fast and easy and was convinced quickly.
If you do want a better answer than the one i gave you, you can read a compreensive description about amfphp here:
http://www.amfphp.org/amfphprocks.html
I'll post and example in a while (not at home atm).

Yeah I know I looked at the page, but - I can't really find info on what it truly is, is it a flash component, a web server or?.. Can't find anything about it in technical aspects more than how you use it which is irrelevant. Just looked quick though, as I'm busy constructing my game in over-all with my team.
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 25th, 2010, 9:34 pm

Amfphp is just a set of php scripts that implement the amf3 protocol.
Flash already has builtin components to talk to amfphp. All you need to do is download amfphp and upload it to a folder on your webserver.
Create a file called HiWorld.php inside /amfphp/services. Put this inside:

Code: Select all
<?php
class HiWorld
{
   
   public function test() {
   
      $var[0]="Hello";
      $var[1]=" World";
      return $var;
      
   }
}
?>


Now in actionscript you can call the test function like this:

Code: Select all
import mx.remoting.*;
import mx.rpc.*;

      private function test():void {
      
         var responder:Responder = new Responder(onresult);
         var connection:NetConnection = new NetConnection;
         connection.connect(http://www.yourserver.com/amfphp/gateway.php");
         connection.call("HiWorld.test", responder);

      }
      
      private function onresult(result:Array):void
      {
      
         Alert.show(result[0] + result[1]);
      
      }


Of course this is just a simple example, but you can already see the it's usefullness. Flash recognises the php array as such, try and pass an array or even more complex objects through GET ;)
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 25th, 2010, 10:29 pm

fox1980 wrote:Amfphp is just a set of php scripts that implement the amf3 protocol.
Flash already has builtin components to talk to amfphp. All you need to do is download amfphp and upload it to a folder on your webserver.
Create a file called HiWorld.php inside /amfphp/services. Put this inside:

Code: Select all
<?php
class HiWorld
{
   
   public function test() {
   
      $var[0]="Hello";
      $var[1]=" World";
      return $var;
      
   }
}
?>


Now in actionscript you can call the test function like this:

Code: Select all
import mx.remoting.*;
import mx.rpc.*;

      private function test():void {
      
         var responder:Responder = new Responder(onresult);
         var connection:NetConnection = new NetConnection;
         connection.connect(http://www.yourserver.com/amfphp/gateway.php");
         connection.call("HiWorld.test", responder);

      }
      
      private function onresult(result:Array):void
      {
      
         Alert.show(result[0] + result[1]);
      
      }


Of course this is just a simple example, but you can already see the it's usefullness. Flash recognises the php array as such, try and pass an array or even more complex objects through GET ;)


Thanks for the examples, fox1980.
I will try this out tomorrow. (late here).
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 26th, 2010, 4:59 pm

Do I need to have other programs than Adobe Flash CS4/5? Because I'm kind of unsure where the mx imports come from?

Edit; I took a glimpse at Flex Builder, if that is what you're telling us to do. Unfortunately I don't get the idea of coding in Flex Builder instead of Flash Professional CS4/5. Is there any kind of way I can still code and do everything in Flash CS4 instead of porting everything over to this ridiculous program Flex Builder? As I need its components or imports, somehow it must be possible to import them without actually using the program, no?..
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 26th, 2010, 6:18 pm

Oh yes, i forgot to mention that. I'm an uncondicional fan of Flex/Flash Builder, so yes the imports are from the flex framework.

Here's a link to a very good and easy tutorial for Flash CS->amfphp:

http://www.gotoandlearn.com/play?id=79
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 26th, 2010, 6:32 pm

fox1980 wrote:Oh yes, i forgot to mention that. I'm an uncondicional fan of Flex/Flash Builder, so yes the imports are from the flex framework.

Here's a link to a very good and easy tutorial for Flash CS->amfphp:

http://www.gotoandlearn.com/play?id=79

Yes, thanks for the URL although I found something similar just an hour ago.
Although, I'm getting some really major odd error "NetConnection.BadVersion", I've tried to find a solution to it but I can't make it dissappear. Apparently it's a common error, but I can't seem to solve it..
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 26th, 2010, 6:42 pm

When you get that error message, 99% of the time it's a bad formatted php file. Make sure all parenthesis are closed, and it's actually php code, i lost count of how many time i wrote AS3 syntax inside a php file. For easier debugging just access the php service file you created directly in the browser and it will tell you wich line is causing the problem.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 26th, 2010, 6:51 pm

fox1980 wrote:When you get that error message, 99% of the time it's a bad formatted php file. Make sure all parenthesis are closed, and it's actually php code, i lost count of how many time i wrote AS3 syntax inside a php file. For easier debugging just access the php service file you created directly in the browser and it will tell you wich line is causing the problem.

Bad formatted PHP file?
How do I format it properly? Because when I visit the file, both in the AMFPHP Services' Browser and in my normal browser, I get no errors, no nothing. A simple white page, and in Services Browser I get a variable line to fill and "call" if I want to.
Ideas?.. :?
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 26th, 2010, 6:59 pm

So you get a normal result when you press 'call' from the services browser ?
The services browser is just a program so you can test your services, if you get the php return value back then the problem should lie in your AS3 code.

Anyway i found this info:

Some typical situations which raise a Call.BadVersion while developing in AMF-PHP Remoting:
1.open with browser the gateway.php file. A download dialog should appear, this means it's all ok. if you don't see the download dialog or the page is not blank, you've errors in the gateway file
2.open with the browser the php class file you're using as service (for example localhost/flashservices/service/myclass.php). no character must appear in the page
3.build PHP test suites to thoroughly test your PHP classes. If your tests generate warnings or errors, you can either fix them :) or do error_reporting(0); at the top of your PHP code. It happened to me that opening a class in my browser didn't generate any output (which is the desired behavior) but when calling one buggy method from Flash it did generate warnings and returned a Call.BadVersion.
4.if you're under windows try to name the php class file and the class & constructor with lowercase characters
5.blank line or spaces at the beginning or end of your php files (gateway.php and class file)
6.be sure you're not adding any BOM header to the files if your editor save files with UTF encoding
7.If you're using firewall program such as ZoneAlarm try to disable them and try again
8.If in your flash you're trying to call 2 remoting methods in the same time try to comment out one. If next time it works then you need to download the last AMFPHP version
9.If you work under Windows or Mac OS X, your editor may be creating incompatible line breaks. Windows terminates every line with CRLF (\n\r); some applications in Mac OS X terminate lines with the standard Mac line ending (chr(13)) plus a CR (\n)
10.If your PHP service class uses include files do not forget to check the line breaks in those include files as well.
11.Check if in your functions, you haven't included "echo" for tests. Remove every echo-call.
12.For the installation on Mac OSX with apache
13.If you receive a message like:

Scene=Scene 1, Layer=Remoting, Line=1: Error 5: Error opening include file NetServices.as: File not found.
#include "NetServices.as"then you first need to download the Flash Remoting components from macromedia.com

1.Also take note that if your service class uses included classes, the calling function will need to have the class file included in the function itself
2.Don't forget to look at the errors PHP generates. On test systems you will usually see the PHP errors directly on the PHP page called; you can't use that info when working with remoting. What you need to do is change the php.ini log_errors value to On. When you do this you will be able to retrieve the errors PHP generates in Apache's error log (available under (server)/logs/error.log. Usually these errors are helpful enough that you will be able to pinpoint the source of the problem.
3.The path in gateway.php (in your project folder) must be ABSOLUTE:
e.g

include("d:\appserv\www\flashservices\app\Gateway.php"); (change to your absolute path!);

$gateway = new Gateway(); $gateway->setBaseClassPath("./services/"); $gateway->service();
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 26th, 2010, 7:07 pm

fox1980 wrote:So you get a normal result when you press 'call' from the services browser ?
The services browser is just a program so you can test your services, if you get the php return value back then the problem should lie in your AS3 code.

Anyway i found this info:


Hi again,

package
{
import flash.net.Responder;

public class RemotingTest
{
private var rs:RemotingService;

function RemotingTest()
{
init();
}

private function init()
{
rs = new RemotingService("http://localhost/amfphp/gateway.php");
var responder:Responder = new Responder(onResult,onFault);
var params:Object = new Object;
params.arg1 = "something";
params.arg2 = "2";
rs.call("Test.test",responder,params);
}

private function onResult(result:Object):void
{
trace(result);
}

private function onFault(fault:Object):void
{
trace(fault);
}
}
}


I cannot see anything wrong with this..
And the php result is returning right, I guess I'm just unlucky?.. lol

Error #2044: Unhandled NetStatusEvent:. level=error, code=NetConnection.Call.BadVersion
at RemotingTest/init()
at RemotingTest()
at Main()


EDIT:
I managed to fix this by changing the "PRODUCTION_SERVER" property in Gateway.php to false. I don't know how it caused the trouble, but anyway.
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 26th, 2010, 7:41 pm

Not sure if this is the reason but :

Code: Select all
var params:Object = new Object;


should be:
Code: Select all
var params:Object = new Object();


Tough i would never tried passing an object type.
Can you try this ?

Code: Select all
private function init()
{
rs = new RemotingService("http://localhost/amfphp/gateway.php");
var responder:Responder = new Responder(onResult,onFault);
var params:Array= new Array();
params.push("something");
params.push("2");
rs.call("Test.test",responder,params);
}


Also if you're working on localhost you should change production_server parameter to false in gateway.php

define("PRODUCTION_SERVER", false);


If none of these work can you show me your php file ?
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 26th, 2010, 8:58 pm

fox1980 wrote:Not sure if this is the reason but :

Code: Select all
var params:Object = new Object;


should be:
Code: Select all
var params:Object = new Object();


Tough i would never tried passing an object type.
Can you try this ?

Code: Select all
private function init()
{
rs = new RemotingService("http://localhost/amfphp/gateway.php");
var responder:Responder = new Responder(onResult,onFault);
var params:Array= new Array();
params.push("something");
params.push("2");
rs.call("Test.test",responder,params);
}


Also if you're working on localhost you should change production_server parameter to false in gateway.php

define("PRODUCTION_SERVER", false);


If none of these work can you show me your php file ?

Already fixed the problem! but thanks anyway. (edited my answer before your post ;))
Anyway, I'm now trying to get a value from the DB so that I can notify my game where something is currently located.
I'm trying to put it in a number variable, as I'm trying to get last known X/Y for the player, but I don't really know how to return the value?

my php function (works in browser)
Code: Select all
   function loadX($uid)
   {
      $result = mysql_query("SELECT x FROM players WHERE uid=$uid");
      return mysql_result($result, 0);
   }


Gives me a typecast, that I can't put Void into something that is of the variable Number.
Code: Select all
var charX:Number = gw.call("loadPlayerService.loadX", res, 0);


How would I make it possible to put my float variable from MySQL into my AS3 Variable Number?
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby flash_mmo » May 26th, 2010, 9:42 pm

I solved the above problem by doing this;
Code: Select all
public function onResult(responds:Object):void{
         if (getNetResponse.length > 0)
            getNetResponse.pop();
         else
            getNetResponse[0] = responds;
         trace("Server response: "+responds);
      }


And right after I have called my variable, I simply do:
Code: Select all
my_char.x = getNetResponse[0];
flash_mmo
 
Posts: 20
Joined: May 20th, 2010, 1:14 pm

Re: Saving Data with Player.IO?

Postby fox1980 » May 27th, 2010, 12:13 am

Glad you got it working.
In order to optimize speed and memory consumption you should try to avoid using variables with type Object (i benchmarked in Flex profiler and found Object is very expensive regarding memory). When possible always try to use the correct type.

You can rewrite your php function like this:

Code: Select all
function loadX($uid)
   {
      $result = mysql_query("SELECT x FROM players WHERE uid=$uid");
      $row=mysql_fetch_array($result);
      return $row["x"];
   }


and your AS3 onResult function would go like this:
Code: Select all
public function onResult(responds:int):void{
         trace("Server response: "+responds);
         my_char.x = responds;
      }
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Next

Return to Multiplayer