Advertisement
Guest User

Untitled

a guest
Apr 15th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. package com.rs.utils;
  2.  
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5.  
  6. import com.rs.cores.mysql.Database;
  7. import com.rs.game.World;
  8. import com.rs.game.player.Player;
  9. import com.rs.game.player.content.Raffle;
  10. /**
  11. * Add to command like so:
  12. * new Thread(new FoxVote(player)).start();
  13. *
  14. */
  15. public class FoxVote implements Runnable {
  16.  
  17. private static String host = "173.82.152.23";// connection ip
  18. private static String data = "drygonew_drygon_vote";// database name
  19. private static String user = "drygonew_vote";// username
  20. private static String pass = "Nike2323"; // password
  21.  
  22. private Player player;
  23. public FoxVote(Player player) {
  24. this.player = player;
  25. }
  26.  
  27. @Override
  28. public void run() {
  29. try {
  30. Database db = new Database(host, user, pass, data);
  31.  
  32. if (!db.init()) {
  33. return;
  34. }
  35.  
  36. String name = player.getUsername();
  37.  
  38. ResultSet rs = db.executeQuery("SELECT * FROM fx_votes WHERE username='"+name+"' AND claimed=0 AND callback_date IS NOT NULL");
  39. while (rs.next()) {
  40. String timestamp = rs.getTimestamp("callback_date").toString();
  41. String ipAddress = rs.getString("ip_address");
  42. int siteId = rs.getInt("site_id");
  43. player.VotePoint ++;
  44. player.amountvotedtoday ++;
  45. Raffle.addVoterToList(player.getUsername());
  46. if (player.getInventory().hasFreeSlots() != true) {
  47. player.getBank().addItem(5022, 1, true);
  48. } else {
  49. player.getInventory().addItem(5022, 1);
  50. }
  51. if (player.amountvotedtoday <= 12)
  52. player.amountvotedthismonth11 ++;
  53. TopVoters.checkRank(player);
  54. player.sendMessage("<col=00ff00>You were rewarded 1 vote point & 1M ticket, you now have "+player.VotePoint+" vote points.</col>");
  55. if (player.votedtoday != true) {
  56. World.sendWorldMessage("<col=ff0000> "+player.getDisplayName()+" has just voted! Vote now by typing ;;vote!", false);
  57. player.votedtoday = true;
  58. }
  59.  
  60. rs.updateInt("claimed", 1); // do not delete otherwise they can reclaim!
  61. rs.updateRow();
  62.  
  63. // System.out.println("[FoxVote] Vote claimed by "+name+". (sid: "+siteId+", ip: "+ipAddress+", time: "+timestamp+")");
  64. }
  65. db.destroyAll();
  66. } catch (Exception e) {
  67. e.printStackTrace();
  68. }
  69.  
  70. }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement