Multiplayer and MMO Server (quasi real-time)

Discussion in 'Useful Development Tools' started by Fumetsujo, Jan 12, 2017.

  1. Fumetsujo

    Fumetsujo Villager Member

    Messages:
    6
    Likes Received:
    1
    First Language:
    English & Dutch
    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
     
    #1
    Zeriab likes this.
  2. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,348
    Likes Received:
    10,400
    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.
     
    #2
    Fumetsujo likes this.
  3. CtrlAltCuteness

    CtrlAltCuteness Warper Member

    Messages:
    1
    Likes Received:
    1
    First Language:
    English
    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.
     
    #3
    Fumetsujo likes this.
  4. Amy Pond

    Amy Pond Veteran Veteran

    Messages:
    667
    Likes Received:
    1,357
    First Language:
    English (UK)
    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.
     
    #4
    Fumetsujo likes this.
  5. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    575
    Location:
    Bassett Nebraska
    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: Jan 20, 2017
    #5
    Fumetsujo likes this.
  6. Fumetsujo

    Fumetsujo Villager Member

    Messages:
    6
    Likes Received:
    1
    First Language:
    English & Dutch
    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!
     
    #6
  7. Fumetsujo

    Fumetsujo Villager Member

    Messages:
    6
    Likes Received:
    1
    First Language:
    English & Dutch
    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!
     
    #7
  8. Andar

    Andar Veteran Veteran

    Messages:
    28,122
    Likes Received:
    6,369
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV

    Fumetsujo, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


    If you want to answer several people, either use the quote option instead of reply, or use the @Username convention.
     
    #8
  9. donatman

    donatman Villager Member

    Messages:
    6
    Likes Received:
    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 !
     
    #9

Share This Page