Website and Server

Discussion in 'Plugin Development' started by mrkirby153, Apr 27, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    mrkirby153

    I am developing a web shop plugin that allows the player to purchase items online with ingame currency and they will receive the items ingame. I thought that when the person buys an item, it puts a value into a database saying XX bought YY. The server polls the database every five or so minutes and gives all the players the items they bought and updates the amount of money they have. The only problem I have is that I want the website to show the amount of money that they have and once they buy something, that number decreases in realtime. Not five minutes later. How would I handle this?

    I guess I could poll the same table and get the money they currently have and subtract the cost of the items queued for delivery but the more items there are, the slower the site.
     
  2. Offline

    Adriani6

  3. Offline

    GaaTavares

    I use SQL for almost the same purpose as you, and it works fine. Remember you gotta use async tasks for SQL
     
  4. Offline

    mrkirby153

    GaaTavares
    That is great and all but how do I update the player's account balance in realtime (Not five minutes later)? I do use async for SQL tasks but the one catch I found was the general SQL Query that returns a resultset. Here is my SQL handler class if you want. Just to verify that I'm doing everything correctly.
     
  5. Offline

    Plo124

    mrkirby153
    Realtime would be similar if you just polled the SQL database every 5-10 seconds, its not a up to 5 minute wait.
    As for money, I would recommend you store in the SQL database the user IP and money amount, and with the php server then check their IP. That way you avoid having to keep track of their username and asking them for it, it also prevents people from typing someone elses username and making them do a trade.
     
  6. Offline

    mrkirby153

    Plo124
    Yes, that would be an option but that is a lot of unnecessary bandwidth usage and would be slow if there are a lot of people syncing their balance and a slow database
     
Thread Status:
Not open for further replies.

Share This Page