-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathUServer.Commands.pas
More file actions
558 lines (500 loc) · 13.8 KB
/
UServer.Commands.pas
File metadata and controls
558 lines (500 loc) · 13.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
unit UServer.Commands;
interface
uses
Winapi.Windows, System.SysUtils, System.Classes, Vcl.Graphics, UServer.Types;
type
TCommands = class
private
FAirdropMassCount: Byte;
FGetPlayersID: TGetPlayersIDFunc;
FLogHandler: TLogHandler;
FSendCommandHandler: TSendCommandHandler;
function GetSIDs: TStringList;
procedure ExecuteCommand(Cmd: string);
procedure Log(Text: string);
public
constructor Create;
function GiveExpirienceAll(Amount: Cardinal): Word;
function GiveItemAll(Item: string; Amount: Cardinal): Word;
function GiveItemsAll(Items: TStringList; Amount: Cardinal): Word;
function GiveMoneyAll(Amount: Cardinal): Word;
function GiveVehicleAll(Vehicle: string): Word;
function HealAll: Word;
function KickAll(Reason: string): Word;
function KillAll: Word;
function TeleportAll(Target: TMapPlace): Word; overload;
function TeleportAll(Target: TSteamID): Word; overload;
procedure Admin(SteamID: TSteamID);
procedure Airdrop;
procedure AirdropMass;
procedure Ban(SteamID: TSteamID; Reason: string; Duration: Cardinal);
procedure Chat(Text: string; Color: TColor); overload;
procedure GetAdmins;
procedure GetBans;
procedure GetPlayers;
procedure Login(const Password: string);
procedure Shutdown(Delay: Cardinal = 1);
procedure GetPerms(SteamID: TSteamID);
procedure Command(Data: string);
procedure GetNowInfo;
procedure Chat(Text: string; Color: TColor; SteamID: TSteamID); overload;
procedure GiveExpirience(SteamID: TSteamID; Amount: Cardinal);
procedure GiveItem(SteamID: TSteamID; Item: string; Amount: Cardinal);
procedure GiveItems(SteamID: TSteamID; Items: TStringList; Amount: Cardinal);
procedure GiveMoney(SteamID: TSteamID; Amount: Cardinal);
procedure GiveVehicle(SteamID: TSteamID; Vehicle: string);
procedure Heal(SteamID: TSteamID);
procedure Kick(SteamID: TSteamID; Reason: string);
procedure Kill(SteamID: TSteamID);
procedure Mute(SteamID: TSteamID);
procedure PermAdd(SteamID: TSteamID; Group: string);
procedure PermRemove(SteamID: TSteamID; Group: string);
procedure SetDay;
procedure SetNight;
procedure Slay(SteamID: TSteamID);
procedure Spy(SteamID: TSteamID);
procedure Storm;
procedure Teleport(SteamID: TSteamID; Target: TMapPlace); overload;
procedure Teleport(SteamID: TSteamID; Target: TSteamID); overload;
procedure Unadmin(SteamID: TSteamID);
procedure Unban(SteamID: TSteamID);
property AirdropMassCount: Byte read FAirdropMassCount write FAirdropMassCount default 10;
property GetPlayersID: TGetPlayersIDFunc read FGetPlayersID write FGetPlayersID;
property LogHandler: TLogHandler read FLogHandler write FLogHandler;
property SendCommandHandler: TSendCommandHandler read FSendCommandHandler write FSendCommandHandler;
end;
implementation
uses
UServer.CommonFunc;
{ TCommands }
constructor TCommands.Create;
begin
FAirdropMassCount := 10;
end;
procedure TCommands.GetAdmins;
begin
ExecuteCommand('admins');
end;
procedure TCommands.GetBans;
begin
ExecuteCommand('bans');
end;
procedure TCommands.GetNowInfo;
begin
ExecuteCommand('GET NOW');
end;
procedure TCommands.GetPerms(SteamID: TSteamID);
begin
ExecuteCommand('p "' + SteamID + '"');
end;
procedure TCommands.GetPlayers;
begin
ExecuteCommand('players');
end;
function TCommands.GetSIDs: TStringList;
begin
if not Assigned(FGetPlayersID) then
Exit(TStringList.Create);
FGetPlayersID(Result);
end;
function TCommands.GiveExpirienceAll(Amount: Cardinal): Word;
var
Items: TStringList;
i: Integer;
begin
Result := 0;
Items := GetSIDs;
if Items.Count <= 0 then
Exit;
for i := 0 to Items.Count - 1 do
begin
GiveExpirience(Items[i], Amount);
Inc(Result);
end;
end;
function TCommands.GiveItemAll(Item: string; Amount: Cardinal): Word;
var
SIDs: TStringList;
i: Integer;
begin
Result := 0;
SIDs := GetSIDs;
if SIDs.Count <= 0 then
Exit;
for i := 0 to SIDs.Count - 1 do
begin
GiveItem(SIDs[i], Item, Amount);
Inc(Result);
end;
end;
function TCommands.GiveItemsAll(Items: TStringList; Amount: Cardinal): Word;
var
SIDs: TStringList;
i: Integer;
begin
Result := 0;
SIDs := GetSIDs;
if SIDs.Count <= 0 then
Exit;
for i := 0 to SIDs.Count - 1 do
begin
GiveItems(SIDs[i], Items, Amount);
Inc(Result);
end;
end;
function TCommands.GiveMoneyAll(Amount: Cardinal): Word;
var
Items: TStringList;
i: Integer;
begin
Result := 0;
Items := GetSIDs;
if Items.Count <= 0 then
Exit;
for i := 0 to Items.Count - 1 do
begin
GiveMoney(Items[i], Amount);
Inc(Result);
end;
end;
function TCommands.GiveVehicleAll(Vehicle: string): Word;
var
Items: TStringList;
i: Integer;
begin
Result := 0;
Items := GetSIDs;
if Items.Count <= 0 then
Exit;
for i := 0 to Items.Count - 1 do
begin
GiveVehicle(Items[i], Vehicle);
Inc(Result);
end;
end;
function TCommands.HealAll: Word;
var
Items: TStringList;
i: Integer;
begin
Result := 0;
Items := GetSIDs;
if Items.Count <= 0 then
Exit;
for i := 0 to Items.Count - 1 do
begin
Heal(Items[i]);
Inc(Result);
end;
end;
function TCommands.KickAll(Reason: string): Word;
var
Items: TStringList;
i: Integer;
begin
Result := 0;
Items := GetSIDs;
if Items.Count <= 0 then
Exit;
for i := 0 to Items.Count - 1 do
begin
Kick(Items[i], Reason);
Inc(Result);
end;
end;
function TCommands.KillAll: Word;
var
Items: TStringList;
i: Integer;
begin
Result := 0;
Items := GetSIDs;
if Items.Count <= 0 then
Exit;
for i := 0 to Items.Count - 1 do
begin
Kill(Items[i]);
Inc(Result);
end;
end;
function TCommands.TeleportAll(Target: TSteamID): Word;
var
Items: TStringList;
i: Integer;
begin
Result := 0;
Items := GetSIDs;
if Items.Count <= 0 then
Exit;
for i := 0 to Items.Count - 1 do
begin
if Items[i] = Target then
Continue;
Teleport(Items[i], Target);
Inc(Result);
end;
end;
function TCommands.TeleportAll(Target: TMapPlace): Word;
var
Items: TStringList;
i: Integer;
begin
Result := 0;
Items := GetSIDs;
if Items.Count <= 0 then
Exit;
for i := 0 to Items.Count - 1 do
begin
Teleport(Items[i], Target);
Inc(Result);
end;
end;
procedure TCommands.Admin(SteamID: TSteamID);
begin
ExecuteCommand('admin ' + SteamID);
end;
procedure TCommands.Airdrop;
begin
ExecuteCommand('airdrop');
Log('Âûçâàí Airdrop');
end;
procedure TCommands.AirdropMass;
var
i: Integer;
begin
for i := 1 to FAirdropMassCount do
ExecuteCommand('airdrop');
Log('Âûçâàí ìàññîâûé Airdrop (x' + IntToStr(FAirdropMassCount) + ')');
end;
procedure TCommands.Ban(SteamID: TSteamID; Reason: string; Duration: Cardinal);
begin
{ban [SteamID | Player]/[Reason]/[Duration]}
ExecuteCommand(Format('ban %s "%s" %d', [SteamID, Reason, Duration]));
Log(Format('Îòïðàâëåí â áàí %s "%s" %d', [SteamID, Reason, Duration]));
end;
procedure ConvertForServerControlPlugin(var Text: string);
var
i: Integer;
begin
//Ñòðî÷íûå
Text := Text.Replace('à', '/00');
Text := Text.Replace('á', '/01');
Text := Text.Replace('â', '/02');
Text := Text.Replace('ã', '/03');
Text := Text.Replace('ä', '/04');
Text := Text.Replace('å', '/05');
Text := Text.Replace('¸', '/06');
Text := Text.Replace('æ', '/07');
Text := Text.Replace('ç', '/08');
Text := Text.Replace('è', '/09');
Text := Text.Replace('é', '/10');
Text := Text.Replace('ê', '/11');
Text := Text.Replace('ë', '/12');
Text := Text.Replace('ì', '/13');
Text := Text.Replace('í', '/14');
Text := Text.Replace('î', '/15');
Text := Text.Replace('ï', '/16');
Text := Text.Replace('ð', '/17');
Text := Text.Replace('ñ', '/18');
Text := Text.Replace('ò', '/19');
Text := Text.Replace('ó', '/20');
Text := Text.Replace('ô', '/21');
Text := Text.Replace('õ', '/22');
Text := Text.Replace('ö', '/23');
Text := Text.Replace('÷', '/24');
Text := Text.Replace('ø', '/25');
Text := Text.Replace('ù', '/26');
Text := Text.Replace('ú', '/27');
Text := Text.Replace('û', '/28');
Text := Text.Replace('ü', '/29');
Text := Text.Replace('ý', '/30');
Text := Text.Replace('þ', '/31');
Text := Text.Replace('ÿ', '/32');
//Ïðîïèñíûå
Text := Text.Replace('À', '/33');
Text := Text.Replace('Á', '/34');
Text := Text.Replace('Â', '/35');
Text := Text.Replace('Ã', '/36');
Text := Text.Replace('Ä', '/37');
Text := Text.Replace('Å', '/38');
Text := Text.Replace('¨', '/39');
Text := Text.Replace('Æ', '/40');
Text := Text.Replace('Ç', '/41');
Text := Text.Replace('È', '/42');
Text := Text.Replace('É', '/43');
Text := Text.Replace('Ê', '/44');
Text := Text.Replace('Ë', '/45');
Text := Text.Replace('Ì', '/46');
Text := Text.Replace('Í', '/47');
Text := Text.Replace('Î', '/48');
Text := Text.Replace('Ï', '/49');
Text := Text.Replace('Ð', '/50');
Text := Text.Replace('Ñ', '/51');
Text := Text.Replace('Ò', '/52');
Text := Text.Replace('Ó', '/53');
Text := Text.Replace('Ô', '/54');
Text := Text.Replace('Õ', '/55');
Text := Text.Replace('Ö', '/56');
Text := Text.Replace('×', '/57');
Text := Text.Replace('Ø', '/58');
Text := Text.Replace('Ù', '/59');
Text := Text.Replace('Ú', '/60');
Text := Text.Replace('Û', '/61');
Text := Text.Replace('Ü', '/62');
Text := Text.Replace('Ý', '/63');
Text := Text.Replace('Þ', '/64');
Text := Text.Replace('ß', '/65');
//Ñïåö.
Text := Text.Replace('"', '/66');
end;
procedure TCommands.Chat(Text: string; Color: TColor; SteamID: TSteamID);
var
R, G, B: Byte;
RGB: Integer;
begin
ConvertForServerControlPlugin(Text);
RGB := ColorToRGB(Color);
R := GetRValue(RGB);
G := GetGValue(RGB);
B := GetBValue(RGB);
ExecuteCommand(Format('cchat "%s" "%s" %d %d %d', [SteamID, Text, R, G, B]));
end;
procedure TCommands.Command(Data: string);
begin
ExecuteCommand(Data);
Log(Format('Âûïîëíåíà êîìàíäà %s', [Data]));
end;
procedure TCommands.Chat(Text: string; Color: TColor);
var
R, G, B: Byte;
RGB: Integer;
begin
ConvertForServerControlPlugin(Text);
RGB := ColorToRGB(Color);
R := GetRValue(RGB);
G := GetGValue(RGB);
B := GetBValue(RGB);
ExecuteCommand(Format('cchat "%s" %d %d %d', [Text, R, G, B]));
end;
procedure TCommands.ExecuteCommand(Cmd: string);
begin
if not Assigned(FSendCommandHandler) then
Exit;
FSendCommandHandler(Cmd);
end;
procedure TCommands.GiveExpirience(SteamID: TSteamID; Amount: Cardinal);
begin
ExecuteCommand(Format('experience %s %d', [SteamID, Amount]));
Log(Format('Âûäà÷à îïûòà %s +%d', [SteamID, Amount]));
end;
procedure TCommands.GiveItem(SteamID: TSteamID; Item: string; Amount: Cardinal);
begin
ExecuteCommand(Format('give %s %s %d', [SteamID, Item, Amount]));
Log(Format('Âûäà÷à ïðåäìåòà %s %s ïî %d', [SteamID, Item, Amount]));
end;
procedure TCommands.GiveItems(SteamID: TSteamID; Items: TStringList; Amount: Cardinal);
var
i: Integer;
begin
for i := 0 to Items.Count - 1 do
ExecuteCommand(Format('give %s %s %d', [SteamID, Items[i], Amount]));
Log(Format('Âûäà÷à ïðåäìåòîâ %s %s ïî %d', [SteamID, Items.Text, Amount]));
end;
procedure TCommands.GiveMoney(SteamID: TSteamID; Amount: Cardinal);
begin
ExecuteCommand(Format('pay %s %d', [SteamID, Amount]));
Log(Format('Âûäà÷à äåíåã (EP) %s +%d', [SteamID, Amount]));
end;
procedure TCommands.GiveVehicle(SteamID: TSteamID; Vehicle: string);
begin
ExecuteCommand(Format('vehicle %s %s', [SteamID, Vehicle]));
Log(Format('Âûäà÷à òðàíñïîðòà %s %s', [SteamID, Vehicle]));
end;
procedure TCommands.Heal(SteamID: TSteamID);
begin
ExecuteCommand('heal ' + SteamID);
Log('Ïîëíîå ëå÷åíèå ' + SteamID);
end;
procedure TCommands.Kick(SteamID: TSteamID; Reason: string);
begin
ExecuteCommand('kick ' + SteamID + ' "' + Reason + '"');
Log('Âûãíàí ñ ñåðâåðà ' + SteamID);
end;
procedure TCommands.Kill(SteamID: TSteamID);
begin
ExecuteCommand('kill ' + SteamID);
Log('Óáèò ' + SteamID);
end;
procedure TCommands.Log(Text: string);
begin
if Assigned(FLogHandler) then
FLogHandler(Text);
end;
procedure TCommands.Login(const Password: string);
begin
ExecuteCommand('login ' + Password);
end;
procedure TCommands.Mute(SteamID: TSteamID);
begin
ExecuteCommand('mute ' + SteamID);
Log('Èãðîêó ' + SteamID + ' çàïðåù¸í ÷àò');
end;
procedure TCommands.PermAdd(SteamID: TSteamID; Group: string);
begin
ExecuteCommand('p add ' + SteamID + ' ' + Group);
Log(SteamID + ' äîáàâëåí â ãðóïïó ' + Group);
end;
procedure TCommands.PermRemove(SteamID: TSteamID; Group: string);
begin
ExecuteCommand('p remove ' + SteamID + ' ' + Group);
Log(SteamID + ' óäàë¸í èç ãðóïïû ' + Group);
end;
procedure TCommands.SetDay;
begin
ExecuteCommand('day');
Log('Óñòàíîâëåí äåíü');
end;
procedure TCommands.SetNight;
begin
ExecuteCommand('night');
Log('Óñòàíîâëåíà íî÷ü');
end;
procedure TCommands.Shutdown(Delay: Cardinal);
begin
end;
procedure TCommands.Slay(SteamID: TSteamID);
begin
ExecuteCommand('slay ' + SteamID);
Log('Èãðîê ' + SteamID + ' óáèò, êèêíóò è îòïðàâëåí â áàí íà ãîä');
end;
procedure TCommands.Spy(SteamID: TSteamID);
begin
ExecuteCommand('spy ' + SteamID);
Log('Ñëåæåíèå çà èãðîé ' + SteamID);
end;
procedure TCommands.Storm;
begin
ExecuteCommand('weather storm');
Log('Óñòàíîâëåíà/óáðàíà ïàñìóðíàÿ ïîãîäà');
end;
procedure TCommands.Teleport(SteamID, Target: TSteamID);
begin
ExecuteCommand('teleport ' + SteamID + ' "' + Target + '"');
Log(SteamID + ' òåëåïîðòèðîâàí ê ' + Target);
end;
procedure TCommands.Teleport(SteamID: TSteamID; Target: TMapPlace);
begin
ExecuteCommand('teleport ' + SteamID + ' "' + Target.Name + '"');
Log(SteamID + ' òåëåïîðòèðîâàí â ' + Target.Desc);
end;
procedure TCommands.Unadmin(SteamID: TSteamID);
begin
ExecuteCommand('unadmin ' + SteamID);
Log('Óäàë¸í àäìèí ' + SteamID);
end;
procedure TCommands.Unban(SteamID: TSteamID);
begin
ExecuteCommand('unban ' + SteamID);
Log('Ðàçáàíåí ' + SteamID);
end;
end.