File tree Expand file tree Collapse file tree 5 files changed +19
-6
lines changed
Expand file tree Collapse file tree 5 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,6 @@ namespace CustomCommands.Interfaces;
77public interface IPluginUtilities
88{
99 string [ ] SplitStringByCommaOrSemicolon ( string str ) ;
10- void ExecuteServerCommands ( Commands cmd ) ;
10+ void ExecuteServerCommands ( Commands cmd , CCSPlayerController player ) ;
1111 bool RequiresPermissions ( CCSPlayerController player , Permission permissions ) ;
1212}
Original file line number Diff line number Diff line change @@ -10,10 +10,12 @@ namespace CustomCommands.Services;
1010public class PluginUtilities : IPluginUtilities
1111{
1212 private readonly IPluginGlobals PluginGlobals ;
13+ private readonly IReplaceTagsFunctions ReplaceTagsFunctions ;
1314
14- public PluginUtilities ( IPluginGlobals PluginGlobals )
15+ public PluginUtilities ( IPluginGlobals PluginGlobals , IReplaceTagsFunctions ReplaceTagsFunctions )
1516 {
1617 this . PluginGlobals = PluginGlobals ;
18+ this . ReplaceTagsFunctions = ReplaceTagsFunctions ;
1719 }
1820
1921 public string [ ] SplitStringByCommaOrSemicolon ( string str )
@@ -23,13 +25,13 @@ public string[] SplitStringByCommaOrSemicolon(string str)
2325 . ToArray ( ) ;
2426 }
2527
26- public void ExecuteServerCommands ( Commands cmd )
28+ public void ExecuteServerCommands ( Commands cmd , CCSPlayerController player )
2729 {
2830 if ( cmd . ServerCommands . Count == 0 ) return ;
2931
3032 foreach ( var serverCommand in cmd . ServerCommands )
3133 {
32- Server . ExecuteCommand ( serverCommand ) ;
34+ Server . ExecuteCommand ( ReplaceTagsFunctions . ReplaceMessageTags ( serverCommand , player ) ) ;
3335 }
3436 }
3537 public bool RequiresPermissions ( CCSPlayerController player , Permission permissions )
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ public void AddCommands(Commands com)
4141
4242 MessageManager . SendMessage ( player , com ) ;
4343
44- PluginUtilities . ExecuteServerCommands ( com ) ;
44+ PluginUtilities . ExecuteServerCommands ( com , player ) ;
4545 } ) ;
4646 }
4747 }
Original file line number Diff line number Diff line change @@ -64,14 +64,15 @@ public string ReplaceLanguageTags(string input)
6464 public string ReplaceMessageTags ( string input , CCSPlayerController player )
6565 {
6666 SteamID steamId = new SteamID ( player . SteamID ) ;
67-
67+
6868 Dictionary < string , string > replacements = new ( )
6969 {
7070 { "{PREFIX}" , PluginGlobals . Config . Prefix ?? "<PREFIX not found>" } ,
7171 { "{MAP}" , NativeAPI . GetMapName ( ) ?? "<MAP not found>" } ,
7272 { "{TIME}" , DateTime . Now . ToString ( "HH:mm:ss" ) ?? "<TIME not found>" } ,
7373 { "{DATE}" , DateTime . Now . ToString ( "dd.MM.yyyy" ) ?? "<DATE not found>" } ,
7474 { "{PLAYERNAME}" , player . PlayerName ?? "<PLAYERNAME not found>" } ,
75+ { "{USERID}" , player . UserId . ToString ( ) ?? "<USERID not found>" } ,
7576 { "{STEAMID2}" , steamId . SteamId2 ?? "<STEAMID2 not found>" } ,
7677 { "{STEAMID3}" , steamId . SteamId3 ?? "<STEAMID3 not found>" } ,
7778 { "{STEAMID32}" , steamId . SteamId32 . ToString ( ) ?? "<STEAMID32 not found>" } ,
Original file line number Diff line number Diff line change 4040 " @customcommands/surf"
4141 ]
4242 }
43+ },
44+ {
45+ "Title" : " Kickme" ,
46+ "Description" : " command that kicks yourself" ,
47+ "Command" : " kickme" ,
48+ "Message" : " Getting Kicket" ,
49+ "PrintTo" : 0 ,
50+ "ServerCommands" : [
51+ " kick {PLAYERNAME}" // Tags work for commands as well
52+ ]
4353 }
4454]
You can’t perform that action at this time.
0 commit comments