Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
object_template_crc_string_table.tab
**/.idea/*
*.iml
/out/*
36 changes: 36 additions & 0 deletions sku.0/sys.server/compiled/game/script/gm/cmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -4439,6 +4439,38 @@ else if (command.equalsIgnoreCase("setWeather")) {
return SCRIPT_CONTINUE;
}

else if (command.equalsIgnoreCase("setCount")) {

int count;
if(st.hasMoreTokens()) {
count = utils.stringToInt(st.nextToken());
} else {
sendSystemMessageTestingOnly(self, "Syntax: /admin setCount <integer> ");
return SCRIPT_CONTINUE;
}
if (count > 500) {
count = 500;
}
setCount(target, count);
sendConsoleMessage(self, "You have added " + count + " to " + target + " (" + getName(target) + ")");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why these are console messages when standard pattern is system messages for admin command results. Not a big deal but curious deviation.

return SCRIPT_CONTINUE;
}

else if (command.equalsIgnoreCase("messageTo")){
String message;
float messageDelay;
if(st.hasMoreTokens()) {
message = st.nextToken();
messageDelay = utils.stringToFloat(st.nextToken());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With StringTokenizer you need to check hasMoreTokens() for each parameter. This currently has the potential to throw a null pointer exception because you’re calling nextToken() twice without knowing there are actually 2 more tokens (vs just 1 for the message param).

As an aside, these command scripts could really be cleaned up with a helper method and class used to validate params and return syntax because it’s so messy the way we currently do it over and over. A todo for another time.

} else {
sendSystemMessageTestingOnly(self, "Syntax: /admin messageTo <messageHandler> <timeToDelay (float)> ");
return SCRIPT_CONTINUE;
}
messageTo(target, message, null, messageDelay, true);
sendConsoleMessage(self, "Message " + message + " sent to " + target + " (" + getName(target) + ") with a delay of " + messageDelay + " seconds.");
return SCRIPT_CONTINUE;
}

else {
showAdminCmdSyntax(self);
}
Expand All @@ -4457,6 +4489,10 @@ private static void showAdminCmdSyntax(obj_id self) throws InterruptedException
sendConsoleMessage(self, "returns the account username of the specified player");
sendConsoleMessage(self, "\\#00ffff setWeather \\#bfff00 <clear | mild | heavy | severe> \\#.");
sendConsoleMessage(self, "sets the weather for the current scene");
sendConsoleMessage(self, "\\#00ffff setCount \\#bfff00 <integer> \\#.");
sendConsoleMessage(self, "sets the amount of a stackable item.");
sendConsoleMessage(self, "\\#00ffff sendMessageTo \\#bfff00 <messageHandler> <time as float> \\#.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command is just “messageTo” but here it’s listed as “sendMessageTo”

sendConsoleMessage(self, "sends a messageTo the specified handler with no params and a specified delay.");
sendConsoleMessage(self, "\\#ffff00 ============ ============ ============ ============ \\#.");
}

Expand Down