Re: Couple of Commands[Updates : 5]
!spawnmob <mobid> <hp> <exp> <amount (optional)> for BubblesDEV
GMCommand.java
Add at imports:
PHP Code:
import static net.sf.odinms.client.messages.CommandProcessor.getOptionalIntArg;
Add anywhere:
PHP Code:
} else if (splitted[0].equalsIgnoreCase("!spawnmob")) {
MapleMonsterStats newStats = new MapleMonsterStats();
int mobid = Integer.parseInt(splitted[1]);
int HP = Integer.parseInt(splitted[2]);
int EXP = Integer.parseInt(splitted[3]);
int amount = Math.min(getOptionalIntArg(splitted, 4, 1), 100);
if (HP != 0) {
newStats.setHp(HP);
}
if (EXP != 0) {
newStats.setExp(EXP);
}
if (amount == 1){
MapleMonster npcmob = MapleLifeFactory.getMonster(mobid);
npcmob.setOverrideStats(newStats);
npcmob.setHp(HP);
npcmob.setMp(npcmob.getMaxMp());
player.getMap().spawnMonsterOnGroundBelow(npcmob, player.getPosition());
} else {
for (int i = 0; i < amount; i++) {
MapleMonster npcmob = MapleLifeFactory.getMonster(mobid);
npcmob.setOverrideStats(newStats);
npcmob.setHp(HP);
npcmob.setMp(npcmob.getMaxMp());
player.getMap().spawnMonsterOnGroundBelow(npcmob, player.getPosition());
}
}
CommandProcessor.java
Add anywhere:
PHP Code:
public static int getOptionalIntArg(String splitted[], int position, int def) {
if (splitted.length > position) {
try {
return Integer.parseInt(splitted[position]);
} catch (NumberFormatException nfe) {
return def;
}
}
return def;
}
Compile and you're done!
Re: Couple of Commands[Updates : 5]
Quote:
Originally Posted by
AxedMS
Code:
} else if (splitted[0].equalsIgnoreCase("!spawnmob")) {
MapleMonsterStats newStats = new MapleMonsterStats();
int mobid = Integer.parseInt(splitted[1]);
int HP = Integer.parseInt(splitted[2]);
int EXP = Integer.parseInt(splitted[3]);
int amount = Math.min(getOptionalIntArg(splitted, 4, 1), 100);
if (HP != 0) {
newStats.setHp(HP);
}
if (EXP != 0) {
newStats.setExp(EXP);
}
if (amount == 1){
MapleMonster npcmob = MapleLifeFactory.getMonster(mobid);
npcmob.setOverrideStats(newStats);
npcmob.setHp(HP);
npcmob.setMp(npcmob.getMaxMp());
player.getMap().spawnMonsterOnGroundBelow(npcmob, player.getPosition());
} else {
for (int i = 0; i < amount; i++) {
MapleMonster npcmob = MapleLifeFactory.getMonster(mobid);
npcmob.setOverrideStats(newStats);
npcmob.setHp(HP);
npcmob.setMp(npcmob.getMaxMp());
player.getMap().spawnMonsterOnGroundBelow(npcmob, player.getPosition());
}
}
fixed :D
Ty, works! :thumbup:
Re: Couple of Commands[Updates : 5]
Quote:
Originally Posted by
wietse02
Ty, works! :thumbup:
yw ^^
-too short-
Re: Couple of Commands[Updates : 5]
Quote:
Originally Posted by
flav
Wouldn't this also work for
!warpthismap? :w00t:
Code:
if (splitted[0].equalsIgnoreCase("!warpthismap")) {
for (MapleCharacter chr : player.getMap().getCharacters())
chr.changeMap(Integer.parseInt(splitted[1]));
}
Yea it would
I didnt know theres getCharacters in MapleMap :O:
Re: Couple of Commands[Updates : 5]
Nice commands, going to use some ._.
Re: Couple of Commands[Updates : 5]
Lol. cheers again to your nice release.
Re: Couple of Commands[Updates : 5]
nice u keep updating keep it up
Re: Couple of Commands[Updates : 5]
Code:
} else if (splitted[0].equalsIgnoreCase("!silver")) {
for (int amnt = getOptionalIntArg(splitted, 5, 5); amnt > 0; amnt--) {
player.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(9400203), player.getPosition());
}
Funnier one to confuse players (Not tested)
Code:
} else if (splitted[0].equalsIgnoreCase("!silver1")) {
for (int amnt = getOptionalIntArg(splitted, 5, 5); amnt > 0; amnt--) {
player.getMap().spawnMonsterOnGroudAbove(MapleLifeFactory.getMonster(9400203)
}
Add this near the bottom underneath
Code:
New CommandDefinition("nxslimes", 3),
Code:
new CommandDefinition("silver", 3),
new CommandDefinition("silver1", 3),
If anyone want's it lol it spawns 5 silver slimes for events ^^;
But, can you also make a command that gives a virety of buffs to the entire map? Like, Haste, Bless, Holy symble, Hyperbody, Sharp eyes, etc ^^
Re: Couple of Commands[Updates : 5]
Xerixe, Will this be added in CardellsStory?
Re: Couple of Commands[Updates : 5]
nice release, but i have a problem for !pmob
Code:
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:124: unreported exception java.sql.SQLException; must be caught or declared to be thrown
PreparedStatement ps = con.prepareStatement("INSERT INTO spawns ( idd, f, fh, cy, rx0, rx1, type, x, y, mid, mobtime ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:125: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(1, npcId);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:126: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(2, 0);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:127: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(3, c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition()).getId());
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:128: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(4, c.getPlayer().getPosition().y);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:129: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(5, c.getPlayer().getPosition().x + 50);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:130: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(6, c.getPlayer().getPosition().x - 50);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:131: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setString(7, "m");
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:132: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(8, c.getPlayer().getPosition().x);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:133: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(9, c.getPlayer().getPosition().y);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:134: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(10, c.getPlayer().getMapId());
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:135: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(11, mobTime);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:136: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.executeUpdate();
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:137: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.close();
14 errors
BUILD FAILED (total time: 0 seconds)
Re: Couple of Commands[Updates : 5]
Re: Couple of Commands[Updates : 5]
Quote:
Originally Posted by
slayer991133
nice release, but i have a problem for !pmob
Code:
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:124: unreported exception java.sql.SQLException; must be caught or declared to be thrown
PreparedStatement ps = con.prepareStatement("INSERT INTO spawns ( idd, f, fh, cy, rx0, rx1, type, x, y, mid, mobtime ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:125: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(1, npcId);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:126: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(2, 0);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:127: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(3, c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition()).getId());
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:128: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(4, c.getPlayer().getPosition().y);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:129: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(5, c.getPlayer().getPosition().x + 50);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:130: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(6, c.getPlayer().getPosition().x - 50);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:131: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setString(7, "m");
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:132: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(8, c.getPlayer().getPosition().x);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:133: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(9, c.getPlayer().getPosition().y);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:134: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(10, c.getPlayer().getMapId());
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:135: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.setInt(11, mobTime);
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:136: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.executeUpdate();
C:\Users\AppleSauce\Desktop\ThePackII\ThePackII\src\net\sf\odinms\client\messages\AdminCommand.java:137: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ps.close();
14 errors
BUILD FAILED (total time: 0 seconds)
From what I can tell, you put it in the wrong spot. Make sure you put it in the correct place.
Re: Couple of Commands[Updates : 5]
Here's my !online command, merged !connected with !online.
Use : !online OR !online CHANNEL
Code:
if (command.equalsIgnoreCase("!online")) {
if (splitted.length < 2) {
int online = 0;
Map<Integer, Integer> connected = cserv.getWorldInterface().getConnected();
for (int i : connected.keySet()) {
if (i != 0) {
online += connected.get(i);
if (connected.get(i) == 1)
player.dropMessage("1 player is online in channel " + i + ".");
else
player.dropMessage(connected.get(i) + " players are online in channel " + i + ".");
}
}
if (online == 1)
player.dropMessage("1 player is online in total.");
else
player.dropMessage(online + " players are online in total.");
} else {
int channelId = Integer.parseInt(splitted[1]);
int online = 0;
String players = "";
int i = 1;
for (MapleCharacter chr : ChannelServer.getInstance(channelId).getPlayerStorage().getAllCharacters()) {
online++;
if (i != ChannelServer.getInstance(channelId).getPlayerStorage().getAllCharacters().size()) {
players += chr.getName() + ", ";
i++;
} else {
players += chr.getName();
}
}
if (online == 0)
player.dropMessage("No players are in channel " + channelId + ".");
else if (online == 1)
player.dropMessage("This player is in channel " + channelId + " : " + players);
else
player.dropMessage("These players are in channel " + channelId + " : " + players);
}
}
Bad coded... :D:
Re: Couple of Commands[Updates : 5]
Quote:
Originally Posted by
Gmanpopinjay
i would add !pmob <mob> but im not sure it would lag cause more stress on the mysql :( but then again never tried it :P
It doesn't it just adds the NPC perm in the map and adds it to the Db as well.
Re: Couple of Commands[Updates : 5]
Do u compile this with netbeans and where do u put the
PHP Code:
} else if (splitted[0].equals("!pmob")) {
int npcId = Integer.parseInt(splitted[1]);
int mobTime = Integer.parseInt(splitted[2]);
MapleMonster mob = MapleLifeFactory.getMonster(npcId);
if (mob != null && !mob.getName().equals("MISSINGNO")) {
mob.setPosition(c.getPlayer().getPosition());
mob.setCy(c.getPlayer().getPosition().y);
mob.setRx0(c.getPlayer().getPosition().x + 50);
mob.setRx1(c.getPlayer().getPosition().x - 50);
mob.setFh(c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition()).getId());
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO spawns ( idd, f, fh, cy, rx0, rx1, type, x, y, mid, mobtime ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
ps.setInt(1, npcId);
ps.setInt(2, 0);
ps.setInt(3, c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition()).getId());
ps.setInt(4, c.getPlayer().getPosition().y);
ps.setInt(5, c.getPlayer().getPosition().x + 50);
ps.setInt(6, c.getPlayer().getPosition().x - 50);
ps.setString(7, "m");
ps.setInt(8, c.getPlayer().getPosition().x);
ps.setInt(9, c.getPlayer().getPosition().y);
ps.setInt(10, c.getPlayer().getMapId());
ps.setInt(11, mobTime);
ps.executeUpdate();
ps.close();
c.getPlayer().getMap().addMonsterSpawn(mob, mobTime);
} else {
mc.dropMessage("You have entered an invalid Npc-Id");
}