|
38 | 38 | "ooc_cmd_format_timer", |
39 | 39 | "ooc_cmd_timer_interval", |
40 | 40 | "ooc_cmd_ooc_actions", |
| 41 | + "ooc_cmd_sfx", |
41 | 42 | ] |
42 | 43 |
|
43 | 44 |
|
@@ -1124,3 +1125,49 @@ def ooc_cmd_ooc_actions(client, arg): |
1124 | 1125 | if client.ooc_actions: |
1125 | 1126 | stat = "now see" |
1126 | 1127 | client.send_ooc(f"You will {stat} actions in OOC.") |
| 1128 | + |
| 1129 | + |
| 1130 | +def ooc_cmd_sfx(client, arg): |
| 1131 | + """ |
| 1132 | + Play a sound effect directly without associating it with an emote. |
| 1133 | + Usage: /sfx [sound_path] |
| 1134 | + """ |
| 1135 | + if arg == "": |
| 1136 | + raise ArgumentError( |
| 1137 | + "sound_path can't be empty. Usage: /sfx [sound_path]" |
| 1138 | + ) |
| 1139 | + is_mod = client.is_mod or client in client.area.owners |
| 1140 | + # Only incur cooldowns etc. on mods. |
| 1141 | + if not is_mod: |
| 1142 | + if client.char_id <= -1 or client.char_id == None: |
| 1143 | + raise ClientError( |
| 1144 | + "You can't play sfx when you're a spectator and not a CM/GM!" |
| 1145 | + ) |
| 1146 | + if not client.can_sfx(): |
| 1147 | + raise ClientError( |
| 1148 | + "You need to wait before playing sfx again!" |
| 1149 | + ) |
| 1150 | + target_areas = [client.area] |
| 1151 | + if len(client.broadcast_list) > 0 and is_mod: |
| 1152 | + try: |
| 1153 | + a_list = ", ".join([str(a.id) |
| 1154 | + for a in client.broadcast_list]) |
| 1155 | + client.send_ooc(f"Broadcasting to areas {a_list}") |
| 1156 | + target_areas = client.broadcast_list |
| 1157 | + except: |
| 1158 | + client.send_ooc( |
| 1159 | + "Your broadcast list is invalid! Do /clear_broadcast to reset it and /broadcast <id(s)> to set a new one." |
| 1160 | + ) |
| 1161 | + return |
| 1162 | + for area in target_areas: |
| 1163 | + # Plays on unused music layer 3 (max channel) |
| 1164 | + area.send_command("MC", f"../general/{arg}", -1, "", 0, 3, 0) |
| 1165 | + area.broadcast_ooc(f"[{client.id}] {client.showname} has played sfx '{arg}'.") |
| 1166 | + for a in area.broadcast_list: |
| 1167 | + # Plays on unused music layer 3 (max channel) |
| 1168 | + a.send_command("MC", f"../general/{arg}", -1, "", 0, 3, 0) |
| 1169 | + a.broadcast_ooc(f"[{client.id}] {client.showname} has played sfx '{arg}'.") |
| 1170 | + client.set_sfx_delay() |
| 1171 | + database.log_area( |
| 1172 | + "sfx", client, client.area, message=f"has played sfx {arg}" |
| 1173 | + ) |
0 commit comments