@@ -19,7 +19,16 @@ public static bool Prefix(ChatController __instance, [HarmonyArgument(0)] Player
1919 // After entering the command, when you try to join the lobby it will show "X/15". Only after the game is over will there be a larger lobby.
2020 if ( chatText . StartsWith ( "!limit " ) )
2121 {
22- if ( GameData . Instance . GetHost ( ) == sourcePlayer . Data )
22+ if ( ( AmongUsClient . Instance . GameState == InnerNet . InnerNetClient . GameStates . Started || AmongUsClient . Instance . NetworkMode == NetworkModes . FreePlay ) && sourcePlayer . PlayerId == PlayerControl . LocalPlayer . PlayerId )
23+ {
24+ if ( sourcePlayer . PlayerId == PlayerControl . LocalPlayer . PlayerId )
25+ {
26+ chatText = "You cannot use this command during the game!" ;
27+ error = true ;
28+ }
29+ return sourcePlayer . PlayerId == PlayerControl . LocalPlayer . PlayerId ;
30+ }
31+ if ( GameData . Instance . GetHost ( ) == sourcePlayer . Data && sourcePlayer . PlayerId == PlayerControl . LocalPlayer . PlayerId )
2332 {
2433 string [ ] args = chatText . Split ( ' ' ) ;
2534 if ( args . Length > 1 && int . TryParse ( args [ 1 ] , out int newLimit ) )
@@ -31,41 +40,37 @@ public static bool Prefix(ChatController __instance, [HarmonyArgument(0)] Player
3140 GameOptionsManager . Instance . CurrentGameOptions . SetInt ( Int32OptionNames . MaxPlayers , newLimit ) ;
3241 if ( sourcePlayer . PlayerId == PlayerControl . LocalPlayer . PlayerId )
3342 {
43+ chatText = $ "Player limit has been set for: <color=#D91919FF><b>{ newLimit } </b></color>";
3444 system = true ;
35- HudManager . Instance . Chat . AddChat ( PlayerControl . LocalPlayer , $ "A player limit has been set for: <color=#D91919FF>{ newLimit } </color>") ;
3645 }
37- return false ;
3846 }
3947 catch { }
4048 }
4149 else
4250 {
4351 if ( sourcePlayer . PlayerId == PlayerControl . LocalPlayer . PlayerId )
4452 {
53+ chatText = "The !limit command has a range of 4 - 35!" ;
4554 error = true ;
46- HudManager . Instance . Chat . AddChat ( PlayerControl . LocalPlayer , "The limit must be between 4 and 35." ) ;
4755 }
48- return false ;
4956 }
5057 }
5158 else
5259 {
5360 if ( sourcePlayer . PlayerId == PlayerControl . LocalPlayer . PlayerId )
5461 {
62+ chatText = "Use !limit [number]. Example: !limit 20" ;
5563 error = true ;
56- HudManager . Instance . Chat . AddChat ( PlayerControl . LocalPlayer , "Use !limit [number]. Example: !limit 20" ) ;
5764 }
58- return false ;
5965 }
6066 }
6167 else if ( sourcePlayer . PlayerId == PlayerControl . LocalPlayer . PlayerId )
6268 {
6369 if ( sourcePlayer . PlayerId == PlayerControl . LocalPlayer . PlayerId )
6470 {
6571 noaccess = true ;
66- HudManager . Instance . Chat . AddChat ( PlayerControl . LocalPlayer , "You don't have access to this command!" ) ;
72+ chatText = "You don't have access to this command!" ;
6773 }
68- return false ;
6974 }
7075 return sourcePlayer . PlayerId == PlayerControl . LocalPlayer . PlayerId ;
7176 }
0 commit comments