Thread: Player Saving via MySQL

Results 1 to 6 of 6
  1. #1 Player Saving via MySQL 
    Banned

    Join Date
    Jul 2011
    Posts
    691
    Thanks given
    163
    Thanks received
    161
    Rep Power
    0
    So I finally was able to hook up Xampp on my VPS and now I want to start writing a database to save my players. I am pretty proficient at writing and handling SQL but I was wondering how I would go about saving a players bank. Obviously I don't want to manually create over 300 fields for each bank slot and amount so what would be the best way to approach saving their banks? If someone could explain it or provide me a code sample of an actual rsps bank saving SQL query since I know a lot of servers are saving via SQL databases, that would be very helpful and I will definitely rep++ to anyone who can give me a good answer.
    Reply With Quote  
     

  2. #2  
    Respected Member


    Join Date
    Jan 2009
    Posts
    5,743
    Thanks given
    1,162
    Thanks received
    3,603
    Rep Power
    5000
    player table -> id, username, password
    bank table -> id, player_id, slot, item, amount

    Code:
    CREATE TABLE IF NOT EXISTS `players` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `created` int(9) DEFAULT NULL,
      `username` varchar(12) DEFAULT NULL,
      `password` char(32) DEFAULT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `username` (`username`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    
    CREATE TABLE IF NOT EXISTS `player_bank` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `player_id` int(11) unsigned NOT NULL,
      `slot` smallint(3) NOT NULL,
      `item` smallint(5) NOT NULL,
      `amount` int(11) NOT NULL,
      PRIMARY KEY (`id`,`player_id`),
      KEY `FK__players` (`player_id`),
      CONSTRAINT `player_bank_ibfk_1` FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    remember mysql is a RELATIONAL database.

    http://www.anchor.com.au/hosting/sup...tionalDatabase Some very good explanations and examples
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Banned
    Join Date
    Sep 2013
    Posts
    236
    Thanks given
    145
    Thanks received
    52
    Rep Power
    0
    As Stuart said but before we decide to do such a thing I really suggest you make 100% sure your website is completely secure before doing this. Once that database gets hacked you're asking for mass hackings potentionally being hacked 9000 times a day like battlescape.
    Reply With Quote  
     

  5. #4  
    Banned

    Join Date
    Jul 2011
    Posts
    691
    Thanks given
    163
    Thanks received
    161
    Rep Power
    0
    Quote Originally Posted by Stuart View Post
    player table -> id, username, password
    bank table -> id, player_id, slot, item, amount

    Code:
    CREATE TABLE IF NOT EXISTS `players` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `created` int(9) DEFAULT NULL,
      `username` varchar(12) DEFAULT NULL,
      `password` char(32) DEFAULT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `username` (`username`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    
    CREATE TABLE IF NOT EXISTS `player_bank` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `player_id` int(11) unsigned NOT NULL,
      `slot` smallint(3) NOT NULL,
      `item` smallint(5) NOT NULL,
      `amount` int(11) NOT NULL,
      PRIMARY KEY (`id`,`player_id`),
      KEY `FK__players` (`player_id`),
      CONSTRAINT `player_bank_ibfk_1` FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    remember mysql is a RELATIONAL database.

    Creating A Quick MySQL Relational Database Tutorial Using All Common Relationships - Web and dedicated hosting tutorials by Anchor Some very good explanations and examples
    So kind of like this, correct?


    Quote Originally Posted by Kr4zyf4ken View Post
    As Stuart said but before we decide to do such a thing I really suggest you make 100% sure your website is completely secure before doing this. Once that database gets hacked you're asking for mass hackings potentionally being hacked 9000 times a day like battlescape.
    I am running it off of my VPS and trust and believe it is more secure than the white house. Also a lot of my sensitive data like player passwords and such are all encrypted.
    Reply With Quote  
     

  6. #5  
    Respected Member


    Join Date
    Jan 2009
    Posts
    5,743
    Thanks given
    1,162
    Thanks received
    3,603
    Rep Power
    5000
    Quote Originally Posted by Slawth Baws View Post
    So kind of like this, correct?




    I am running it off of my VPS and trust and believe it is more secure than the white house. Also a lot of my sensitive data like player passwords and such are all encrypted.
    do not use playername as a key, use the player incremental id. you will regret using playername.
    Reply With Quote  
     

  7. Thankful users:


  8. #6  
    Banned

    Join Date
    Jul 2011
    Posts
    691
    Thanks given
    163
    Thanks received
    161
    Rep Power
    0
    Quote Originally Posted by Stuart View Post
    do not use playername as a key, use the player incremental id. you will regret using playername.
    Ok. Do you mind if I ask why? And also what do you mean by player incremental id?
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [562][rs2hd] MySQL Player Saving & Loading [REQ]
    By coolv1994 in forum Requests
    Replies: 11
    Last Post: 09-11-2011, 01:36 AM
  2. Replies: 4
    Last Post: 03-27-2011, 12:58 AM
  3. Player Saving via xml or dat
    By Lord Military in forum Help
    Replies: 5
    Last Post: 05-09-2010, 02:07 PM
  4. Player loading via mysql
    By Pronyma in forum Application Development
    Replies: 1
    Last Post: 03-26-2010, 08:11 PM
  5. Replies: 6
    Last Post: 08-22-2008, 12:11 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •