-
[Mini-Addon] Stat Command
This command isn't good or impressive in anyway, I was just fooling around looking at my source, then I got bored and made this... use it if you want (its quite similar to "@str/dex/int/luk) But you can see the obvious difference. It can be for GMs or players depending on your rates, but nevertheless... enjoy.
PHP Code:
} else if (splitted[0].equalsIgnoreCase("StatEdit")) {
MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
if (victim != null) {
if (splitted[2].equalsIgnoreCase("str")) {
victim.setStr(Integer.parseInt(splitted[3]));
victim.updateSingleStat(MapleStat.STR, victim.getStr());
} else if (splitted[2].equalsIgnoreCase("dex")) {
victim.setDex(Integer.parseInt(splitted[3]));
victim.updateSingleStat(MapleStat.DEX, victim.getDex());
} else if (splitted[2].equalsIgnoreCase("int")) {
victim.setInt(Integer.parseInt(splitted[3]));
victim.updateSingleStat(MapleStat.INT, victim.getInt());
} else if (splitted[2].equalsIgnoreCase("luk")) {
victim.setLuk(Integer.parseInt(splitted[3]));
victim.updateSingleStat(MapleStat.LUK, victim.getLuk());
} else if (splitted[2].equalsIgnoreCase("hp")) {
victim.setHp(Integer.parseInt(splitted[3]));
victim.updateSingleStat(MapleStat.HP, victim.getHp());
} else if (splitted[2].equalsIgnoreCase("mp")) {
victim.setMp(Integer.parseInt(splitted[3]));
victim.updateSingleStat(MapleStat.MP, victim.getMp());
} else {
return true;
}
victim.dropMessage("Your " + splitted[2] + " has been changed to " + splitted[3] + "");
player.dropMessage("The stat: " + splitted[2] + " of the user: " + victim+ " has been successfully updated to: " + splitted[3] + "");
} else {
player.dropMessage(victim +" could not be found");
}
Code:
Syntax: !statedit <ign> <stat> <amount>
If I missed something in my daze of sleepiness or you want anything added I'll do my best. Sorry if I messed up on something it seems fine though :$: <--- Bloodshot eyes
Edit: Updated.
Edit 2: Updated -- Do I have one too many brackets?
-
Re: [Mini-Addon] Stat Command
Awesome! As you said its similar to the @str/luk/dex/int, but nice job!
-
Re: [Mini-Addon] Stat Command
Sure is a dumb release in here
Quote:
victim.dropMessage("The stat: " + splitted[2] + " of the user: " + splitted[1] + " has been successfully updated to: " + splitted[3]);
Why are you telling the targeted maplecharacter instance this message? Your logic is flawed. Apparently putting none of the said stats means that the player cannot be found. COOL!
-
Re: [Mini-Addon] Stat Command
Edited it to work with MoopleDEV, and just to make Rice happy changed what it says to the person doing the command and had it say "Your "statname" has been changed" to the player.
PHP Code:
} else if (sub[0].equalsIgnoreCase("StatEdit")) {
MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(sub[1]);
if(victim != null) {
if (sub[2].equalsIgnoreCase("str")) {
victim.setStr(Integer.parseInt(sub[3]));
victim.updateSingleStat(MapleStat.STR, victim.getStr());
} else if (sub[2].equalsIgnoreCase("dex")) {
victim.setDex(Integer.parseInt(sub[3]));
victim.updateSingleStat(MapleStat.DEX, victim.getDex());
} else if (sub[2].equalsIgnoreCase("int")) {
victim.setInt(Integer.parseInt(sub[3]));
victim.updateSingleStat(MapleStat.INT, victim.getInt());
} else if (sub[2].equalsIgnoreCase("luk")) {
victim.setLuk(Integer.parseInt(sub[3]));
victim.updateSingleStat(MapleStat.LUK, victim.getLuk());
} else if (sub[2].equalsIgnoreCase("hp")) {
victim.setHp(Integer.parseInt(sub[3]));
victim.updateSingleStat(MapleStat.HP, victim.getHp());
} else if (sub[2].equalsIgnoreCase("mp")) {
victim.setMp(Integer.parseInt(sub[3]));
victim.updateSingleStat(MapleStat.MP, victim.getMp());
victim.dropMessage("Your " + sub[2] + " has been changed to " + sub [3] + "");
player.dropMessage("The stat: " + sub[2] + " of the user: " + sub[1] + " has been successfully updated to: " + sub[3]+ "");
} else {
player.dropMessage("The player could not be found");
}
}
Also, in the OP, this needs to be changed.
Code:
victim.dropMessage("The stat: " + sub[2] + " of the user: " + sub[1] + " has been successfully updated to: " + sub[3]);
to
Code:
victim.dropMessage("The stat: " + sub[2] + " of the user: " + sub[1] + " has been successfully updated to: " + sub[3]+ "");
-
Re: [Mini-Addon] Stat Command
This looks amazing o-o!! Great job!
-
Re: [Mini-Addon] Stat Command
This message only sends when they're updating the MP
Code:
victim.dropMessage("The stat: " + splitted[2] + " of the user: " + splitted[1] + " has been successfully updated to: " + splitted[3]);
-
Re: [Mini-Addon] Stat Command
Quote:
Originally Posted by
Xerixe
This message only sends when they're updating the MP
Code:
victim.dropMessage("The stat: " + splitted[2] + " of the user: " + splitted[1] + " has been successfully updated to: " + splitted[3]);
^
Yeah, you'd better test before you release.
-
Re: [Mini-Addon] Stat Command
Quote:
Originally Posted by
mertjuh
^
Yeah, you'd better test before you release.
I was too tired to check anything last night. But thanks for letting me know. I updated it.
If you still notice something wrong let me know.
-
Re: [Mini-Addon] Stat Command
Insted of adding
PHP Code:
victim.dropMessage("Your " + splitted[2] + " has been changed to " + splitted[3] + "");
like 5 times you could have just added it once above
} else {
-
Re: [Mini-Addon] Stat Command
I did not read it completely, but the logic of:
PHP Code:
victim.dropMessage("Your " + splitted[2] + " has been changed to " + splitted[3] + "");
player.dropMessage("The stat: " + splitted[2] + " of the user: " + splitted[1] + " has been successfully updated to: " + splitted[3]+ "");
}
Is really silly, like, why you made it so "adaptable" when you keep on repeating it for each case? It makes no sense, just put the words instead.
-
Re: [Mini-Addon] Stat Command
Quote:
Originally Posted by
xane666
This looks amazing o-o!! Great job!
Every release thread has Xane comment something almost exactly like this.
-
Re: [Mini-Addon] Stat Command
Good job! I am going to use this!
-
Re: [Mini-Addon] Stat Command
Quote:
Originally Posted by
Rift
Insted of adding
PHP Code:
victim.dropMessage("Your " + splitted[2] + " has been changed to " + splitted[3] + "");
like 5 times you could have just added it once above
} else {
Thanks for the input Charlie.
Thanks Osiris
And LOL @ Angel.
-
Re: [Mini-Addon] Stat Command
Quote:
Originally Posted by
BloodAngel13
Every release thread has Xane comment something almost exactly like this.
Not on every thred lol i look through it and if i like it i have something good to say but if i dont like it ill complain but im not mean lol
-
Re: [Mini-Addon] Stat Command
Yup a bracket too many, anyway I think it's better to add a statcheck since it would be weird if you type something weird and the victim would see it.
PHP Code:
} else if (splitted[0].equalsIgnoreCase("StatEdit")) {
MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
if (victim != null) {
if (splitted[2].equalsIgnoreCase("str")) {
victim.setStr(Integer.parseInt(splitted[3]));
victim.updateSingleStat(MapleStat.STR, victim.getStr());
} else if (splitted[2].equalsIgnoreCase("dex")) {
victim.setDex(Integer.parseInt(splitted[3]));
victim.updateSingleStat(MapleStat.DEX, victim.getDex());
} else if (splitted[2].equalsIgnoreCase("int")) {
victim.setInt(Integer.parseInt(splitted[3]));
victim.updateSingleStat(MapleStat.INT, victim.getInt());
} else if (splitted[2].equalsIgnoreCase("luk")) {
victim.setLuk(Integer.parseInt(splitted[3]));
victim.updateSingleStat(MapleStat.LUK, victim.getLuk());
} else if (splitted[2].equalsIgnoreCase("hp")) {
victim.setHp(Integer.parseInt(splitted[3]));
victim.updateSingleStat(MapleStat.HP, victim.getHp());
} else if (splitted[2].equalsIgnoreCase("mp")) {
victim.setMp(Integer.parseInt(splitted[3]));
victim.updateSingleStat(MapleStat.MP, victim.getMp());
} else {
return true;
}
victim.dropMessage("Your " + splitted[2] + " has been changed to " + splitted[3] + "");
player.dropMessage("The stat: " + splitted[2] + " of the user: " + victim+ " has been successfully updated to: " + splitted[3] + "");
} else {
player.dropMessage(victim+" could not be found");
}
PS: change
to
if you get errors
-
Re: [Mini-Addon] Stat Command
-
Re: [Mini-Addon] Stat Command
Maybe include a command that will show you their stats as well, so you're not just editing blindly. Other than that, gj, looks clean. Why are you returning it as true tho? I would just take out the else completely or have it return false. Or just return; unless it gives you errors.
-
Re: [Mini-Addon] Stat Command
Quote:
Originally Posted by
Sharky
Maybe include a command that will show you their stats as well, so you're not just editing blindly. Other than that, gj, looks clean. Why are you returning it as true tho? I would just take out the else completely or have it return false. Or just return; unless it gives you errors.
That doesn't make much sense tbh, returning true means that the command is located here, it also means the rest of the command will not get executed which is more useful.
-
Re: [Mini-Addon] Stat Command
Quote:
Originally Posted by
mertjuh
That doesn't make much sense tbh, returning true means that the command is located here, it also means the rest of the command will not get executed which is more useful.
My bad, you're right.
-
Re: [Mini-Addon] Stat Command
Why not just use getNamedIntArg instead of all those else if's?
-
Re: [Mini-Addon] Stat Command
Quote:
Originally Posted by
AskHugo
Why not just use getNamedIntArg instead of all those else if's?
Explain please.
@Chris, it does display what their stats after the command is executed. (the stat you changed). For check their stats before hand, !charinfo and !spy have been invented.
-
Re: [Mini-Addon] Stat Command
PHP Code:
} else if (splitted[0].equalsIgnoreCase("!statedit")) {
MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
if (splitted.length > 1 && splitted.length < 19) {
if (victim != null) {
int str = (getNamedIntArg(splitted, 2, "str") == null ? victim.getStr() : getNamedIntArg(splitted, 2, "str"));
int dex = (getNamedIntArg(splitted, 2, "dex") == null ? victim.getDex() : getNamedIntArg(splitted, 2, "dex"));
int Int = (getNamedIntArg(splitted, 2, "int") == null ? victim.getInt() : getNamedIntArg(splitted, 2, "int"));
int luk = (getNamedIntArg(splitted, 2, "luk") == null ? victim.getLuk() : getNamedIntArg(splitted, 2, "luk"));
int hp = (getNamedIntArg(splitted, 2, "hp") == null ? victim.getHp() : getNamedIntArg(splitted, 2, "hp"));
int mp = (getNamedIntArg(splitted, 2, "mp") == null ? victim.getMp() : getNamedIntArg(splitted, 2, "mp"));
int maxhp = (getNamedIntArg(splitted, 2, "maxhp") == null ? victim.getMaxHp() : getNamedIntArg(splitted, 2, "maxhp"));
int maxmp = (getNamedIntArg(splitted, 2, "maxmp") == null ? victim.getMaxMp() : getNamedIntArg(splitted, 2, "maxmp"));
victim.setStr(str);
victim.setDex(dex);
victim.setInt(Int);
victim.setLuk(luk);
victim.setHp(hp);
victim.setMp(mp);
victim.setMaxHp(maxhp);
victim.setMaxMp(maxmp);
victim.updateSingleStat(MapleStat.STR, str);
victim.updateSingleStat(MapleStat.DEX, dex);
victim.updateSingleStat(MapleStat.INT, Int);
victim.updateSingleStat(MapleStat.LUK, luk);
victim.updateSingleStat(MapleStat.HP, hp);
victim.updateSingleStat(MapleStat.MP, mp);
victim.updateSingleStat(MapleStat.MAXHP, maxhp);
victim.updateSingleStat(MapleStat.MAXMP, maxmp);
player.dropMessage("Your stats have been changed by " + player.getName());
victim.dropMessage("You have changed " + victim.getName() + "'s stats");
String update = "New stats: str : " + str + " dex: " + dex + " int: " + Int + " luk: " + luk + " hp: " + hp + " mp: " + mp + " maxhp:" + maxhp + " maxmp:" + maxmp;
player.dropMessage(update);
victim.dropMessage(update);
} else {
player.dropMessage(victim + " could not be found");
}
} else {
mc.dropMessage("Syntax : !statedit <ign> <str/dex/int/luk/mp/hp>");
mc.dropMessage("Example : !statedit noob str 10 dex 10 int 100");
}
Coded a little something something.
You can pass how many you want in any order.
-
Re: [Mini-Addon] Stat Command
Thats even longer and more confusing. The command I made is fine but thats for enlightening me on that function... (so many variables...)
And the syntax is more like
!statedit AskHugo str 1
Adds one to AskHugo's strength.
-
Re: [Mini-Addon] Stat Command
No you don't get it.
I could do !statedit hugo str 10 dex 10
or
!statedit hugo luk 10 str 10 int 10
and they would both work.
PHP Code:
} else if (splitted[0].equalsIgnoreCase("!statedit")) {
MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
if (splitted.length > 2 && splitted.length < 29) {
if (victim != null) {
int str = (getNamedIntArg(splitted, 2, "str") == null ? victim.getStr() : getNamedIntArg(splitted, 2, "str"));
int dex = (getNamedIntArg(splitted, 2, "dex") == null ? victim.getDex() : getNamedIntArg(splitted, 2, "dex"));
int Int = (getNamedIntArg(splitted, 2, "int") == null ? victim.getInt() : getNamedIntArg(splitted, 2, "int"));
int luk = (getNamedIntArg(splitted, 2, "luk") == null ? victim.getLuk() : getNamedIntArg(splitted, 2, "luk"));
int hp = (getNamedIntArg(splitted, 2, "hp") == null ? victim.getHp() : getNamedIntArg(splitted, 2, "hp"));
int mp = (getNamedIntArg(splitted, 2, "mp") == null ? victim.getMp() : getNamedIntArg(splitted, 2, "mp"));
int maxhp = (getNamedIntArg(splitted, 2, "maxhp") == null ? victim.getMaxHp() : getNamedIntArg(splitted, 2, "maxhp"));
int maxmp = (getNamedIntArg(splitted, 2, "maxmp") == null ? victim.getMaxMp() : getNamedIntArg(splitted, 2, "maxmp"));
int fame = (getNamedIntArg(splitted, 2, "fame") == null ? victim.getFame() : getNamedIntArg(splitted, 2, "fame"));
int job = (getNamedIntArg(splitted, 2, "job") == null ? victim.getJob().getId() : getNamedIntArg(splitted, 2, "job"));
int meso = (getNamedIntArg(splitted, 2, "meso") == null ? victim.getMeso() : getNamedIntArg(splitted, 2, "meso"));
int lvl = (getNamedIntArg(splitted, 2, "lvl") == null ? victim.getLevel() : getNamedIntArg(splitted, 2, "lvl"));
int exp = (getNamedIntArg(splitted, 2, "exp") == null ? victim.getExp() : getNamedIntArg(splitted, 2, "exp"));
victim.setStr(str);
victim.setDex(dex);
victim.setInt(Int);
victim.setLuk(luk);
victim.setHp(hp);
victim.setMp(mp);
victim.setMaxHp(maxhp);
victim.setMaxMp(maxmp);
victim.setFame(fame);
victim.setJob(job);
victim.setMeso(meso);
victim.setLevel(lvl);
victim.setExp(exp);
victim.updateSingleStat(MapleStat.STR, str);
victim.updateSingleStat(MapleStat.DEX, dex);
victim.updateSingleStat(MapleStat.INT, Int);
victim.updateSingleStat(MapleStat.LUK, luk);
victim.updateSingleStat(MapleStat.HP, hp);
victim.updateSingleStat(MapleStat.MP, mp);
victim.updateSingleStat(MapleStat.MAXHP, maxhp);
victim.updateSingleStat(MapleStat.MAXMP, maxmp);
victim.updateSingleStat(MapleStat.FAME, fame);
victim.updateSingleStat(MapleStat.MESO, meso);
victim.updateSingleStat(MapleStat.JOB, job);
victim.updateSingleStat(MapleStat.LEVEL, lvl);
victim.updateSingleStat(MapleStat.EXP, exp);
player.dropMessage("Your stats have been changed by " + player.getName());
victim.dropMessage("You have changed " + victim.getName() + "'s stats");
String update = "New stats: str: " + str + " dex: " + dex + " int: " + Int + " luk: " + luk + " hp: " + hp + " mp: " + mp + " maxhp:" + maxhp + " maxmp:" + maxmp + " fame: " + fame + " meso: " + meso + " job: " + job + " lvl: " + lvl + " exp: " + exp;
player.dropMessage(update);
victim.dropMessage(update);
} else {
player.dropMessage(victim + " could not be found");
}
} else {
mc.dropMessage("Syntax : !statedit <ign> <str/dex/int/luk/mp/hp/maxhp/maxmp/fame/meso/job/lvl/exp>");
mc.dropMessage("Example : !statedit noob str 10 dex 10 int 100");
}
Anyways, updated to work with almost any stat you want to edit.
Go try it yourself.
If you don't have the function, you need to add this:
PHP Code:
public static String getNamedArg(String splitted[], int startpos, String name) {
for (int i = startpos; i < splitted.length; i++) {
if (splitted[i].equalsIgnoreCase(name) && i + 1 < splitted.length) {
return splitted[i + 1];
}
}
return null;
}
public static Integer getNamedIntArg(String splitted[], int startpos, String name) {
String arg = getNamedArg(splitted, startpos, name);
if (arg != null) {
try {
return Integer.parseInt(arg);
} catch (NumberFormatException nfe) {
}
}
return null;
}
-
Re: [Mini-Addon] Stat Command
Quote:
Originally Posted by
AskHugo
No you don't get it.
I could do !statedit hugo str 10 dex 10
or
!statedit hugo luk 10 str 10 int 10
and they would both work.
PHP Code:
} else if (splitted[0].equalsIgnoreCase("!statedit")) {
MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
if (splitted.length > 2 && splitted.length < 29) {
if (victim != null) {
int str = (getNamedIntArg(splitted, 2, "str") == null ? victim.getStr() : getNamedIntArg(splitted, 2, "str"));
int dex = (getNamedIntArg(splitted, 2, "dex") == null ? victim.getDex() : getNamedIntArg(splitted, 2, "dex"));
int Int = (getNamedIntArg(splitted, 2, "int") == null ? victim.getInt() : getNamedIntArg(splitted, 2, "int"));
int luk = (getNamedIntArg(splitted, 2, "luk") == null ? victim.getLuk() : getNamedIntArg(splitted, 2, "luk"));
int hp = (getNamedIntArg(splitted, 2, "hp") == null ? victim.getHp() : getNamedIntArg(splitted, 2, "hp"));
int mp = (getNamedIntArg(splitted, 2, "mp") == null ? victim.getMp() : getNamedIntArg(splitted, 2, "mp"));
int maxhp = (getNamedIntArg(splitted, 2, "maxhp") == null ? victim.getMaxHp() : getNamedIntArg(splitted, 2, "maxhp"));
int maxmp = (getNamedIntArg(splitted, 2, "maxmp") == null ? victim.getMaxMp() : getNamedIntArg(splitted, 2, "maxmp"));
int fame = (getNamedIntArg(splitted, 2, "fame") == null ? victim.getFame() : getNamedIntArg(splitted, 2, "fame"));
int job = (getNamedIntArg(splitted, 2, "job") == null ? victim.getJob().getId() : getNamedIntArg(splitted, 2, "job"));
int meso = (getNamedIntArg(splitted, 2, "meso") == null ? victim.getMeso() : getNamedIntArg(splitted, 2, "meso"));
int lvl = (getNamedIntArg(splitted, 2, "lvl") == null ? victim.getLevel() : getNamedIntArg(splitted, 2, "lvl"));
int exp = (getNamedIntArg(splitted, 2, "exp") == null ? victim.getExp() : getNamedIntArg(splitted, 2, "exp"));
victim.setStr(str);
victim.setDex(dex);
victim.setInt(Int);
victim.setLuk(luk);
victim.setHp(hp);
victim.setMp(mp);
victim.setMaxHp(maxhp);
victim.setMaxMp(maxmp);
victim.setFame(fame);
victim.setJob(job);
victim.setMeso(meso);
victim.setLevel(lvl);
victim.setExp(exp);
victim.updateSingleStat(MapleStat.STR, str);
victim.updateSingleStat(MapleStat.DEX, dex);
victim.updateSingleStat(MapleStat.INT, Int);
victim.updateSingleStat(MapleStat.LUK, luk);
victim.updateSingleStat(MapleStat.HP, hp);
victim.updateSingleStat(MapleStat.MP, mp);
victim.updateSingleStat(MapleStat.MAXHP, maxhp);
victim.updateSingleStat(MapleStat.MAXMP, maxmp);
victim.updateSingleStat(MapleStat.FAME, fame);
victim.updateSingleStat(MapleStat.MESO, meso);
victim.updateSingleStat(MapleStat.JOB, job);
victim.updateSingleStat(MapleStat.LEVEL, lvl);
victim.updateSingleStat(MapleStat.EXP, exp);
player.dropMessage("Your stats have been changed by " + player.getName());
victim.dropMessage("You have changed " + victim.getName() + "'s stats");
String update = "New stats: str: " + str + " dex: " + dex + " int: " + Int + " luk: " + luk + " hp: " + hp + " mp: " + mp + " maxhp:" + maxhp + " maxmp:" + maxmp + " fame: " + fame + " meso: " + meso + " job: " + job + " lvl: " + lvl + " exp: " + exp;
player.dropMessage(update);
victim.dropMessage(update);
} else {
player.dropMessage(victim + " could not be found");
}
} else {
mc.dropMessage("Syntax : !statedit <ign> <str/dex/int/luk/mp/hp/maxhp/maxmp/fame/meso/job/lvl/exp>");
mc.dropMessage("Example : !statedit noob str 10 dex 10 int 100");
}
Anyways, updated to work with almost any stat you want to edit.
Go try it yourself.
If you don't have the function, you need to add this:
PHP Code:
public static String getNamedArg(String splitted[], int startpos, String name) {
for (int i = startpos; i < splitted.length; i++) {
if (splitted[i].equalsIgnoreCase(name) && i + 1 < splitted.length) {
return splitted[i + 1];
}
}
return null;
}
public static Integer getNamedIntArg(String splitted[], int startpos, String name) {
String arg = getNamedArg(splitted, startpos, name);
if (arg != null) {
try {
return Integer.parseInt(arg);
} catch (NumberFormatException nfe) {
}
}
return null;
}
I don't see what this one is better , it's not optimized and it updated all stats which is not necessary.