Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Saving bans in MySQL Database

Comments in 'Plugin Development' started by Radix, Aug 21, 2015.

  1. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    Title ?
  2. Gamecrafter
    Offline

    Gamecrafter Notable Member Plugin Developer

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Needs more information. What do you want to do with the ban saves?
  3. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    I just want to be able to save bans in mysql database so I can display bans on my website and have global bans
  4. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    Make new column or table with bans
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Learn MySQL language.

    I recommend this table structure:
    Code:
    CREATE TABLE IF NOT EXISTS bans(
      ban_id INT PRIMARY KEY AUTO_INCREMENT,
      username VARCHAR(20),
      ip VARCHAR(15),
      message VARCHAR(255),
      creation TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      duration INT DEFAULT 0 -- permanent ban
    );
    To check if a player is banned (and to get the message):
    Code:
    SELECT msg FROM bans WHERE (username=:username OR ip=:ip) AND (duration=0 OR unix_timestamp() < unix_timestamp(creation) + duration);
    xpyctum, CrazedMiner and Legoboy0215 like this.
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Isn't it just SQL language?
  7. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Same. A dialect of SQL. Just like Mandarin is a dialect of Chinese.
    Legoboy0215 likes this.
  9. Humerus
    Offline

    Humerus Staff Member Plugin Reviewer

    Joined:
    Aug 23, 2013
    Posts:
    114
    Plugins:
    1
  10. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Wow. You post? And it works very neatly.

Share This Page

Advertisement