#script_wse_console_command_received
# Called each time a command is typed on the dedicated server console (after parsing standard commands)
# INPUT
# s0 = text
# OUTPUT
# trigger result = anything non-zero if the command succeeded
# result string = message to display on success (if empty, default message will be used)
("wse_console_command_received", [
(str_split, ":num_tokens", s30, s0, "@ ", 1),
(ge, ":num_tokens", 1),
(assign, ":fail", 0),
(try_begin),
(str_store_string, s0, "@set_max_players_real"),
(str_store_replace_spaces_with_underscores, s0, s0), #Workaround for Warband' annoying habit of replacing all underscores with spaces (seriously, was underscore the less common character they could come up with?)
(str_starts_with, s30, s0),
(try_begin),
(ge, ":num_tokens", 3),
(str_to_num, ":max_players", s31),
(str_to_num, ":max_private_players", s32),
(is_between, ":max_players", 2, 251),
(is_between, ":max_private_players", 2, 251),
(le, ":max_players", ":max_private_players"),
(server_set_max_num_players, ":max_players", ":max_private_players"),
(assign, reg0, ":max_players"),
(assign, reg1, ":max_private_players"),
(set_result_string, "@Set maximum players to {reg0} and maximum private players to {reg1}"),
(else_try),
(set_result_string, "@Usage: set_max_players_real <max_players> (2-250) <max_private_players> (2-250)"),
(try_end),
(else_try),
(assign, ":fail", 1),
(try_end),
(eq, ":fail", 0),
(set_trigger_result, 1),
]),