Multiplayer and MMO Server (quasi real-time)

Fumetsujo

Villager
Member
Joined
Jan 12, 2017
Messages
6
Reaction score
1
First Language
English & Dutch
Primarily Uses
Hi peeps,


I've worked on a way to make Rpgmaker MV work in multiplayer. This with built-in chat & seeing other players. 


You are allowed to do with it whatever you want, but if it's a commercial project do mention my name "Fumetsujo" please. 


Info: 


Fumetsujo multiplayer/MMO Server


This require some basic understanding of coding. Mainly in javascript and Python. 
I've made it as easy as possible, so if you pick up python, than this is a fantastic opportunity!



Possibilities: 
* Chat
* See other players in (almost) real-time.



How does it work?
This python based (flask server), addition makes it possible to create a multiplayer or mmo rpg. 
You start the webserver.py and surf with CHROME or FIREFOX to 127.0.0.1:8000/game.
It's possible from most extern devices (but then you must typ ip-adres-server:8000/game), although this version has a lot of lag on smartphones.
To the point: The Rpgmaker does ajax calls to the webserver and your name + data gets stored in a dictionary. 



Through events the 'other' players are shown on your screen.


Note: Galv spawn map doesn't work with the server (I've tried), because the deletion of old events instances and deploying new ones simultaneously creates errors. 
Note 2: I haven't found a way to link skins to the other players (how to change img for an event).
Note 3: I didn't use websockets, because python-based (free) online servers don't always know how to handle websockets. Get/Posts are 35% slower, yet work trustworthy.
-----
Requirements: 
Python 2.7 + flask
Windows >= 7



Links:
Python 2.7; https://www.python.org/download/releases/2.7/
Flask;  in cmd --> (python) pip install flask
Tutorial python (pip); http://stackoverflow.com/questions/4750806/how-do-i-install-pip-on-windows

 


--> Link to the server: http://fumetsujo.pythonanywhere.com/static/Fumetsujo_MultiplayerMMO.zip
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
21,869
Reaction score
11,081
First Language
English
Primarily Uses
RMVXA
I've moved this thread to Useful Development Tools. Please be sure to post your threads in the correct forum next time. Thank you.
 
Joined
Sep 28, 2016
Messages
1
Reaction score
1
First Language
English
Primarily Uses
If I may offer my advice, Python is a heavily bloated (and slow) language. The reason for this is that Python itself is run from a somewhat hosting language, be it C (the default "Python"), Java (Jython/JPython... extremely slower because Java is already quite slow), C#.NET (I think this is "IronPython" but I could be wrong), or one developed in the future...


Python, like Java, does not directly compile into raw machine code, but is instead interpreted (which is why one ".py" file can work on many different OSes as long as Python is installed and it doesn't rely on a specific feature of an OS). When you run your ".py" file alone, it doesn't create any compiled byte-code (Java's byte-code is its ".jar" files) directly (it just does it internally), but it does if you "import" your ".py" file from another...


Although if you want a suggestion for a replacement for a Python socket server, try Node.js (located here for the native English page on the site). It uses code written in V8 (a very optimized Javascript parser, can be considered to be more ECMAScript than Javascript because of some web browser-only features not existing) and is ran off of "modules". If you only import what modules you need, it is MUCH lighter in RAM and faster than Python if both your current and the Node.js version are just at a basic "no optimizations or bloat in the raw code".


To be honest, it is basically so much useful in modules only doing their own part (at least for the built-in ones), you do not even need to worry about RAM usage by parts of a programming language which don't even get used..... and it isn't just strictly for servers (you can completely omit the "http" module if you just use it as a in-the-console (cmd.exe, bash, etc. etc.) replacement for tasks that need to be looped numerous times over (single-run short programs are slower than command line PHP, but faster than PHP if looped numerous times).


....About your issue with the IMG tags...


I would suggest giving them each an ID attribute (if you have not done so yet), and when one player "applies" another "skin", it would be picked up by the game clients who are in the area (you do limit sending out info so nobody sees what they cannot see within a few seconds in the future, right?), or are otherwise able to see that person's image (friends list, party, guild/clan, etc.)... when this event gets picked up, each client will find that IMG if they have it <<example>>


var targetEventUserSpriteIMG = document.getElementById("user_"+targetUserId);


if (targetEventUserSpriteIMG)


{


    // It is null if not found, otherwise an object is given, making this not give an error.


    targetEventUserSpriteIMG.setAttribute("src", targetEventUserNewSpriteURL);


}


// Probably should first cache with making a `new Image()` and setting its


// `.onload` / `.onerror` properties to a in-line function (keeping the image


// variable in memory until after the image is loaded & the test for the image


// is over, or the loading of the image fails).


<<end example>>


Do note that you would need to store custom files on the server (same domain due to XSS restrictions) if you plan to allow user uploads (make sure to validate your stuff as things like a RAR file can actually be hidden inside an image file!).. or just have a LOT of sprites (user-selectable "character skins") on the server-side, or downloaded with the client.
 

Ellie Jane

Veteran
Veteran
Joined
Mar 17, 2012
Messages
760
Reaction score
1,477
First Language
English (UK)
Primarily Uses
RMMV
With regards to skins, what I did was generated the images server-side. Because the game's browser based anyway and loading images from the web, it was easy to switch one of those images for a script (in my case a PHP file but could easily be Python). So instead of image.png it loads image.php. I put some variables into that again using GET like you, so image.php?user=1, and the script then generates the right graphic. The advantage of this was that I was able to very easily implement a paperdoll visual equipment system, while keeping file sizes down and the user not having to download every single little graphic for the system.
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
876
Reaction score
586
First Language
English
Primarily Uses
RMMV
The thing is just constantly pounding the server with ajax get posts? IDK. You might want to look into using a socket, though I myself have no understanding of how to with RPG Maker. That ajax way is only way I can think of how to do it too, but I only know PHP which I understand would be even slower for live moving.
 
Last edited by a moderator:

Fumetsujo

Villager
Member
Joined
Jan 12, 2017
Messages
6
Reaction score
1
First Language
English & Dutch
Primarily Uses
If I may offer my advice, Python is a heavily bloated (and slow) language. The reason for this is that Python itself is run from a somewhat hosting language, be it C (the default "Python"), Java (Jython/JPython... extremely slower because Java is already quite slow), C#.NET (I think this is "IronPython" but I could be wrong), or one developed in the future...


Python, like Java, does not directly compile into raw machine code, but is instead interpreted (which is why one ".py" file can work on many different OSes as long as Python is installed and it doesn't rely on a specific feature of an OS). When you run your ".py" file alone, it doesn't create any compiled byte-code (Java's byte-code is its ".jar" files) directly (it just does it internally), but it does if you "import" your ".py" file from another...


Although if you want a suggestion for a replacement for a Python socket server, try Node.js (located here for the native English page on the site). It uses code written in V8 (a very optimized Javascript parser, can be considered to be more ECMAScript than Javascript because of some web browser-only features not existing) and is ran off of "modules". If you only import what modules you need, it is MUCH lighter in RAM and faster than Python if both your current and the Node.js version are just at a basic "no optimizations or bloat in the raw code".


To be honest, it is basically so much useful in modules only doing their own part (at least for the built-in ones), you do not even need to worry about RAM usage by parts of a programming language which don't even get used..... and it isn't just strictly for servers (you can completely omit the "http" module if you just use it as a in-the-console (cmd.exe, bash, etc. etc.) replacement for tasks that need to be looped numerous times over (single-run short programs are slower than command line PHP, but faster than PHP if looped numerous times).


....About your issue with the IMG tags...


I would suggest giving them each an ID attribute (if you have not done so yet), and when one player "applies" another "skin", it would be picked up by the game clients who are in the area (you do limit sending out info so nobody sees what they cannot see within a few seconds in the future, right?), or are otherwise able to see that person's image (friends list, party, guild/clan, etc.)... when this event gets picked up, each client will find that IMG if they have it <<example>>


var targetEventUserSpriteIMG = document.getElementById("user_"+targetUserId);


if (targetEventUserSpriteIMG)


{


// It is null if not found, otherwise an object is given, making this not give an error.


targetEventUserSpriteIMG.setAttribute("src", targetEventUserNewSpriteURL);


}


// Probably should first cache with making a `new Image()` and setting its


// `.onload` / `.onerror` properties to a in-line function (keeping the image


// variable in memory until after the image is loaded & the test for the image


// is over, or the loading of the image fails).


<<end example>>


Do note that you would need to store custom files on the server (same domain due to XSS restrictions) if you plan to allow user uploads (make sure to validate your stuff as things like a RAR file can actually be hidden inside an image file!).. or just have a LOT of sprites (user-selectable "character skins") on the server-side, or downloaded with the client.
Hi,

Thank you for your aid! I will look into it.

Note: I did use python for its open source facet and easy programming. Hosting in c#(azure) or js node is not that cheap and Php I don't know that proficiently.

Regard!
 

Fumetsujo

Villager
Member
Joined
Jan 12, 2017
Messages
6
Reaction score
1
First Language
English & Dutch
Primarily Uses
The thing is just constantly pounding the server with ajax get posts? IDK. You might want to look into using a socket, though I myself have no understanding of how to with RPG Maker. That ajax way is only way I can think of how to do it too, but I only know PHP which I understand would be even slower for live moving.
Sockets are way faster! But not all free hosts know to handle them. Also, from an educational aspect, post/get is easier to understand.

Regards!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,081
Reaction score
7,050
First Language
German
Primarily Uses
RMMV
[dpost]Fumetsujo[/dpost]
If you want to answer several people, either use the quote option instead of reply, or use the @Username convention.
 

donatman

Villager
Member
Joined
Nov 13, 2017
Messages
6
Reaction score
0
First Language
Finland
Primarily Uses
RMMV
Hi!

I must ask are you making online trade system? Our team would need that badly to make game we want :) Thank you !
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Am I allowed to make a recruitment thread NOT for RPG Maker stuff?

Like for a group project?
(NOT RPG Maker project.)
If the new RPG Maker's character generator produces full busts and can match the art styles of previous RPG Makers, that might be a big incentive to buy it. An easier way to craft custom map tile sheets though would probably be an even bigger game changer.
Note to self: One lemon is enough to flavor my drink.
'I'm not homophobic, I'm not scared of me house.' - Peter Kay xD
When did anything under your mid-twenties become the new 10 years old? At least try to act like your old enough to sign a lease.

Forum statistics

Threads
98,192
Messages
950,242
Members
129,492
Latest member
Solar_Flare
Top