Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.rs.utils;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import com.rs.cores.mysql.Database;
- import com.rs.game.World;
- import com.rs.game.player.Player;
- import com.rs.game.player.content.Raffle;
- /**
- * Add to command like so:
- * new Thread(new FoxVote(player)).start();
- *
- */
- public class FoxVote implements Runnable {
- private static String host = "173.82.152.23";// connection ip
- private static String data = "drygonew_drygon_vote";// database name
- private static String user = "drygonew_vote";// username
- private static String pass = "Nike2323"; // password
- private Player player;
- public FoxVote(Player player) {
- this.player = player;
- }
- @Override
- public void run() {
- try {
- Database db = new Database(host, user, pass, data);
- if (!db.init()) {
- return;
- }
- String name = player.getUsername();
- ResultSet rs = db.executeQuery("SELECT * FROM fx_votes WHERE username='"+name+"' AND claimed=0 AND callback_date IS NOT NULL");
- while (rs.next()) {
- String timestamp = rs.getTimestamp("callback_date").toString();
- String ipAddress = rs.getString("ip_address");
- int siteId = rs.getInt("site_id");
- player.VotePoint ++;
- player.amountvotedtoday ++;
- Raffle.addVoterToList(player.getUsername());
- if (player.getInventory().hasFreeSlots() != true) {
- player.getBank().addItem(5022, 1, true);
- } else {
- player.getInventory().addItem(5022, 1);
- }
- if (player.amountvotedtoday <= 12)
- player.amountvotedthismonth11 ++;
- TopVoters.checkRank(player);
- player.sendMessage("<col=00ff00>You were rewarded 1 vote point & 1M ticket, you now have "+player.VotePoint+" vote points.</col>");
- if (player.votedtoday != true) {
- World.sendWorldMessage("<col=ff0000> "+player.getDisplayName()+" has just voted! Vote now by typing ;;vote!", false);
- player.votedtoday = true;
- }
- rs.updateInt("claimed", 1); // do not delete otherwise they can reclaim!
- rs.updateRow();
- // System.out.println("[FoxVote] Vote claimed by "+name+". (sid: "+siteId+", ip: "+ipAddress+", time: "+timestamp+")");
- }
- db.destroyAll();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement