Crossserver money

Discussion in 'Archived: Plugin Requests' started by Snipershotmaster, Jul 12, 2014.

  1. hi i wa wondering if there is a plugin or if someone can create a plugin that will sync all there money together on targeted servers, is there such plugin that can be created?
     
  2. Offline

    ImDeJay

    Your looking for an economy plugin that has MySQL support, search the current economy plugins for this feature, im sure there is one out there.
     
  3. Offline

    Starfire1337

    I may be able to do this if you are using a vault-compatible economy plugin. You should be able to p.getBalance when the player logs off, then update that into the MySQL db. When someone logs on, you should be able to do p.setBalance, grabbing the value from the MySQL db. The only problem I see with this is if you have a huge server, there could be a possibility of lag because the plugin must access the db so many times.
     
  4. Online

    timtower Administrator Administrator Moderator

    Starfire1337 Not to mention economy transactions when the player is offline on one server, somebody pays him there, he is still online on other server.
     
  5. Offline

    Starfire1337

    timtower That's the only downside, If there is an option to update every X minutes, unless it is perfectly in sync, it could potentially mess up the player's balance (Add or subtract more money than he/she should have).

    Also, to my knowledge, the only command that could give a player money when they are offline is /eco give (For essentials because /pay an offline username returns a Player not found).
     
  6. Online

    timtower Administrator Administrator Moderator

  7. Offline

    TheMcScavenger

    timtower, Starfire1337, I think it can be achieved quite simply:
    • PlayerJoinEvent > get the money from the MySQL Database, set the player's balance on the server to that
    • PlayerQuitEvent > get the money from the MySQL Database, add the balance the player has more than the original balance (not the balance that's in the db now!), subtract if the balance the player has now is less than the original balance (not the balance that's in the db now!).
    When a player then joins one server, his money is gotten from the database, and set properly on the server. When a player quits, the server makes sure to update the money. This does mean that if a player were to earn money on one server, and play on another, he wouldn't receive the money unless he relogged. This can be resolved by adding the refresh function, and get the money every xtime, or in some magical way push updates in the DB to the server.

    Forgot to mention; great idea! :)
     
  8. Offline

    Starfire1337

    TheMcScavenger
    That would be difficult, because lets say Player X is on server Y when a shop plugin on server Z adds XY to player X's balance. At the same time (Before the sync), Player X will spend XZ money on server Y. Now, let's say player X has $1000 on server Y, but has $2500 on server Z. If Player X loggs off of server Y and Joins server Z, his balance would be updated to $1000, therefore loosing any money he earned from the shop.
     
  9. Offline

    TheMcScavenger

    Umm not really. Money synchronises when a player joins and leaves the server, meaning if he were to earn the money on server X, and spend money on server Y, when he joins server X, the money has already synchronised. The only thing that'd have to happen, which I didn't yet mention, is instantly adding the balance to the database when it's earned if the player is offline, but that's not too difficult.

    Seeing as nobody else does, I'll start working on it a bit. Won't give you an ETA, but I'll make it something nice :)

    http://dev.bukkit.org/bukkit-plugins/shared-economy/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016

Share This Page