Multiplayer :/

Before I came to coronalabs, I was scripting in an open-source multiplayer mod for GTASA called MTA,

In MTA there were 2 types of coding, server-side and client-side…

Client-side is a script which only involves the localPlayer so for example if I created a table in client-side every player will have a different table, on the other hand if I created a table in server-side that table is the same for everyone.

The question is there a server-side in corona ? I’ve read about game networking but I still have trouble understanding the concept on how it works, and how will I be able to control and retrieve all of player’s actions when am only using client-side

for example what if I made player1 shoot, that only happened in client-side how I send that action to all of the other players ?

This may take a bit of explaining. Corona SDK has the following available:

  1. network.* API’s that let you talk to web service API endpoints (RESTful APIs). You request a web page (usually a PHP or .NET script), send some information, get a result back (usually a JSON table) and parse the JSON table into a Lua table you can use (see json.decode). If you have access to a web host that lets you create MySQL databases (or MSSQL if you’re more of a .NET person) you can create your own database and a few .PHP or .NET scripts to take network.request calls from Corona, process them on the server side and return an updated version of the server’s table to you. It’s a little bit of work, but it works.

  2. socket.* APIs that let you open lower level, but real time sockets to a server. You probably do not want to go down this route.

  3. Game Networking plugins: These include: Apple’s GameCenter, Goggle’s Google Play Game Services and Amazon’s GameCircle. These all let you save leaderboards and achievements. Each has some level of multiplayer support. We are working on a new GPGS plugin that will provide better support in that area. Once you figure out the various levels of multi-player support, you’re likely going to have to implement things differently for each platform and it’s perhaps a bit more work than just fetching a shared table.

  4. Third party services. Most people used to use Parse.com for this, but Facebook has decided to shutter this service and it won’t be around much longer. One of our Corona developers created a service called Coronium (http://Coronimum.io) that is Lua based and lets you basically have a server side table like you’re looking for. However I believe that he’s not encouraging new customers right now because…

  5. Corona Labs is working on a cloud based solution based on Coronium. We hired Coronium’s developer Chris Byerley to create our cloud based solution. So for now, while he’s focused on that, he doesn’t have time to support new Coronium customers. We don’t have an ETA on the new cloud solution, but it gets closer each day.

  6. Look at the Photon plugin. https://docs.coronalabs.com/plugin/photon/index.html

It’s a real time gaming service but it might do what you want. It does high speed instant messaging between clients thats needed in a real time service. But the idea is a same, you send a packet of data to the server, all connected apps get that data sent back to them.

If you have to do this today, I’d look at Photon first and see if it will do what you want to do. If you have experience with PHP, you can certainly go with #1. If you can code up the rest of your app, and delay the multi-player part until later, I think our cloud based solution will be exactly up your ally.

Rob

Actually Photon looks like it can handle a lot of what’s going in my mind, but there are still some problems, like lets say for example player1 pressed a button that initiates a vote to kick player2 and player3 and player4 should vote, how could I send them that a vote has been initiated, and event was called for player1 how would I recieve that event as player3 or player4 ?

There is a specific forum for Photon and they actively monitor it. I would suggest you ask this question there.

https://forums.coronalabs.com/forum/616-photon/

Rob

I have also updated the autolan plugin if you ever want to local multiplayer over wifi

This may take a bit of explaining. Corona SDK has the following available:

  1. network.* API’s that let you talk to web service API endpoints (RESTful APIs). You request a web page (usually a PHP or .NET script), send some information, get a result back (usually a JSON table) and parse the JSON table into a Lua table you can use (see json.decode). If you have access to a web host that lets you create MySQL databases (or MSSQL if you’re more of a .NET person) you can create your own database and a few .PHP or .NET scripts to take network.request calls from Corona, process them on the server side and return an updated version of the server’s table to you. It’s a little bit of work, but it works.

  2. socket.* APIs that let you open lower level, but real time sockets to a server. You probably do not want to go down this route.

  3. Game Networking plugins: These include: Apple’s GameCenter, Goggle’s Google Play Game Services and Amazon’s GameCircle. These all let you save leaderboards and achievements. Each has some level of multiplayer support. We are working on a new GPGS plugin that will provide better support in that area. Once you figure out the various levels of multi-player support, you’re likely going to have to implement things differently for each platform and it’s perhaps a bit more work than just fetching a shared table.

  4. Third party services. Most people used to use Parse.com for this, but Facebook has decided to shutter this service and it won’t be around much longer. One of our Corona developers created a service called Coronium (http://Coronimum.io) that is Lua based and lets you basically have a server side table like you’re looking for. However I believe that he’s not encouraging new customers right now because…

  5. Corona Labs is working on a cloud based solution based on Coronium. We hired Coronium’s developer Chris Byerley to create our cloud based solution. So for now, while he’s focused on that, he doesn’t have time to support new Coronium customers. We don’t have an ETA on the new cloud solution, but it gets closer each day.

  6. Look at the Photon plugin. https://docs.coronalabs.com/plugin/photon/index.html

It’s a real time gaming service but it might do what you want. It does high speed instant messaging between clients thats needed in a real time service. But the idea is a same, you send a packet of data to the server, all connected apps get that data sent back to them.

If you have to do this today, I’d look at Photon first and see if it will do what you want to do. If you have experience with PHP, you can certainly go with #1. If you can code up the rest of your app, and delay the multi-player part until later, I think our cloud based solution will be exactly up your ally.

Rob

Actually Photon looks like it can handle a lot of what’s going in my mind, but there are still some problems, like lets say for example player1 pressed a button that initiates a vote to kick player2 and player3 and player4 should vote, how could I send them that a vote has been initiated, and event was called for player1 how would I recieve that event as player3 or player4 ?

There is a specific forum for Photon and they actively monitor it. I would suggest you ask this question there.

https://forums.coronalabs.com/forum/616-photon/

Rob

I have also updated the autolan plugin if you ever want to local multiplayer over wifi