Advertisement
Guest User

Untitled

a guest
Nov 26th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. public static int loadGame(Player p, String playerName, String playerPass) {
  2. System.out.println("Work in progress! " + p.playerName);
  3. int send = 0;
  4. System.out.println("test : " + playerName + ", p = " + p.playerName);
  5. //Mysql load the points etc!
  6. try {
  7. Server.conGameData = DriverManager.getConnection(
  8. "jdbc:mysql://srv.zarpor.org/zarpordb?charSet=ISO8859-1&autoReconnect=true&failOverReadOnly=false&maxReconnects=10", Server.MySQLUser,
  9. Server.MySQLPassword);
  10. Statement stmt = Server.conGameData.createStatement();
  11. String query = "select * from accounts where playerName = '" + playerName + "'";
  12. ResultSet rs = stmt.executeQuery(query);
  13.  
  14. if (rs.next()) {
  15. if(rs.getString("playerName").equals(playerName) || rs.getString("playerName").equalsIgnoreCase(playerName)) {
  16. String Pass = new String(rs.getString("playerPass").getBytes("ISO-8859-1"), "ISO-8859-1");
  17. p.playerPass = Pass;
  18. Boolean updated = false;
  19. if (updated || Hash.stringToSHA1(playerPass).equals(Pass)) {
  20. playerPass = Pass;
  21. p.dbId = rs.getInt("id");
  22.  
  23. if (rs.getInt("charX") <= 0 || rs.getInt("charY") <= 0) {
  24. p.teleportToX = 2113;
  25. p.teleportToY = 3915;
  26. p.heightLevel = 0;
  27. } else {
  28. p.teleportToX = rs.getInt("charX");
  29. p.teleportToY = rs.getInt("charY");
  30. p.heightLevel = rs.getInt("charZ");
  31. }
  32.  
  33. p.playerGroup = rs.getInt("usergroupid");
  34. p.playerRights = rs.getInt("playerRights");
  35.  
  36. //Points
  37. p.pcPoints = rs.getInt("PC_Points");
  38. p.duoPoints = rs.getInt("Duo_Slayer_Points");
  39. p.slayerPoints = rs.getInt("Slayer_Points");
  40. p.pkPoints = rs.getInt("PK_Points");
  41. p.achievementPoint = rs.getInt("Achievement_Points");
  42. p.voteTotalPoints = rs.getInt("Total_Vote_Points");
  43. p.votePoints = rs.getInt("Vote_Points");
  44.  
  45. } else {
  46. return 3;
  47. }
  48. } else {
  49. send = 12;
  50. }
  51. } else {
  52. return 12;
  53. }
  54.  
  55. } catch (Exception e) {
  56. e.printStackTrace();
  57. return 13;
  58. }
  59.  
  60. if(loadGame_file(p, playerName) > send && send == 0)
  61. return loadGame_file(p, playerName);
  62. return send;
  63. }
  64.  
  65. public static void saveGame(Client p) {
  66. System.out.println("Work in progress! " + p.playerName);
  67. try {
  68. Server.conGameData = DriverManager.getConnection(
  69. "jdbc:mysql://srv.zarpor.org/zarpordb?charSet=ISO8859-1&autoReconnect=true&failOverReadOnly=false&maxReconnects=10", Server.MySQLUser,
  70. Server.MySQLPassword);
  71. Statement stmt = Server.conGameData.createStatement();
  72. String query = "UPDATE `accounts` SET x = "+ p.absX +", y = "+ p.absY +", z = "+ p.heightLevel + ", PC_Points = '" + p.pcPoints + "', Duo_Slayer_Points = "+p.duoPoints+", Slayer_Points = "+p.slayerPoints+", PK_Points = "+p.pkPoints+", Achievement_Points = "+p.achievementPoint+", Total_Vote_Points = "+p.voteTotalPoints+", Vote_Points = "+p.votePoints+" WHERE id = " + p.dbId;
  73. stmt.executeUpdate(query);
  74. saveGame_file(p);
  75. } catch (Exception e) {
  76. e.printStackTrace();
  77. System.out.println("Save Exception: " + p.playerId + ", " + p.playerName);
  78. return;
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement