gift

Newbie Spellweaver
Joined
Apr 27, 2009
Messages
19
Reaction score
0
Code:
if (splitted[0].equalsIgnoreCase("!gift")) {
    String type = splitted[2].toLowerCase();
    MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
    int amount = Integer.parseInt(splitted[3]);
    if (type.equalsIgnoreCase("mesos")) {
        if (victim.getMeso() + amount > Integer.MAX_VALUE)
            player.dropMessage(1, "If you give " + victim.getName() + " this many mesos, they will have more than " + Integer.MAX_VALUE + ".");
        else {
            victim.gainMeso(amount, true);
            victim.dropMessage("[Server] " + player.getName() + " has just given you " + amount + " mesos.");
        }
    }else if (type.equalsIgnoreCase("nx")) {
        victim.modifyCSPoints(1, amount);
        victim.dropMessage(5, amount >= 0 ? "[Server] " + player.getName() + " has gifted you " + amount + " NX Cash." : "[Server] " + player.getName() + " has taken away " + amount + " NX Cash from you.");
    }
}

Thanks to X-Stasis for fixing & cleaning it up.
 
Last edited:
Not to mention that you Meso give way is bad.

PHP:
if (splitted[0].equalsIgnoreCase("!gift")) {
    String type = splitted[2].toLowerCase();
    MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
    int amount = Integer.parseInt(splitted[3]);
    if (type.equalsIgnoreCase("mesos")) {
        if (victim.getMeso() + amount > Integer.MAX_VALUE)
            player.dropMessage(1, "If you give " + victim.getName() + " this many mesos, they will have more than " + Integer.MAX_VALUE + ".");
        else {
            victim.gainMeso(amount, true);
            victim.dropMessage("[Server] " + player.getName() + " has just given you " + amount + " mesos.");
        }
    }else if (type.equalsIgnoreCase("nx")) {
        victim.modifyCSPoints(1, amount);
        victim.dropMessage(5, amount >= 0 ? "[Server] " + player.getName() + " has gifted you " + amount + " NX Cash." : "[Server] " + player.getName() + " has taken away " + amount + " NX Cash from you.");
    }
}
 
Not to mention that you Meso give way is bad.

PHP:
if (splitted[0].equalsIgnoreCase("!gift")) {
    String type = splitted[2].toLowerCase();
    MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
    int amount = Integer.parseInt(splitted[3]);
    if (type.equalsIgnoreCase("mesos")) {
        if (victim.getMeso() + amount > Integer.MAX_VALUE)
            player.dropMessage(1, "If you give " + victim.getName() + " this many mesos, they will have more than " + Integer.MAX_VALUE + ".");
        else {
            victim.gainMeso(amount, true);
            victim.dropMessage("[Server] " + player.getName() + " has just given you " + amount + " mesos.");
        }
    }else if (type.equalsIgnoreCase("nx")) {
        victim.modifyCSPoints(1, amount);
        victim.dropMessage(5, amount >= 0 ? "[Server] " + player.getName() + " has gifted you " + amount + " NX Cash." : "[Server] " + player.getName() + " has taken away " + amount + " NX Cash from you.");
    }
}

k w/e thx <--- not too short
 
Integer.MAX_VALUE - victim.getMeso() > Integer.MAX_VALUE

IntergerMax Value, 2,14bil..

2,14bil - Get User Mesos... WILL NEVER BE GREATER THAN 2,14bil.

It's a dumb check.

There was a purpose for that... I honestly can't remember what I was trying to do. I think it had something to do with the amount the person wanted to give to the player being over the meso limit if added to the user's current meso.
 
Back