- Joined
- Oct 29, 2008
- Messages
- 563
- Reaction score
- 8
Code:
} else if (splitted[0].equals("!strike") || splitted[0].equals("!warn")) {
final MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
if(victim != null){
if(victim.getGMLevel() >= 1 && c.getPlayer().getGMLevel() <= 499){
mc.dropMessage("You can't give a strike to a gm.");
}else{
victim.strike();
mc.dropMessage("You have added a strike into " + victim.getName() + "'s Account if his/her strike number is 3 they will be banned.");
victim.dropMessage("You have recieved a strike from " + c.getPlayer().getName() + " If you recive 3 strikes on your account you will be banned.");
}
}else{
mc.dropMessage("Syntax: !strike <charname> where <charname> is the IGN of a player.");
}
} else if (splitted[0].equals("!strike") || splitted[0].equals("!warn")) {
final MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
if(victim != null){
if(victim.getGMLevel() >= 1 && c.getPlayer().getGMLevel() <= 499){
mc.dropMessage("You can't give a strike to a gm.");
}else{
victim.strike();
mc.dropMessage("You have added a strike into " + victim.getName() + "'s Account if his/her strike number is 3 they will be banned.");
victim.dropMessage("You have recieved a strike from " + c.getPlayer().getName() + " If you recive 3 strikes on your account you will be banned.");
}
}else{
mc.dropMessage("Syntax: !strike <charname> where <charname> is the IGN of a player.");
}
Functions :
//start strike system
public void ban() {
if (lastmonthfameids == null) {
throw new RuntimeException("Trying to ban a non-loaded character (testhack)");
}
try {
getClient().banMacs();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET banned = ? WHERE id = ?");
ps.setInt(1, 1);
ps.setInt(2, accountid);
ps.executeUpdate();
ps.close();
ps = con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?)");
String[] ipSplit = client.getSession().getRemoteAddress().toString().split(":");
ps.setString(1, ipSplit[0]);
ps.executeUpdate();
ps.close();
} catch (SQLException ex) {
log.error("Error while banning", ex);
}
client.getSession().close();
}
public void strike() {
int strike = 0;
Connection con = DatabaseConnection.getConnection();
try
{
PreparedStatement ps = con.prepareStatement("SELECT strike FROM accounts where id = ?");
ps.setInt(1, accountid);
ResultSet rs = ps.executeQuery();
if (!rs.next()) {
throw new RuntimeException("Checking for strikes failed!");
}
strike = rs.getInt("strike");
} catch(SQLException sql) {
}
if(strike == 0){
try {
con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET strike = ? WHERE id = ?");
ps.setInt(1, 1);
ps.setInt(2, accountid);
ps.executeUpdate();
ps.close();
} catch (SQLException ex) {
log.error("Error while Striking", ex);
}
dropMessage("You have been given a strike by a Game Master, you currently have 1 Strike(s).");
}
if(strike == 1){
try {
con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET strike = ? WHERE id = ?");
ps.setInt(1, 2);
ps.setInt(2, accountid);
ps.executeUpdate();
ps.close();
} catch (SQLException ex) {
log.error("Error while Striking", ex);
}
dropMessage("You have been given a strike by a Game Master, you currently have 2 Strike(s).");
}
if(strike == 2){
try {
con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET strike = ? WHERE id = ?");
ps.setInt(1, 3);
ps.setInt(2, accountid);
ps.executeUpdate();
ps.close();
} catch (SQLException ex) {
log.error("Error while Striking", ex);
}
ban();
client.getSession().close();
}
}
//end strike function
//start strike system
public void ban() {
if (lastmonthfameids == null) {
throw new RuntimeException("Trying to ban a non-loaded character (testhack)");
}
try {
getClient().banMacs();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET banned = ? WHERE id = ?");
ps.setInt(1, 1);
ps.setInt(2, accountid);
ps.executeUpdate();
ps.close();
ps = con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?)");
String[] ipSplit = client.getSession().getRemoteAddress().toString().split(":");
ps.setString(1, ipSplit[0]);
ps.executeUpdate();
ps.close();
} catch (SQLException ex) {
log.error("Error while banning", ex);
}
client.getSession().close();
}
public void strike() {
int strike = 0;
Connection con = DatabaseConnection.getConnection();
try
{
PreparedStatement ps = con.prepareStatement("SELECT strike FROM accounts where id = ?");
ps.setInt(1, accountid);
ResultSet rs = ps.executeQuery();
if (!rs.next()) {
throw new RuntimeException("Checking for strikes failed!");
}
strike = rs.getInt("strike");
} catch(SQLException sql) {
}
if(strike == 0){
try {
con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET strike = ? WHERE id = ?");
ps.setInt(1, 1);
ps.setInt(2, accountid);
ps.executeUpdate();
ps.close();
} catch (SQLException ex) {
log.error("Error while Striking", ex);
}
dropMessage("You have been given a strike by a Game Master, you currently have 1 Strike(s).");
}
if(strike == 1){
try {
con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET strike = ? WHERE id = ?");
ps.setInt(1, 2);
ps.setInt(2, accountid);
ps.executeUpdate();
ps.close();
} catch (SQLException ex) {
log.error("Error while Striking", ex);
}
dropMessage("You have been given a strike by a Game Master, you currently have 2 Strike(s).");
}
if(strike == 2){
try {
con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET strike = ? WHERE id = ?");
ps.setInt(1, 3);
ps.setInt(2, accountid);
ps.executeUpdate();
ps.close();
} catch (SQLException ex) {
log.error("Error while Striking", ex);
}
ban();
client.getSession().close();
}
}
//end strike function
Enjoy!
