Cross-Server /seen

Discussion in 'Plugin Development' started by xWatermelon, Jun 24, 2013.

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

    xWatermelon

    I have a network of servers and would like to know how to make a plugin that when you type /seen <player> it will tell you on what server and how long ago they were last seen on. I assume it would be easiest to save it to a MySQL table, but I do not know the correct way to format the table and send/retrieve the correct information. Thanks!
     
  2. Offline

    ProtoTempus

    xWatermelon Does it, by chance, run on BungeeCord?

    If not, it's a simple enough plugin. On PlayerJoinEvent, record the server name, player name, and time.
    A table format that would work: "CREATE TABLE playerJoins (serverName VARCHAR(20), playerName VARCHAR(35), time DATETIME)' or something similar....;

    Then your normal MySQL SELECT: "SELECT time FROM playerJoins WHERE playerName=???"
    And inserting entries: "INSERT INTO playerJoins VALUES (serverName, playerName, time)"
     
    xWatermelon likes this.
  3. Offline

    NoLiver92

    look at my MySQLAPI this would help you as you dont need to know mysql to use it.
     
    xWatermelon likes this.
  4. Offline

    dillyg10

    Yes, using MySQL is a fantastic solution

    Simply (using java.sql.Date or something similar) log the date into the sql database, and then just grab it via the command.

    Hopefully you are familiar with MySQL.... if not you should REALLY get acquainted with it, MySQL is pretty fantastic.
     
    xWatermelon likes this.
  5. Offline

    Rocoty

    I'd use PlayerQuitEvent instead. Because that logs when they were last seen.
     
    Hoolean and xWatermelon like this.
  6. Offline

    xWatermelon

    ProtoTempus NoLiver92 dillyg10 thanks! Just a quick question: If I used the insert into function in a table where the player was already in, would it override the existing row or create a new row? If it creates a new row, how can I override the existing one? I have no previous MySQL experience and am trying to learn it :p
     
  7. Offline

    NoLiver92

    insert will always add, you need update to replace data (this is the tricky part).

    with update you need to know what the other column values are or when you change one column the others go to null (talking from my own experience)

    xWatermelon The way i learnt it was to have my own database with phpmyadmin and when you change something in the gui way it gave you the code for the sql statement which i then change to what i need. this might help you

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
    xWatermelon likes this.
  8. Offline

    dillyg10


    Do something like

    update `table` set `colum`=`value` where `othercolum`=`othervalue`
     
    xWatermelon likes this.
  9. Offline

    xWatermelon

    NoLiver92 dillyg10 how can I check the number of rows so I can either perform the insert into or update function?

    Ooh also, how would I handle it if the player is online? Like: "Player is online Hub server for 1m 20s."

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

    chasechocolate

    Insert into the table in PlayerJoinEvent.

    xWatermelon oh and also, there's a really easy way to get the time units (using java.sql.Date) by using date.getHours(), date.getMinutes(), date.getDays(), etc.

    EDIT: Just realized they are deprecated...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
Thread Status:
Not open for further replies.

Share This Page