Skip to content

Commit 1e80010

Browse files
committed
Updating Examples to markdown with more explanation
1 parent 23736c5 commit 1e80010

19 files changed

+254
-51
lines changed

CustomCommands/Interfaces/IPluginUtilities.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,51 @@ namespace CustomCommands.Interfaces;
55

66
public interface IPluginUtilities
77
{
8+
/// <summary>
9+
/// Splits the commands string into an array of strings.
10+
/// </summary>
11+
/// <param name="commands"></param>
12+
/// <returns></returns>
813
string[] GettingCommandsFromString(string commands);
14+
15+
/// <summary>
16+
/// Adds the css_ prefix to each alias.
17+
/// This will help cs# tell this command belongs to the framework.
18+
/// </summary>
19+
/// <param name="input"></param>
20+
/// <returns></returns>
921
string[] AddCSSTagsToAliases(string[] input);
22+
1023
/// <summary>
1124
/// Splits a string by comma, semicolon, or whitespace characters.
1225
/// </summary>
1326
/// <param name="str">The string to be split.</param>
1427
/// <returns>An array of strings containing the split substrings.</returns>
1528
string[] SplitStringByCommaOrSemicolon(string str);
29+
1630
/// <summary>
1731
/// Executes the server commands from the command object
1832
/// </summary>
1933
/// <param name="cmd"></param>
2034
/// <param name="player"></param>
2135
void ExecuteServerCommands(Commands cmd, CCSPlayerController player);
36+
2237
/// <summary>
2338
/// Issue the specified command to the specified client (mimics that client typing the command at the console).
2439
/// Note: Only works for some commands, marked with the FCVAR_CLIENT_CAN_EXECUTE flag (not many).
2540
/// </summary>
2641
/// <param name="cmd"></param>
2742
/// <param name="player"></param>
2843
void ExecuteClientCommands(Commands cmd, CCSPlayerController player);
44+
2945
/// <summary>
3046
/// Issue the specified command directly from the server (mimics the server executing the command with the given player context).
3147
/// <remarks>Works with server commands like `kill`, `explode`, `noclip`, etc. </remarks>
3248
/// </summary>
3349
/// <param name="cmd"></param>
3450
/// <param name="player"></param>
3551
void ExecuteClientCommandsFromServer(Commands cmd, CCSPlayerController player);
52+
3653
/// <summary>
3754
/// Checks if the player has the required permissions to execute the command
3855
/// </summary>

CustomCommands/Services/PluginUtilities.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ public string[] GettingCommandsFromString(string commands)
3333
return splitCommands;
3434
}
3535

36-
/// <summary>
37-
/// Adds the css_ prefix to each alias.
38-
/// This will help cs# tell this command belongs to the framework.
39-
/// </summary>
40-
/// <param name="input"></param>
41-
/// <returns></returns>
4236
public string[] AddCSSTagsToAliases(string[] input)
4337
{
4438
for (int i = 0; i < input.Length; i++)
@@ -49,11 +43,6 @@ public string[] AddCSSTagsToAliases(string[] input)
4943
return input;
5044
}
5145

52-
/// <summary>
53-
/// Splits a string by comma, semicolon, or whitespace characters.
54-
/// </summary>
55-
/// <param name="str">The string to be split.</param>
56-
/// <returns>An array of strings containing the split substrings.</returns>
5746
public string[] SplitStringByCommaOrSemicolon(string str)
5847
{
5948
return Regex.Split(str, ",|;|\\s")

CustomCommands/tests.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
* [ ] check if newline in language files works
88
* [ ] check if arguments still work
99
* [ ] check if argument message appears when not giving enough arguments
10+
* [ ] Test Client commands
11+
* [ ] Test ClientServer Commands
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
## Center Message with color:
2+
3+
It is possible to add HTML to the center Message that means its possible to add any color to it. Here are some examples.
4+
5+
6+
```json
17
[
28
{
39
"Title": "Center Message with color",
410
"Description": "Center Message with color",
511
"Command": "colorcenter",
612
"CenterMessage": {
7-
"Message": "<font color='#00ff00'>Cool color here</font>",
13+
"Message": "`<font color='#00ff00'>`Cool color here`</font>`",
814
"Time": 5 // Seconds
915
},
1016
"PrintTo": 2
@@ -15,9 +21,10 @@
1521
"Description": "With html",
1622
"Command": "htmlcenter",
1723
"CenterMessage": {
18-
"Message": "<div>Steam Group</div><br><div><font color='#00ff00'>https...</font></div>",
24+
"Message": "`<div>`Steam Group`</div><br>``<div><font color='#00ff00'>`https...`</font></div>`",
1925
"Time": 5 // Seconds
2026
},
2127
"PrintTo": 2
2228
}
23-
]
29+
]
30+
```

Examples/ClientCommands.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## Execute Client Commands
2+
3+
If you want to execute Commands for the client here are to different ways of doing it.
4+
5+
#### Execute Client Command:
6+
7+
This means you are simulating typing the command in the players console. Be aware this only works for commands that can be executed by the client.
8+
9+
Example:
10+
11+
```json
12+
[
13+
{
14+
"Title": "Open Buy menu",
15+
"Description": "Opens the buy menu for the player",
16+
"Command": "buy",
17+
"Message": "Opening buy Menu...",
18+
"PrintTo": 0,
19+
"ClientCommands": [
20+
"buymenu"
21+
]
22+
}
23+
]
24+
```
25+
26+
27+
#### Execute Client Command from Server:
28+
29+
Issue the specified command directly from the server (mimics the server executing the command with the given player context).
30+
31+
Works with server commands like `kill`, `explode`, `noclip`, etc.
32+
33+
Example:
34+
35+
```json
36+
[
37+
{
38+
"Title": "Noclip",
39+
"Description": "Noclips player",
40+
"Command": "noclip",
41+
"Message": "Noclip...",
42+
"PrintTo": 0,
43+
"ServerCommands": [
44+
"noclip"
45+
]
46+
}
47+
]
48+
```
49+
50+
51+
### Important!
52+
53+
Its always recommended to Permission to the command so not every player can use the command and execute commands on your server
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
## Colored Messages
2+
3+
If you want to add Color to your chat message you need to use the color tags.
4+
5+
Here are all color tags:
6+
7+
### Colorlist
8+
9+
![CS2Colors](../.github/img/ColorsCS2.png "CS2Colors")
10+
11+
### Note
12+
13+
If you want to add color to the Center Message check this out: [Color For CenterMessage](./CenterMessageWithColor.md)
14+
15+
```json
116
[
217
{
318
"Title": "Rainbow",
419
"Description": "rainbow command",
520
"Command": "rainbow",
6-
"Message": "{RED}R{ORANGE}A{YELLOW}I{GREEN}N{BLUE}B{DARKBLUE}O{PURPLE}W",
21+
"Message": "{RED}R{ORANGE}A{YELLOW}I{GREEN}N{BLUE}B{DARKBLUE}O{PURPLE}W",
722
"PrintTo": 0
823
},
924
{
@@ -13,4 +28,5 @@
1328
"Message": "{DEFAULT}1, {WHITE}2 \n{DARKRED}3, {RED}4, {LIGHTRED}5\n{GREEN}6, {LIME}7, {OLIVE}8\n{ORANGE}9, {GOLD}10, {YELLOW}11\n{BLUE}12, {DARKBLUE}13\n{LIGHTPURPLE}14 {PURPLE}15 \n,{GREY}18",
1429
"PrintTo": 0
1530
}
16-
]
31+
]
32+
```
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Command with Arguments
2+
3+
You can also create your own commands with arguments/numbers after it.
4+
5+
6+
```json
17
[
28
{
39
"Title": "Arguments 1",
@@ -13,4 +19,5 @@
1319
"Message": "Help me with 2 argument",
1420
"PrintTo": 0
1521
}
16-
]
22+
]
23+
```
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## Cooldown for commands
2+
3+
Here are two ways to add a cooldown for a command.
4+
5+
The simple command is just a cooldown for the current player who used the command
6+
7+
In the Advanced command example you can add a "IsGlobal" flag so the whole server has a cooldown for this command not just the Player who uses it
8+
9+
10+
```json
111
[
212
//Simple cooldown command
313
{
@@ -21,4 +31,5 @@
2131
"Message": "Cool cooldown message!",
2232
"PrintTo": 0
2333
}
24-
]
34+
]
35+
```
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Language support for Commands
2+
3+
If you have a server with players from all over the world you probably want a way to output the message into multiple languages.
4+
5+
Here in the example you can see there is a {LANG} tag. The 'test' after the LANG= points to the language tag in CustomCommands/lang.
6+
7+
8+
```json
19
[
210
{
311
"Title": "Sentance",
@@ -11,4 +19,5 @@
1119
"Time": 10
1220
}
1321
}
14-
]
22+
]
23+
```
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Multiple Aliases for one Command
2+
3+
Here is a way of creating aliases for a command.
4+
5+
For example there are many ways a user would try to get the discord link. Using a "," or ";" solve the issue
6+
7+
8+
```json
19
[
210
{
311
"Title": "Discord",
@@ -6,4 +14,5 @@
614
"Message": "{PREFIX}Discord: https://discord.gg/Z9JfJ9Y57C",
715
"PrintTo": 0
816
}
9-
]
17+
]
18+
```

0 commit comments

Comments
 (0)