- Joined
- Feb 24, 2010
- Messages
- 430
- Reaction score
- 167
I took that idea from Counter-Strike :.
What it does that if someone's IP defind as Admin's IP when he logs in his character automaticly will have a gm level of 3 (or change to your choise).
I did not tested it since I dont host a server on my computer so please test and comment thanks.
Now please, if you dont know where to put the stuff I said, DONT USE IT.
What it does that if someone's IP defind as Admin's IP when he logs in his character automaticly will have a gm level of 3 (or change to your choise).
I did not tested it since I dont host a server on my computer so please test and comment thanks.
Now please, if you dont know where to put the stuff I said, DONT USE IT.
well first here's the SQL script:
Then add in MapleClient.java this function:
Then in PlayerLoggedinHandler.java add:
OR
add in your commandProccesor or w/e a check for:
Here's the command to make someone IPGM(please test):
PHP:
DROP TABLE IF EXISTS `admins`;
CREATE TABLE `admins` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(13) NOT NULL DEFAULT '',
`ip` tinytext NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Then add in MapleClient.java this function:
PHP:
public String getLastKnownIP() {
String ip = "";
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT lastknownip FROM accounts WHERE name = ?");
ps.setString(1, getAccountName());
ResultSet rs = ps.executeQuery();
if (rs.first()) {
ip = rs.getString("lastknownip");
} else {
ip = "error";
}
rs.close();
ps.close();
} catch (Exception ex) {
}
return ip;
}
public boolean isIPGM() {
boolean accountGM = false;
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT ip FROM admins WHERE ip = ?");
ps.setString(1, getLastKnownIP());
ResultSet rs = ps.executeQuery();
if (rs.first()) {
accountGM = true;
}
rs.close();
ps.close();
} catch (Exception ex) {
}
return accountGM;
}
Then in PlayerLoggedinHandler.java add:
PHP:
if(c.isIPGM())
c.getPlayer().setGM(3);
else
c.getPlayer().setGM(0);
add in your commandProccesor or w/e a check for:
PHP:
c.isIPGM()
Here's the command to make someone IPGM(please test):
PHP:
} else if (command.equals("setipgm")) {
int accountid;
String accountname;
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT accountid FROM characters WHERE name = ?");
ps.setString(1, splitted[1]);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
accountid = rs.getInt("accountid");
ps.close();
ps = con.prepareStatement("SELECT name FROM accounts WHERE id = ?");
ps.setInt(1, accountid);
ps.executeQuery();
accountname = rs.getString("name");
ps.close();
ps = con.prepareStatement("INSERT INTO admins (name, ip) VALUES (?, ?)");
ps.setString(1, accountname);
ps.setString(2, c.getLastKnownIP());
ps.executeUpdate();
} else {
player.msg("Player was not found in the database.");
}
ps.close();
rs.close();
} catch (SQLException se) {
}
Last edited: