@@ -818,6 +818,7 @@ private class Commands
818
818
public string PickCode = "pick" ;
819
819
public string RandomCode = "random" ;
820
820
public string RemoveCode = "remove" ;
821
+ public string SetCode = "set" ;
821
822
public string QuietMode = "quiet" ;
822
823
823
824
public Commands ( AutoCode plugin )
@@ -941,25 +942,43 @@ private void HandleUse(BasePlayer player, string label, string[] args)
941
942
plugin . data . Inst . playerSettings . Add ( player . userID , new Data . Structure . PlayerSettings ( ) ) ;
942
943
}
943
944
944
- string operation = args [ 0 ] . ToLower ( ) ;
945
+ int nextArg = 0 ;
946
+ int argsRemainingCount = args . Length ;
947
+
948
+ string operation = args [ nextArg ++ ] . ToLower ( ) ;
949
+ argsRemainingCount -- ;
950
+
945
951
bool guest = false ;
946
952
947
953
if ( operation == Guest )
948
954
{
949
- if ( args . Length < 2 )
955
+ if ( argsRemainingCount < 1 )
950
956
{
951
957
SyntaxError ( player , label , args ) ;
952
958
return ;
953
959
}
954
960
955
961
guest = true ;
956
- operation = args [ 1 ] . ToLower ( ) ;
962
+ operation = args [ nextArg ++ ] . ToLower ( ) ;
963
+ argsRemainingCount -- ;
964
+ }
965
+
966
+ if ( operation == SetCode )
967
+ {
968
+ if ( argsRemainingCount < 1 )
969
+ {
970
+ SyntaxError ( player , label , args ) ;
971
+ return ;
972
+ }
973
+
974
+ operation = args [ nextArg ++ ] . ToLower ( ) ;
975
+ argsRemainingCount -- ;
957
976
}
958
977
959
978
// Pick code.
960
979
if ( operation == PickCode )
961
980
{
962
- if ( ( guest && args . Length > 2 ) || ( ! guest && args . Length > 1 ) )
981
+ if ( argsRemainingCount > 0 )
963
982
{
964
983
plugin . Message (
965
984
player ,
@@ -980,7 +999,7 @@ private void HandleUse(BasePlayer player, string label, string[] args)
980
999
SyntaxError ( player , label , args ) ;
981
1000
return ;
982
1001
}
983
- if ( args . Length > 1 )
1002
+ if ( argsRemainingCount > 0 )
984
1003
{
985
1004
plugin . Message (
986
1005
player ,
@@ -996,7 +1015,7 @@ private void HandleUse(BasePlayer player, string label, string[] args)
996
1015
// Remove?
997
1016
if ( operation == RemoveCode )
998
1017
{
999
- if ( ( guest && args . Length > 2 ) || ( ! guest && args . Length > 1 ) )
1018
+ if ( argsRemainingCount > 0 )
1000
1019
{
1001
1020
plugin . Message (
1002
1021
player ,
@@ -1012,7 +1031,7 @@ private void HandleUse(BasePlayer player, string label, string[] args)
1012
1031
// Use random code?
1013
1032
if ( operation == RandomCode )
1014
1033
{
1015
- if ( ( guest && args . Length > 2 ) || ( ! guest && args . Length > 1 ) )
1034
+ if ( argsRemainingCount > 0 )
1016
1035
{
1017
1036
plugin . Message (
1018
1037
player ,
@@ -1035,7 +1054,7 @@ private void HandleUse(BasePlayer player, string label, string[] args)
1035
1054
// Use given code?
1036
1055
if ( plugin . IsValidCode ( operation ) )
1037
1056
{
1038
- if ( ( guest && args . Length > 2 ) || ( ! guest && args . Length > 1 ) )
1057
+ if ( argsRemainingCount > 0 )
1039
1058
{
1040
1059
plugin . Message (
1041
1060
player ,
@@ -1121,13 +1140,22 @@ public string GetHelp(BasePlayer player, string label)
1121
1140
private string GetUsage ( string label )
1122
1141
{
1123
1142
return string . Format (
1124
- "/ {0} <{1}>" ,
1143
+ "{0} <{1}>" ,
1125
1144
label ,
1126
1145
string . Join ( "|" , new string [ ] {
1127
1146
string . Format (
1128
1147
"[{0}] <{1}>" ,
1129
1148
Guest ,
1130
- string . Join ( "|" , new string [ ] { "1234" , PickCode , RandomCode , RemoveCode } )
1149
+ string . Join ( "|" , new string [ ] {
1150
+ string . Format (
1151
+ "[{0}] {1}" ,
1152
+ SetCode ,
1153
+ "1234"
1154
+ ) ,
1155
+ PickCode ,
1156
+ RandomCode ,
1157
+ RemoveCode
1158
+ } )
1131
1159
) ,
1132
1160
QuietMode
1133
1161
} )
0 commit comments