Skip to content

Commit

Permalink
implement command localization
Browse files Browse the repository at this point in the history
  • Loading branch information
destoer committed Jan 22, 2024
1 parent 84a4d54 commit 37e4433
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 25 deletions.
32 changes: 31 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@
"warden.gun_menu_disabled": "Gun menu is disabled!",
"warden.no_warden": "Their is no warden",
"warden.time": "Warden has been active for {0} minutes",
"warden.fire_guard" : "Firing guards",

"warden.take_warden_cmd": "w",
"warden.leave_warden_cmd": "uw",
"warden.remove_warden_cmd": "rw",
"warden.fire_guard_cmd": "fire_guard",
"warden.remove_marker_cmd": "remove_marker",
"warden.marker_colour_cmd": "marker_colour",
"warden.laser_colour_cmd": "laser_colour",
"warden.gun_cmd": "guns",
"warden.time_cmd": "wtime",
"warden.list_cmd": "wcommands",
"warden.warday_cmd": "wd",
"warden.swap_guard_cmd": "swap_guard",
"warden.no_block_cmd": "wub",
"warden.block_cmd": "wb",
"warden.force_open_cmd": "force_open",
"warden.force_close_cmd": "force_close",
"warden.sd_cmd": "wsd",
"warden.sd_ff_cmd": "wsd_ff",


"mute.thirty": "All t's are muted for the first 30 seconds",
"mute.speak_quietly": "T's may now speak quietly",
Expand Down Expand Up @@ -67,6 +88,11 @@
"sd.tank_start": "Tank day started",
"sd.tank_end": "Tank day ended",
"sd.tank": "{0} is the tank!",

"sd.start_cmd": "sd",
"sd.start_ff_cmd": "sd_ff",
"sd.cancel_cmd": "sd_cancel",


"lr.rebel_last": "You must be the last player alive to rebel",
"lr.riot_start": "A riot has started! CT's have 15 seconds to hide",
Expand All @@ -80,5 +106,9 @@
"lr.player_rebel": "{0} is a rebel!",
"lr.knife_rebel": "{0} is knife a rebel!",
"lr.ready": "Last request is available! Type !lr",
"lr.wait": "Please wait 15 seconds into the round before starting an lr"
"lr.wait": "Please wait 15 seconds into the round before starting an lr",

"lr.cancel_lr_cmd": "cancel_lr",
"lr.start_lr_cmd": "lr",
"lr.stats_cmd": "lr_stats"
}
53 changes: 30 additions & 23 deletions src/Jail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,43 +261,50 @@ void register_listener()
});
}

void add_localized_cmd(String base_name,String desc,CommandInfo.CommandCallback callback)
{
AddCommand("css_" + Localizer[base_name],desc,callback);
}

void register_commands()
{
// reg warden comamnds
AddCommand("w", "take warden", warden.take_warden_cmd);
AddCommand("uw", "leave warden", warden.leave_warden_cmd);
AddCommand("rw", "remove warden", warden.remove_warden_cmd);
AddCommand("clear_marker", "remove warden marker",warden.remove_marker_cmd);
add_localized_cmd("warden.take_warden_cmd", "take warden", warden.take_warden_cmd);
add_localized_cmd("warden.leave_warden_cmd", "leave warden", warden.leave_warden_cmd);
add_localized_cmd("warden.remove_warden_cmd", "remove warden", warden.remove_warden_cmd);
add_localized_cmd("warden.remove_marker_cmd","remove warden marker",warden.remove_marker_cmd);

add_localized_cmd("warden.marker_colour_cmd", "set marker colour", warden.marker_colour_cmd);
add_localized_cmd("warden.laser_colour_cmd", "set laser colour", warden.laser_colour_cmd);

AddCommand("marker_colour", "set laser colour", warden.marker_colour_cmd);
AddCommand("laser_colour", "set laser colour", warden.laser_colour_cmd);
add_localized_cmd("warden.no_block_cmd","warden : disable block",warden.wub_cmd);
add_localized_cmd("warden.block_cmd","warden : enable block",warden.wb_cmd);

AddCommand("wub","warden : disable block",warden.wub_cmd);
AddCommand("wb","warden : enable block",warden.wb_cmd);
add_localized_cmd("warden.sd_cmd","warden : call a special day",sd.warden_sd_cmd);
add_localized_cmd("warden.sd_ff_cmd","warden : call a friendly fire special day",sd.warden_sd_ff_cmd);

AddCommand("wsd","warden : call a special day",sd.warden_sd_cmd);
AddCommand("wsd_ff","warden : call a friendly fire special day",sd.warden_sd_ff_cmd);
add_localized_cmd("warden.swap_guard","admin : move a player to ct",warden.swap_guard_cmd);

AddCommand("swap_guard","admin : move a player to ct",warden.swap_guard_cmd);
add_localized_cmd("warden.warday_cmd","warden : start warday",warden.warday_cmd);
add_localized_cmd("warden.list_cmd", "warden : show all commands",warden.cmd_info);
add_localized_cmd("warden.time_cmd","how long as warden been active?",warden.warden_time_cmd);

AddCommand("wd","warden : start warday",warden.warday_cmd);
AddCommand("wcommands", "warden : show all commands",warden.cmd_info);
AddCommand("wtime","how long as warden been active?",warden.warden_time_cmd);
add_localized_cmd("warden.gun_cmd","give ct guns",warden.cmd_ct_guns);

AddCommand("guns","give ct guns",warden.cmd_ct_guns);
add_localized_cmd("warden.force_open_cmd","force open every door and vent",warden.force_open_cmd);
add_localized_cmd("warden.force_close_cmd","force close every door",warden.force_close_cmd);

AddCommand("force_open","force open every door and vent",warden.force_open_cmd);
AddCommand("force_close","force close every door",warden.force_close_cmd);
add_localized_cmd("warden.fire_guard_cmd","admin : Remove all guards apart from warden",warden.fire_guard_cmd);

// reg lr commands
AddCommand("lr","start an lr",lr.lr_cmd);
AddCommand("cancel_lr","admin : cancel lr",lr.cancel_lr_cmd);
AddCommand("lr_stats","list lr stats",jail_stats.lr_stats_cmd);
add_localized_cmd("lr.start_lr_cmd","start an lr",lr.lr_cmd);
add_localized_cmd("lr.cancel_lr_cmd","admin : cancel lr",lr.cancel_lr_cmd);
add_localized_cmd("lr.stats_cmd","list lr stats",jail_stats.lr_stats_cmd);

// reg sd commands
AddCommand("sd","start a sd",sd.sd_cmd);
AddCommand("sd_ff","start a ff sd",sd.sd_ff_cmd);
AddCommand("cancel_sd","cancel an sd",sd.cancel_sd_cmd);
add_localized_cmd("sd.start_cmd","start a sd",sd.sd_cmd);
add_localized_cmd("sd.start_ff_cmd","start a ff sd",sd.sd_ff_cmd);
add_localized_cmd("sd.cancel_cmd","cancel an sd",sd.cancel_sd_cmd);

AddCommandListener("jointeam",join_team);

Expand Down
8 changes: 7 additions & 1 deletion src/Warden/JailPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ public void reset()

public void set_rebel(CCSPlayerController? player)
{
// allready a rebel don't care
if(is_rebel)
{
return;
}

if(JailPlugin.event_active())
{
return;
Expand All @@ -260,7 +266,7 @@ public void set_rebel(CCSPlayerController? player)
{
if(config.colour_rebel)
{
Lib.announce(REBEL_PREFIX,$"{} is a rebel",player.PlayerName);
Lib.announce(REBEL_PREFIX,$"{player.PlayerName} is a rebel");
player.set_colour(Lib.RED);
}
is_rebel = true;
Expand Down
16 changes: 16 additions & 0 deletions src/Warden/Warden.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,22 @@ public void warden_death()
remove_warden();
}

[RequiresPermissions("@css/generic")]
public void fire_guard_cmd(CCSPlayerController? invoke, CommandInfo command)
{
Lib.localise_announce(WARDEN_PREFIX,"warden.fire_guard");

// swap every guard apart from warden to T
List<CCSPlayerController> players = Utilities.GetPlayers();
var valid = players.FindAll(player => player.is_valid() && player.is_ct() && !is_warden(player));

foreach(var player in valid)
{
player.slay();
player.SwitchTeam(CsTeam.Terrorist);
}
}

public void death(CCSPlayerController? player, CCSPlayerController? killer)
{
// player is no longer on server
Expand Down

0 comments on commit 37e4433

Please sign in to comment.