Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int loadGame(Player p, String playerName, String playerPass) {
- System.out.println("Work in progress! " + p.playerName);
- int send = 0;
- System.out.println("test : " + playerName + ", p = " + p.playerName);
- //Mysql load the points etc!
- try {
- Server.conGameData = DriverManager.getConnection(
- "jdbc:mysql://srv.zarpor.org/zarpordb?charSet=ISO8859-1&autoReconnect=true&failOverReadOnly=false&maxReconnects=10", Server.MySQLUser,
- Server.MySQLPassword);
- Statement stmt = Server.conGameData.createStatement();
- String query = "select * from accounts where playerName = '" + playerName + "'";
- ResultSet rs = stmt.executeQuery(query);
- if (rs.next()) {
- if(rs.getString("playerName").equals(playerName) || rs.getString("playerName").equalsIgnoreCase(playerName)) {
- String Pass = new String(rs.getString("playerPass").getBytes("ISO-8859-1"), "ISO-8859-1");
- p.playerPass = Pass;
- Boolean updated = false;
- if (updated || Hash.stringToSHA1(playerPass).equals(Pass)) {
- playerPass = Pass;
- p.dbId = rs.getInt("id");
- if (rs.getInt("charX") <= 0 || rs.getInt("charY") <= 0) {
- p.teleportToX = 2113;
- p.teleportToY = 3915;
- p.heightLevel = 0;
- } else {
- p.teleportToX = rs.getInt("charX");
- p.teleportToY = rs.getInt("charY");
- p.heightLevel = rs.getInt("charZ");
- }
- p.playerGroup = rs.getInt("usergroupid");
- p.playerRights = rs.getInt("playerRights");
- //Points
- p.pcPoints = rs.getInt("PC_Points");
- p.duoPoints = rs.getInt("Duo_Slayer_Points");
- p.slayerPoints = rs.getInt("Slayer_Points");
- p.pkPoints = rs.getInt("PK_Points");
- p.achievementPoint = rs.getInt("Achievement_Points");
- p.voteTotalPoints = rs.getInt("Total_Vote_Points");
- p.votePoints = rs.getInt("Vote_Points");
- } else {
- return 3;
- }
- } else {
- send = 12;
- }
- } else {
- return 12;
- }
- } catch (Exception e) {
- e.printStackTrace();
- return 13;
- }
- if(loadGame_file(p, playerName) > send && send == 0)
- return loadGame_file(p, playerName);
- return send;
- }
- public static void saveGame(Client p) {
- System.out.println("Work in progress! " + p.playerName);
- try {
- Server.conGameData = DriverManager.getConnection(
- "jdbc:mysql://srv.zarpor.org/zarpordb?charSet=ISO8859-1&autoReconnect=true&failOverReadOnly=false&maxReconnects=10", Server.MySQLUser,
- Server.MySQLPassword);
- Statement stmt = Server.conGameData.createStatement();
- 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;
- stmt.executeUpdate(query);
- saveGame_file(p);
- } catch (Exception e) {
- e.printStackTrace();
- System.out.println("Save Exception: " + p.playerId + ", " + p.playerName);
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement