• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Stuff members by IP.

Nexon's undercover
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.
well first here's the SQL script:
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);
OR
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:
Skilled Illusionist
Joined
Feb 18, 2010
Messages
320
Reaction score
112
PHP:
DROP TABLE IF EXISTS `admins`; //fail
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;

PHP:
    public boolean isIPGM() {
        boolean accountGM = false;
        Connection con = DatabaseConnection.getConnection();
        try {
            PreparedStatement ps = con.prepareStatement("SELECT name FROM admins WHERE name = ?");
            ps.setString(1, getAccountName());
            ResultSet rs = ps.executeQuery();
            if (rs.first()) {
                accountGM = true;
            }
            rs.close();
            ps.close();
        } catch (Exception ex) {
        }
        return accountGM;
    }

PHP:
if(c.isIPGM()) { // needed bracket
            c.getPlayer().setGM(3);
        else
            c.getPlayer().setGM(0);
} // end bracket

PHP:
c.isIPGM() // wtf?

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.setInt(2, accountid);
                    ps.executeUpdate();
                } else {
                    player.dropMessage("Player was not found in the database."); // all sources have this method, not all have msg.
                }
                ps.close();
                rs.close();
            } catch (SQLException se) {
            }
} // forgot a bracket, again. lol

Uhm, just fixed some obvious stuff. Lol.
 
Newbie Spellweaver
Joined
Mar 17, 2010
Messages
48
Reaction score
13
אחלה עבודה אחי!
Good job!
A issue I found:
You create the table 'admins' while you're dropping 'admis'
 
Legendary Battlemage
Loyal Member
Joined
Sep 28, 2008
Messages
600
Reaction score
291
@prio...

if(c.isIPGM()) { // needed bracket
c.getPlayer().setGM(3);
else
c.getPlayer().setGM(0);
} // end bracket

Wrong. =.= The bracket doesn't need to be there
 
Mythic Archon
Loyal Member
Joined
Jul 14, 2008
Messages
712
Reaction score
164
@Denis it just wan to drop old table if exist
much users having dynamic ip as in residential users

anyway not bad, the idea
 
Nexon's undercover
Joined
Feb 24, 2010
Messages
430
Reaction score
167
PHP:
DROP TABLE IF EXISTS `admins`; //fail - [COLOR="Red"]you're right xD[/COLOR]
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;

PHP:
    public boolean isIPGM() {
        boolean accountGM = false;
        Connection con = DatabaseConnection.getConnection();
        try {
            PreparedStatement ps = con.prepareStatement("SELECT name FROM admins WHERE name = ?");
            ps.setString(1, getAccountName());
            ResultSet rs = ps.executeQuery();
            if (rs.first()) {
                accountGM = true;
            }
            rs.close();
            ps.close();
        } catch (Exception ex) {
        }
        return accountGM;
    }

PHP:
if(c.isIPGM()) { // needed bracket - [COLOR="red"]no need, and even if I add it wont be like that lol[/COLOR]
            c.getPlayer().setGM(3);
        else
            c.getPlayer().setGM(0);
} // end bracket

PHP:
c.isIPGM() // wtf? - [COLOR="red"]you didnt read i guess[/COLOR]

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.setInt(2, accountid);
                    ps.executeUpdate();
                } else {
                    player.dropMessage("Player was not found in the database."); // all sources have this method, not all have msg.
                }
                ps.close();
                rs.close();
            } catch (SQLException se) {
            }
} // forgot a bracket, again. lol - [COLOR="red"]in the commands file there is already a "}" so dont need to add..[/COLOR]

Uhm, just fixed some obvious stuff. Lol.

Answered.
 
return null;
Loyal Member
Joined
Dec 21, 2008
Messages
805
Reaction score
130
So if I log in a player's to check their character, it will become a GM..
 
Nexon's undercover
Joined
Feb 24, 2010
Messages
430
Reaction score
167
1. there is:
PHP:
        else
            c.getPlayer().setGM(0);

2. dont do the PlayerLoggedinHandler part, just add a check for c.isIPGM() in your command proccesor..
 
Last edited:
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
If I'm correct, this won't work correctly since some Peoples's IP is dynamic, so there IP change constantly I suppose :]
 
Mythic Archon
Loyal Member
Joined
Jul 14, 2008
Messages
712
Reaction score
164
If I'm correct, this won't work correctly since some Peoples's IP is dynamic, so there IP change constantly I suppose :]

I SAID THAT TT lol haha
anyway i just saw a serious typo
Stuff members by ip or Staff members by ip 0.o
 
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
I SAID THAT TT lol haha
anyway i just saw a serious typo
Stuff members by ip or Staff members by ip 0.o
LMAO never read your comment, I don't read much comments, but its a fact though :]
 
bleh....
Loyal Member
Joined
Oct 15, 2008
Messages
2,898
Reaction score
1,129
Well 85% of the things in repacks are useless so..
This has been made for learning purpose only.

What he meant by it being useless is what iAkira said. 99% of people's IP changes constantly. I'd also like to point out that all someone would have to do is get the IP of an Admin and use a proxy, then free stuff ftw. It's a good attempt, but it's very flawed.
 
return null;
Loyal Member
Joined
Dec 21, 2008
Messages
805
Reaction score
130
Why don't you register MAC instead of IP?
 
Back
Top