- Joined
- Aug 16, 2010
- Messages
- 346
- Reaction score
- 111
This has got to be my simplest release yet. It's a single, easy-to-add, user-friendly command for all your True/False events on the OX Map.
Features:
- Fully automatic. Upon using the command, the question will be asked, and after the time is up, the losers will detected and kicked
- Intelligent. Will not kick players if there are no winners for that round.
- Interactive. Has "START", "WIN", "LOSE" and "TIMEOUT" animations and music playing, as well as a timer
- Easy to add to servers
Add this command to your source:
To use the command, say !AskOX <True/False> <Time> <Question>.
- True/False = Is the answer True or False?
- Time = The time limit for the question (A time between 1 to 60 seconds)
- Question = The true/false question asked
So let's say I want to ask the question: "Is water made out of H2O?" with a time limit of 10 seconds, the command I would use is: "!AskOX true 5 Is water made out of H2O?
Have fun.
Features:
- Fully automatic. Upon using the command, the question will be asked, and after the time is up, the losers will detected and kicked
- Intelligent. Will not kick players if there are no winners for that round.
- Interactive. Has "START", "WIN", "LOSE" and "TIMEOUT" animations and music playing, as well as a timer
- Easy to add to servers
Add this command to your source:
Code:
public static class AskOX extends CommandExecute {
@Override
public int execute(MapleClient c, String[] splitted) {
if (c.getPlayer().getMapId() != 109020001) {
c.getPlayer().changeMap(109020001, 0);
c.getPlayer().dropMessage(6, "Warp other players to this map to begin the event");
return 0;
}
final MapleCharacter asker = c.getPlayer();
final MapleMap thisMap = asker.getMap();
String[] trueCmd = {"true", "t", "left", "l", "o"};
String[] falseCmd = {"false", "f", "right", "r", "x"};
boolean tempAns;
if (Arrays.asList(trueCmd).contains(splitted[1].toLowerCase())) {
tempAns = true;
} else if (Arrays.asList(falseCmd).contains(splitted[1].toLowerCase())) {
tempAns = false;
} else {
c.getPlayer().dropMessage(6, "Syntax: !AskOX <True/False> <Time> <Question>");
return 1;
}
final boolean ans = tempAns;
final int timeLimit = Math.min(Math.max(Integer.parseInt(splitted[2]), 1), 60);
final String question = StringUtil.joinStringFrom(splitted, 3);
thisMap.broadcastMessage(CField.MapEff("SportsDay/EndMessage/Start"));
thisMap.broadcastMessage(CField.playSound("Dojang/start"));
Timer.MapTimer.getInstance().schedule(new Runnable() {
@Override
public void run() {
thisMap.broadcastMessage(CWvsContext.serverNotice(0, question));
thisMap.broadcastMessage(CField.getClock(timeLimit));
Timer.MapTimer.getInstance().schedule(new Runnable() {
@Override
public void run() {
List<MapleCharacter> winners = new ArrayList<MapleCharacter>();
for (final MapleCharacter victim : thisMap.getCharacters()) {
if (victim == asker) {
continue;
}
if ((victim.getPosition().x > -308 && victim.getPosition().x < -142) || victim.getPosition().y <= -206) {
// NO ANSWER
victim.getClient().getSession().write(CField.MapEff("SportsDay/EndMessage/TimeOver"));
victim.getClient().getSession().write(CField.playSound("phantom/skaia"));
} else if (victim.getPosition().x > -308 ^ ans) {
// CORRECT ANSWER
winners.add(victim);
victim.getClient().getSession().write(CField.MapEff("SportsDay/EndMessage/Win"));
victim.getClient().getSession().write(CField.playSound("Party1/Clear"));
} else {
// WRONG ANSWER
victim.getClient().getSession().write(CField.MapEff("SportsDay/EndMessage/Lose"));
victim.getClient().getSession().write(CField.playSound("Party1/Failed"));
}
}
if (winners.size() > 0) {
for (final MapleCharacter victim : thisMap.getCharacters()) {
if (victim != asker && !winners.contains(victim)) {
// WARP OUT IN 5 SEC
Timer.MapTimer.getInstance().schedule(new Runnable() {
@Override
public void run() {
victim.changeMap(100000000, 0);
}
}, 5000);
}
}
} else {
thisMap.broadcastMessage(CWvsContext.serverNotice(6, "Since there are no winners for this round, all participants will proceed on to the next round"));
}
}
}, timeLimit * 1000);
}
}, 2000);
return 1;
}
}
To use the command, say !AskOX <True/False> <Time> <Question>.
- True/False = Is the answer True or False?
- Time = The time limit for the question (A time between 1 to 60 seconds)
- Question = The true/false question asked
So let's say I want to ask the question: "Is water made out of H2O?" with a time limit of 10 seconds, the command I would use is: "!AskOX true 5 Is water made out of H2O?
Have fun.

