@@ -186,88 +186,85 @@ void OnChatMessage(SteamFriends.FriendMsgCallback callBack)
186
186
//string[] args; UNCOMMECT WHEN BETTER SETUP IS ADDED!
187
187
if ( callBack . EntryType == EChatEntryType . ChatMsg )
188
188
{
189
- if ( callBack . Message . Length > 1 )
189
+ if ( callBack . Message . Length > 1 && callBack . Message . Remove ( 1 ) == "!" )
190
190
{
191
- if ( callBack . Message . Remove ( 1 ) == "!" )
191
+ string command = callBack . Message ;
192
+ if ( callBack . Message . Contains ( " " ) )
192
193
{
193
- string command = callBack . Message ;
194
- if ( callBack . Message . Contains ( " " ) )
195
- {
196
- command = callBack . Message . Remove ( callBack . Message . IndexOf ( " " ) ) ;
197
- }
198
-
199
- switch ( command )
200
- {
201
- #region !shutdown
202
- case "!shutdown" :
203
- if ( ! isBotAdmin ( callBack . Sender ) )
204
- {
205
- steamFriends . SendChatMessage ( callBack . Sender , EChatEntryType . ChatMsg , "Only admins can use the !shutdown command!" ) ;
206
- break ;
207
- }
208
- Environment . Exit ( 0 ) ;
194
+ command = callBack . Message . Remove ( callBack . Message . IndexOf ( " " ) ) ;
195
+ }
196
+
197
+ switch ( command )
198
+ {
199
+ #region !shutdown
200
+ case "!shutdown" :
201
+ if ( ! isBotAdmin ( callBack . Sender ) )
202
+ {
203
+ steamFriends . SendChatMessage ( callBack . Sender , EChatEntryType . ChatMsg , "Only admins can use the !shutdown command!" ) ;
209
204
break ;
210
- #endregion
211
-
212
- #region !setup
213
- case "!setup" :
214
- playerCount = players . Count ;
215
- for ( var i = 0 ; i < playerCount ; i ++ ) {
216
-
217
- if ( players [ i ] . id == callBack . Sender . AccountID )
218
- {
219
- Console . WriteLine ( "!setup command recived. User: {0}" , steamFriends . GetFriendPersonaName ( callBack . Sender ) ) ;
220
- steamFriends . SendChatMessage ( callBack . Sender , EChatEntryType . ChatMsg , "ID already found in list; ignoreing command..." ) ;
221
- return ;
222
- }
205
+ }
206
+ Environment . Exit ( 0 ) ;
207
+ break ;
208
+ #endregion
209
+
210
+ #region !setup
211
+ case "!setup" :
212
+ playerCount = players . Count ;
213
+ for ( var i = 0 ; i < playerCount ; i ++ ) {
214
+
215
+ if ( players [ i ] . id == callBack . Sender . AccountID )
216
+ {
217
+ Console . WriteLine ( "!setup command recived. User: {0}" , steamFriends . GetFriendPersonaName ( callBack . Sender ) ) ;
218
+ steamFriends . SendChatMessage ( callBack . Sender , EChatEntryType . ChatMsg , "ID already found in list; ignoreing command..." ) ;
219
+ return ;
223
220
}
224
- steamFriends . SendChatMessage ( callBack . Sender , EChatEntryType . ChatMsg , "Setting up user..." ) ;
221
+ }
222
+ steamFriends . SendChatMessage ( callBack . Sender , EChatEntryType . ChatMsg , "Setting up user..." ) ;
225
223
226
- players . Add ( new Structures . PlayerStructure { id = callBack . Sender . AccountID } ) ;
224
+ players . Add ( new Structures . PlayerStructure { id = callBack . Sender . AccountID } ) ;
227
225
228
- for ( var i = 0 ; i < players . Count ; i ++ )
226
+ for ( var i = 0 ; i < players . Count ; i ++ )
227
+ {
228
+ if ( callBack . Sender . AccountID == players [ i ] . id )
229
229
{
230
- if ( callBack . Sender . AccountID == players [ i ] . id )
231
- {
232
- players [ i ] . setupGame ( ) ;
233
- }
230
+ players [ i ] . setupGame ( ) ;
234
231
}
232
+ }
235
233
236
- break ;
234
+ break ;
237
235
238
- #endregion
236
+ #endregion
239
237
240
- #region !attack
241
- case "!attack" :
242
- foreach ( Structures . PlayerStructure player in players ) // Loop the list
238
+ #region !attack
239
+ case "!attack" :
240
+ foreach ( Structures . PlayerStructure player in players ) // Loop the list
241
+ {
242
+ if ( player . id == callBack . Sender . AccountID )
243
243
{
244
- if ( player . id == callBack . Sender . AccountID )
245
- {
246
- player . attack ( callBack , steamFriends ) ;
247
- }
244
+ player . attack ( callBack , steamFriends ) ;
248
245
}
249
- break ;
250
- #endregion
251
-
252
- #region !state
253
- case "!state" :
254
- foreach ( Structures . PlayerStructure player in players ) // Loop the list
246
+ }
247
+ break ;
248
+ #endregion
249
+
250
+ #region !state
251
+ case "!state" :
252
+ foreach ( Structures . PlayerStructure player in players ) // Loop the list
253
+ {
254
+ if ( player . id == callBack . Sender . AccountID )
255
255
{
256
- if ( player . id == callBack . Sender . AccountID )
257
- {
258
- player . state ( callBack , steamFriends ) ;
259
- }
256
+ player . state ( callBack , steamFriends ) ;
260
257
}
261
- break ;
262
- #endregion
263
-
264
- #region !help
265
- case " !help" :
266
- Console . WriteLine ( "!help command revied. User: {0}" , steamFriends . GetFriendPersonaName ( callBack . Sender ) ) ;
267
- steamFriends . SendChatMessage ( callBack . Sender , EChatEntryType . ChatMsg , "The current commands are: \n !help \n !attack \n !setup \n !shutdown(admin only)" ) ;
268
- break ;
269
- #endregion
270
- }
258
+ }
259
+ break ;
260
+ #endregion
261
+
262
+ #region !help
263
+ case "!help" :
264
+ Console . WriteLine ( "!help command revied. User: {0}" , steamFriends . GetFriendPersonaName ( callBack . Sender ) ) ;
265
+ steamFriends . SendChatMessage ( callBack . Sender , EChatEntryType . ChatMsg , "The current commands are: \n !help \n !attack \n !setup \n !shutdown(admin only)" ) ;
266
+ break ;
267
+ #endregion
271
268
}
272
269
}
273
270
}
0 commit comments