-
Notifications
You must be signed in to change notification settings - Fork 0
/
runmode.pas
2334 lines (1895 loc) · 99 KB
/
runmode.pas
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
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//Run Mode v3(1.7.1.1) by Savage
uses database;
const
DB_ID = 1;
DB_NAME = 'runmode.db';
COLOR_1 = $6495ed;
COLOR_2 = $F0E68C;
PATH_TO_FILES = '/home/shared_data/';
USED_IP_TIME = 8;//hours
type tCheckPoint = Record
X, Y: Single;
end;
type tRecord = Record
X, Y: Single;
end;
var
_CheckPoint: array of tCheckPoint;
_Laps: Byte;
_ReplayTime, _WorldTextLoop, _ReplayTime2, _WorldTextLoop2: Integer;
_LapsPassed, _CheckPointPassed: array[1..32] of Byte;
_Timer: array[1..32] of TDateTime;
{$IFDEF RUN_MODE_DEBUG}
_PingRespawn: array[1..32] of Integer;
{$ENDIF}
_ShowTimer, _RKill, _LoggedIn, _JustDied, _FlightMode, _GodMode: array[1..32] of Boolean;
_EliteList, _UsedIP: TStringList;
_Record: array[1..32] of array of tRecord;
_Replay, _Replay2: array of tRecord;
_ScoreId, _ReplayInfo, _ReplayInfo2: String;
_EditMode: Boolean;
_LastPosX, _LastPosY: array[1..32] of Single;
function EscapeApostrophe(Source: String): String;
begin
Result := ReplaceRegExpr('''', Source, '''''', FALSE);
end;
function GetPiece(Source, Delimiter: String; Number: Byte): String;
var
TempStrL: TStringList;
begin
Try
TempStrL := File.CreateStringList;
SplitRegExpr(Delimiter, Source, TempStrL);
Result := TempStrL[Number];
Except
Result := '';
Finally
TempStrL.Free;
end;
end;
{$IFDEF CLIMB}
procedure RecountAllStats;
var
PosCounter: Integer;
MapName, NewMapName: String;
begin
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Gold = 0, Silver = 0, Bronze = 0, NoMedal = 0, Points = 0;') then
WriteLn('RunModeError14: '+DB_Error);
if Not DB_Query(DB_ID, 'SELECT Account, Map FROM Scores ORDER BY Map, Time, Date;') then
WriteLn('RunModeError15: '+DB_Error)
else begin
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
While DB_NextRow(DB_ID) Do begin
NewMapName := DB_GetString(DB_ID, 1);
if Game.MapsList.GetMapIdByName(NewMapName) = -1 then//Do not count maps that are not in maplist
Continue;
if MapName <> NewMapName then begin
MapName := NewMapName;
PosCounter := 0;
end;
Inc(PosCounter, 1);
if PosCounter = 1 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Gold = Gold + 1, Points = Points + 12 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError16: '+DB_Error);
if PosCounter = 2 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Silver = Silver + 1, Points = Points + 6 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError17: '+DB_Error);
if PosCounter = 3 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Bronze = Bronze + 1, Points = Points + 3 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError18: '+DB_Error);
if PosCounter > 3 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 1 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError19: '+DB_Error);
end;
DB_Update(DB_ID, 'COMMIT;');
end;
DB_FinishQuery(DB_ID);
end;
{$ELSE}
procedure RecountAllStats;
var
PosCounter: Integer;
MapName, NewMapName: String;
begin
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Gold = 0, Silver = 0, Bronze = 0, NoMedal = 0, Points = 0;') then
WriteLn('RunModeError1: '+DB_Error);
if Not DB_Query(DB_ID, 'SELECT Account, Map FROM Scores ORDER BY Map, Time, Date;') then
WriteLn('RunModeError2: '+DB_Error)
else begin
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
While DB_NextRow(DB_ID) Do begin
NewMapName := DB_GetString(DB_ID, 1);
if Game.MapsList.GetMapIdByName(NewMapName) = -1 then//Do not count maps that are not in maplist
Continue;
if MapName <> NewMapName then begin
MapName := NewMapName;
PosCounter := 0;
end;
Inc(PosCounter, 1);
if PosCounter = 1 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Gold = Gold + 1, Points = Points + 25 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError3: '+DB_Error);
if PosCounter = 2 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Silver = Silver + 1, Points = Points + 20 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError4: '+DB_Error);
if PosCounter = 3 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Bronze = Bronze + 1, Points = Points + 15 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError5: '+DB_Error);
if PosCounter = 4 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 10 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError6: '+DB_Error);
if PosCounter = 5 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 7 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError7: '+DB_Error);
if PosCounter = 6 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 5 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError8: '+DB_Error);
if PosCounter = 7 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 4 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError9: '+DB_Error);
if PosCounter = 8 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 3 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError10: '+DB_Error);
if PosCounter = 9 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 2 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError11: '+DB_Error);
if PosCounter = 10 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 1 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError12: '+DB_Error);
if PosCounter > 10 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError13: '+DB_Error);
end;
DB_Update(DB_ID, 'COMMIT;');
end;
DB_FinishQuery(DB_ID);
end;
{$ENDIF}
procedure GenerateEliteList;
var
i, j, TempNumber: Integer;
TempTable: array[0..6] of TStringList;
TempString: String;
begin
_EliteList.Clear;
for i := 0 to 6 do
TempTable[i] := File.CreateStringList;
TempTable[0].Append('|Position');
TempTable[0].Append('|');
TempTable[1].Append('|Name');
TempTable[1].Append('');
TempTable[2].Append('|Gold');
TempTable[2].Append('');
TempTable[3].Append('|Silver');
TempTable[3].Append('');
TempTable[4].Append('|Bronze');
TempTable[4].Append('');
TempTable[5].Append('|NoMedal');
TempTable[5].Append('');
TempTable[6].Append('|Points');
TempTable[6].Append('');
if Not DB_Query(DB_ID, 'SELECT Name, Gold, Silver, Bronze, NoMedal, Points FROM Accounts ORDER BY Points DESC LIMIT 20;') then
WriteLn('RunModeError20: '+DB_Error)
else
While DB_NextRow(DB_ID) Do Begin
Inc(TempNumber, 1);
TempTable[0].Append('|'+IntToStr(TempNumber));
TempTable[1].Append('|'+DB_GetString(DB_ID, 0));
TempTable[2].Append('|'+DB_GetString(DB_ID, 1));
TempTable[3].Append('|'+DB_GetString(DB_ID, 2));
TempTable[4].Append('|'+DB_GetString(DB_ID, 3));
TempTable[5].Append('|'+DB_GetString(DB_ID, 4));
TempTable[6].Append('|'+DB_GetString(DB_ID, 5));
end;
TempNumber := 0;
for j := 0 to 6 do begin
TempNumber := 0;
for i := 0 to TempTable[j].Count-1 do
if length(TempTable[j][i]) > TempNumber then
TempNumber := length(TempTable[j][i]);
for i := 0 to TempTable[j].Count-1 do begin
TempString := TempTable[j][i];
While length(TempString) < TempNumber do
if i = 1 then
Insert('-', TempString, Length(TempString)+1)
else
Insert(' ', TempString, Length(TempString)+1);
TempTable[j][i] := TempString;
end;
end;
TempNumber := Length(TempTable[0][0])+Length(TempTable[1][0])+Length(TempTable[2][0])+Length(TempTable[3][0])+Length(TempTable[4][0])+Length(TempTable[5][0])+Length(TempTable[6][0])+1;
TempString := '-';
While length(TempString) < TempNumber do
Insert('-', TempString, Length(TempString)+1);
_EliteList.Append(TempString);
for i := 0 to TempTable[0].Count-1 do
_EliteList.Append(TempTable[0][i]+TempTable[1][i]+TempTable[2][i]+TempTable[3][i]+TempTable[4][i]+TempTable[5][i]+TempTable[6][i]+'|');
_EliteList.Append(TempString);
DB_FinishQuery(DB_ID);
for i := 0 to 6 do
TempTable[i].Free;
end;
function MapBestTime(MapName: String): TDateTime;
begin
if Not DB_Query(DB_ID, 'SELECT Time FROM Scores WHERE Map = '''+EscapeApostrophe(MapName)+''' ORDER BY Time, Date;') then
WriteLn('RunModeError21: '+DB_Error)
else begin
if Not DB_NextRow(DB_ID) then
Result := -1
else
Result := DB_GetDouble(DB_ID, 0);
DB_FinishQuery(DB_ID);
end;
end;
function PlayerBestTime(Account, MapName: String): TDateTime;
begin
if Not DB_Query(DB_ID, 'SELECT Time, Id FROM Scores WHERE Account = '''+EscapeApostrophe(Account)+''' AND Map = '''+EscapeApostrophe(MapName)+''' LIMIT 1;') then
WriteLn('RunModeError22: '+DB_Error)
else begin
if Not DB_NextRow(DB_ID) then
Result := -1
else begin
Result := DB_GetDouble(DB_ID, 0);
_ScoreId := DB_GetString(DB_ID, 1);
end;
DB_FinishQuery(DB_ID);
end;
end;
function ShowTime(DaysPassed: TDateTime): String;
begin
DaysPassed := Abs(DaysPassed);
if Trunc(DaysPassed) > 0 then
Result := IntToStr(Trunc(DaysPassed))+' '+iif(Trunc(DaysPassed) = 1, 'day', 'days')+', '+FormatDateTime('hh:nn:ss.zzz', DaysPassed)
else
if DaysPassed >= 1.0/24 then
Result := FormatDateTime('hh:nn:ss.zzz', DaysPassed)
else
if DaysPassed >= 1.0/1440 then
Result := FormatDateTime('nn:ss.zzz', DaysPassed)
else
if DaysPassed >= 1.0/86400 then
Result := FormatDateTime('ss.zzz', DaysPassed)
else
if DaysPassed >= 1.0/86400000 then
Result := FormatDateTime('zzz', DaysPassed)
else
Result := '000';
end;
procedure Clock(Ticks: Integer);
var
i: Byte;
j, PosCounter: Integer;
TempTime, TempTime2, Timer: TDateTime;
begin
if Ticks mod 6 = 0 then begin
if Length(_Replay) > 0 then begin
if _WorldTextLoop = 240 then
_WorldTextLoop := 200;
Inc(_WorldTextLoop, 1);
if _ReplayTime < Length(_Replay) then begin
Inc(_ReplayTime, 1);
Players.WorldText(_WorldTextLoop, '.', 240, $FF0000, 0.15, _Replay[_ReplayTime-1].X+30*-0.15, _Replay[_ReplayTime-1].Y+140*-0.15);
Players.BigText(10, _ReplayInfo+' '+IntToStr(_ReplayTime)+'/'+IntToStr(Length(_Replay)), 120, $FF0000, 0.05, 5, 340);
if (_ReplayTime = Length(_Replay)) and (Length(_Replay2) = 0) then
_ReplayTime := 0;
end;
end;
if Length(_Replay2) > 0 then begin
if _WorldTextLoop2 = 190 then
_WorldTextLoop2 := 150;
Inc(_WorldTextLoop2, 1);
if _ReplayTime2 < Length(_Replay2) then begin
Inc(_ReplayTime2, 1);
Players.WorldText(_WorldTextLoop2, '.', 240, $0000FF, 0.15, _Replay2[_ReplayTime2-1].X+30*-0.15, _Replay2[_ReplayTime2-1].Y+140*-0.15);
Players.BigText(11, _ReplayInfo2+' '+IntToStr(_ReplayTime2)+'/'+IntToStr(Length(_Replay2)), 120, $0000FF, 0.05, 5, 360);
end;
if (_ReplayTime2 = Length(_Replay2)) and (_ReplayTime = Length(_Replay)) then begin
_ReplayTime2 := 0;
_ReplayTime := 0;
end;
end;
end;
for i := 1 to 32 do
if Players[i].Active then begin
if Ticks mod 6 = 0 then
if Players[i].Alive then
if Length(_Record[i]) > 0 then begin
if Distance(_Record[i][High(_Record[i])].X, _Record[i][High(_Record[i])].Y, Players[i].X, Players[i].Y) >= 300 then begin
Players[i].Damage(i, 150);
Players.WriteConsole('Offmap bug, lag or teleport cheat detected, player '+Players[i].Name+' has been killed', $FF0000);
exit;
end;
SetLength(_Record[i], Length(_Record[i])+1);
_Record[i][High(_Record[i])].X := Players[i].X;
_Record[i][High(_Record[i])].Y := Players[i].Y;
end;
if _ShowTimer[i] then
if _Laps = 0 then
Players[i].BigText(3, ShowTime(Now - _Timer[i])+#10+IntToStr(Trunc(21.6*sqrt(Players[i].VelX*Players[i].VelX + Players[i].VelY*Players[i].VelY)))+'km/h', 120, $FFFFFF, 0.1, 320, 360)
else
Players[i].BigText(3, ShowTime(Now - _Timer[i])+#10+'Lap: '+IntToStr(_LapsPassed[i]+1)+'/'+IntToStr(_Laps)+#10+IntToStr(Trunc(21.6*sqrt(Players[i].VelX*Players[i].VelX + Players[i].VelY*Players[i].VelY)))+'km/h', 120, $FFFFFF, 0.1, 320, 360);
if length(_CheckPoint) > 1 then begin
for j := 0 to High(_CheckPoint) do begin
if (Players[i].Alive) and (not _EditMode) and (not _FlightMode[i]) and (not _GodMode[i]) then begin
if _Laps = 0 then begin
if (_CheckPointPassed[i] <> 0) and (_CheckPointPassed[i] = j) and (Distance(_CheckPoint[j].X, _CheckPoint[j].Y, Players[i].X, Players[i].Y) <= 30) and (Now - _Timer[i] >= 1.0/86400) then
if j <> High(_CheckPoint) then
_CheckPointPassed[i] := j+1
else begin
Timer := Now - _Timer[i];
{$IFDEF RUN_MODE_DEBUG}
Players[i].WriteConsole('Respawn Ping: '+IntToStr(_PingRespawn[i])+', Finish Ping: '+IntToStr(Players[i].Ping), $FF0000);
if _PingRespawn[i] >= Players[i].Ping then
Players[i].WriteConsole('Ping Compensated Time: '+ShowTime(Timer - (1.0/86400000*Players[i].Ping)), $FF0000)
else
Players[i].WriteConsole('Ping Compensated Time: '+ShowTime(Timer - (1.0/86400000*_PingRespawn[i])), $FF0000);
{$ENDIF}
end;
end else
if (_CheckPointPassed[i] <> 0) and (_CheckPointPassed[i] = j) and (Distance(_CheckPoint[j].X, _CheckPoint[j].Y, Players[i].X, Players[i].Y) <= 30) and (Now - _Timer[i] >= 1.0/86400) then
_CheckPointPassed[i] := j+1;
end;
if Ticks mod 15 = 0 then
if j+1 = _CheckPointPassed[i] then
Players[i].WorldText(j, IntToStr(j+1), 120, $00FF00, 0.3, _CheckPoint[j].X+65*-0.3, _CheckPoint[j].Y+120*-0.3)
else
Players[i].WorldText(j, IntToStr(j+1), 120, $FF0000, 0.3, _CheckPoint[j].X+65*-0.3, _CheckPoint[j].Y+120*-0.3);
end;
if (Players[i].Alive) and (not _EditMode) and (not _FlightMode[i]) and (not _GodMode[i]) then
if (_CheckPointPassed[i] = Length(_CheckPoint)) and (Distance(_CheckPoint[0].X, _CheckPoint[0].Y, Players[i].X, Players[i].Y) <= 30) then begin
Inc(_LapsPassed[i], 1);
if _LapsPassed[i] = _Laps then begin
Timer := Now - _Timer[i];
{$IFDEF RUN_MODE_DEBUG}
Players[i].WriteConsole('Respawn Ping: '+IntToStr(_PingRespawn[i])+', Finish Ping: '+IntToStr(Players[i].Ping), $FF0000);
{$ENDIF}
end else
_CheckPointPassed[i] := 1;
end;
end else
if length(_CheckPoint) = 1 then
if _CheckPointPassed[i] = 1 then
Players[i].WorldText(0, '1', 120, $00FF00, 0.3, _CheckPoint[0].X+65*-0.3, _CheckPoint[0].Y+120*-0.3)
else
Players[i].WorldText(0, '1', 120, $FF0000, 0.3, _CheckPoint[0].X+65*-0.3, _CheckPoint[0].Y+120*-0.3);
if Timer > 0 then begin
if Not DB_Query(DB_ID, 'SELECT Name FROM Accounts WHERE Name = '''+EscapeApostrophe(Players[i].Name)+''' LIMIT 1;') then
WriteLn('RunModeError23: '+DB_Error)
else begin
if DB_NextRow(DB_ID) then begin //If account was found
TempTime := MapBestTime(Game.CurrentMap);
if TempTime = -1 then begin
Players.WriteConsole('[1] First score by '+Players[i].Name+': '+ShowTime(Timer), $FFD700);
if _LoggedIn[i] then begin
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
if Not DB_Update(DB_ID, 'INSERT INTO Scores(Account, Map, Date, Time) VALUES('''+EscapeApostrophe(Players[i].Name)+''', '''+EscapeApostrophe(Game.CurrentMap)+''', '+FloatToStr(Now)+', '+FloatToStr(Timer)+');') then //Add score
WriteLn('RunModeError24: '+DB_Error)
else begin
if Not DB_Query(DB_ID, 'SELECT last_insert_rowid();') then
WriteLn('RunModeError25: '+DB_Error)
else begin
DB_NextRow(DB_ID);
if Not DB_Update(DB_ID, 'CREATE TABLE '''+DB_GetString(DB_ID, 0)+'''(Id INTEGER PRIMARY KEY, PosX Double, PosY Double);') then begin
WriteLn('RunModeError26: '+DB_Error);
Players.WriteConsole('RunModeError27: '+DB_Error, $FF0000);
end else
begin
for j := 0 to High(_Record[i]) do
if Not DB_Update(DB_ID, 'INSERT INTO '''+DB_GetString(DB_ID, 0)+'''(PosX, PosY) VALUES('+FloatToStr(_Record[i][j].X)+', '+FloatToStr(_Record[i][j].Y)+');') then
WriteLn('RunModeError28: '+DB_Error);
end;
end;
end;
DB_Update(DB_ID, 'COMMIT;');
end else
Players.WriteConsole('Player '+Players[i].Name+' isn''t logged in - score wasn''t recorded', COLOR_1);
end else
begin
TempTime2 := PlayerBestTime(Players[i].Name, Game.CurrentMap);
if TempTime2 = -1 then begin
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
if Not DB_Update(DB_ID, 'INSERT INTO Scores(Account, Map, Date, Time) VALUES('''+EscapeApostrophe(Players[i].Name)+''', '''+EscapeApostrophe(Game.CurrentMap)+''', '+FloatToStr(Now)+', '+FloatToStr(Timer)+');') then //Add score
WriteLn('RunModeError29: '+DB_Error)
else begin
if Not DB_Query(DB_ID, 'SELECT last_insert_rowid();') then
WriteLn('RunModeError30: '+DB_Error)
else begin
DB_NextRow(DB_ID);
if Not DB_Update(DB_ID, 'CREATE TABLE '''+DB_GetString(DB_ID, 0)+'''(Id INTEGER PRIMARY KEY, PosX Double, PosY Double);') then begin
WriteLn('RunModeError31: '+DB_Error);
Players.WriteConsole('RunModeError32: '+DB_Error, $FF0000);
end else
begin
for j := 0 to High(_Record[i]) do
if Not DB_Update(DB_ID, 'INSERT INTO '''+DB_GetString(DB_ID, 0)+'''(PosX, PosY) VALUES('+FloatToStr(_Record[i][j].X)+', '+FloatToStr(_Record[i][j].Y)+');') then
WriteLn('RunModeError33: '+DB_Error);
end;
end;
end;
if Not DB_Query(DB_ID, 'SELECT Account FROM Scores WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' ORDER BY Time, Date;') then //Find position
WriteLn('RunModeError34: '+DB_Error)
else
While DB_NextRow(DB_ID) Do begin
Inc(PosCounter, 1);
if Players[i].Name = String(DB_GetString(DB_ID, 0)) then
break;
end;
if PosCounter = 1 then
Players.WriteConsole('[1] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: -'+ShowTime(Timer - TempTime), $FFD700);
if PosCounter = 2 then
Players.WriteConsole('[2] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: +'+ShowTime(Timer - TempTime), $C0C0C0);
if PosCounter = 3 then
Players.WriteConsole('[3] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: +'+ShowTime(Timer - TempTime), $F4A460);
if PosCounter > 3 then
Players.WriteConsole('['+IntToStr(PosCounter)+'] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: +'+ShowTime(Timer - TempTime), COLOR_1);
if _LoggedIn[i] then
DB_Update(DB_ID, 'COMMIT;')
else begin
DB_FinishQuery(DB_ID);
DB_Update(DB_ID, 'ROLLBACK;');
Players.WriteConsole('Player '+Players[i].Name+' isn''t logged in - score wasn''t recorded', COLOR_1);
end;
end else
if Timer >= TempTime2 then
Players.WriteConsole(ShowTime(Timer)+', Time was slower than '+Players[i].Name+'''s best by: '+ShowTime(Timer - TempTime2), COLOR_1)
else begin
DB_FinishQuery(DB_ID);
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
if Not DB_Update(DB_ID, 'DROP TABLE '''+_ScoreId+''';') then
WriteLn('RunModeError35: '+DB_Error);
if Not DB_Update(DB_ID, 'DELETE FROM Scores WHERE Account = '''+EscapeApostrophe(Players[i].Name)+''' AND Map = '''+EscapeApostrophe(Game.CurrentMap)+''';') then //Del score
WriteLn('RunModeError36: '+DB_Error);
if Not DB_Update(DB_ID, 'INSERT INTO Scores(Account, Map, Date, Time) VALUES('''+EscapeApostrophe(Players[i].Name)+''', '''+EscapeApostrophe(Game.CurrentMap)+''', '+FloatToStr(Now)+', '+FloatToStr(Timer)+');') then //Add score
WriteLn('RunModeError37: '+DB_Error)
else begin
if Not DB_Query(DB_ID, 'SELECT last_insert_rowid();') then
WriteLn('RunModeError38: '+DB_Error)
else begin
DB_NextRow(DB_ID);
if Not DB_Update(DB_ID, 'CREATE TABLE '''+DB_GetString(DB_ID, 0)+'''(Id INTEGER PRIMARY KEY, PosX Double, PosY Double);') then begin
WriteLn('RunModeError39: '+DB_Error);
Players.WriteConsole('RunModeError40: '+DB_Error, $FF0000);
end else
begin
for j := 0 to High(_Record[i]) do
if Not DB_Update(DB_ID, 'INSERT INTO '''+DB_GetString(DB_ID, 0)+'''(PosX, PosY) VALUES('+FloatToStr(_Record[i][j].X)+', '+FloatToStr(_Record[i][j].Y)+');') then
WriteLn('RunModeError41: '+DB_Error);
end;
end;
end;
if Not DB_Query(DB_ID, 'SELECT Account FROM Scores WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' ORDER BY Time, Date;') then //Find position
WriteLn('RunModeError42: '+DB_Error)
else
While DB_NextRow(DB_ID) Do begin
Inc(PosCounter, 1);
if Players[i].Name = String(DB_GetString(DB_ID, 0)) then
break;
end;
if PosCounter = 1 then
Players.WriteConsole('[1] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: -'+ShowTime(Timer - TempTime2)+', Map''s best time: -'+ShowTime(Timer - TempTime), $FFD700);
if PosCounter = 2 then
Players.WriteConsole('[2] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: -'+ShowTime(Timer - TempTime2)+', Map''s best time: +'+ShowTime(Timer - TempTime), $C0C0C0);
if PosCounter = 3 then
Players.WriteConsole('[3] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: -'+ShowTime(Timer - TempTime2)+', Map''s best time: +'+ShowTime(Timer - TempTime), $F4A460);
if PosCounter > 3 then
Players.WriteConsole('['+IntToStr(PosCounter)+'] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: -'+ShowTime(Timer - TempTime2)+', Map''s best time: +'+ShowTime(Timer - TempTime), COLOR_1);
if _LoggedIn[i] then
DB_Update(DB_ID, 'COMMIT;')
else begin
DB_FinishQuery(DB_ID);
DB_Update(DB_ID, 'ROLLBACK;');
Players.WriteConsole('Player '+Players[i].Name+' isn''t logged in - score wasn''t recorded', COLOR_1);
end;
end;
end;
end else
begin //If account wasn't found
TempTime := MapBestTime(Game.CurrentMap);
if TempTime = -1 then
Players.WriteConsole('[1] First score by '+Players[i].Name+': '+ShowTime(Timer), $FFD700)
else begin
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
if Not DB_Update(DB_ID, 'INSERT INTO Scores(Account, Map, Date, Time) VALUES('''+EscapeApostrophe(Players[i].Name)+''', '''+EscapeApostrophe(Game.CurrentMap)+''', '+FloatToStr(Now)+', '+FloatToStr(Timer)+');') then //Add score
WriteLn('RunModeError43: '+DB_Error);
if Not DB_Query(DB_ID, 'SELECT Account FROM Scores WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' ORDER BY Time, Date;') then //Find position
WriteLn('RunModeError44: '+DB_Error)
else
While DB_NextRow(DB_ID) Do begin
Inc(PosCounter, 1);
if Players[i].Name = String(DB_GetString(DB_ID, 0)) then
break;
end;
if PosCounter = 1 then
Players.WriteConsole('[1] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: -'+ShowTime(Timer - TempTime), $FFD700);
if PosCounter = 2 then
Players.WriteConsole('[2] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: +'+ShowTime(Timer - TempTime), $C0C0C0);
if PosCounter = 3 then
Players.WriteConsole('[3] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: +'+ShowTime(Timer - TempTime), $F4A460);
if PosCounter > 3 then
Players.WriteConsole('['+IntToStr(PosCounter)+'] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: +'+ShowTime(Timer - TempTime), COLOR_1);
DB_FinishQuery(DB_ID);
DB_Update(DB_ID, 'ROLLBACK;');
end;
Players.WriteConsole('Unregistered nickname: '+Players[i].Name+' - score wasn''t recorded', COLOR_1);
end;
DB_FinishQuery(DB_ID);
end;
Players[i].Damage(i, 150);
Timer := 0;
end;
if _FlightMode[i] then begin
Players[i].SetVelocity(0, 0);
if Players[i].KeyJetpack then begin
Players[i].Move(Players[i].MouseAimX, Players[i].MouseAimY);
_LastPosX[i] := Players[i].MouseAimX;
_LastPosY[i] := Players[i].MouseAimY;
end else
Players[i].Move(_LastPosX[i], _LastPosY[i]);
end;
if Ticks mod 3 = 0 then
if (Players[i].KeyReload) and (_RKill[i]) and (not _EditMode) and (not _FlightMode[i]) and (not _GodMode[i]) then
if length(_CheckPoint) <= 1 then
Players[i].BigText(5, 'Checkpoints error', 120, $FF0000, 0.1, 320, 300)
else
Players[i].Damage(i, 150);
//1 SEC INTERVAL LOOP
if Ticks mod 60 = 0 then begin
if _FlightMode[i] then
Players[i].BigText(9, 'Flight', 120, COLOR_1, 0.1, 320, 150);
if _GodMode[i] then
Players[i].BigText(8, 'God', 120, COLOR_1, 0.1, 320, 180);
if _EditMode then
Players[i].BigText(7, 'EditMode', 120, COLOR_1, 0.1, 320, 210);
if (not _LoggedIn[i]) and (Players[i].Team <> 5) then
Players[i].BigText(4, 'Not logged in', 120, $FF0000, 0.1, 320, 240);
if (Players[i].Alive) and (not _EditMode) and (not _FlightMode[i]) and (not _GodMode[i]) then
if _CheckPointPassed[i] = 0 then
Players[i].BigText(6, 'Press "Reload Key" to start', 120, COLOR_1, 0.1, 320, 270);
end;
//END OF 1 SEC INTERVAL LOOP
end;
if Ticks mod(3600*3) = 0 then
Players.WriteConsole('!help - All you want to know, our Discord: https://discord.gg/Jr8CFQu', Random(0, 16777215+1));
if Ticks mod(3600*40) = 0 then
Players.WriteConsole('Official Soldat Discord: https://discord.gg/v9t82C9', Random(0, 16777215+1));
if Ticks mod(3600*12) = 0 then begin
Players.WriteConsole('Want to optimize your run & improve your time? Type !rme for more info', $c53159);
end;
if Ticks mod(216000*USED_IP_TIME) = 0 then begin
_UsedIP.Clear;
{$IFDEF RUN_MODE_DEBUG}
WriteLn('RunMode: _UsedIP.Clear');
{$ENDIF}
end;
end;
function OnAdminCommand(Player: TActivePlayer; Command: string): boolean;
var
i: Integer;
StrToIntConv, StrToIntConv2: Integer;
TimeStart: TDateTime;
Ini: TIniFile;
TempStrL: TStringList;
TempX, TempY: Single;
begin
Result := False;
if Command = '/recountallstats' then begin
Players.WriteConsole('Recounting medals...', COLOR_1);
TimeStart := Now;
RecountAllStats;
Players.WriteConsole('Done in '+ShowTime(Now - TimeStart), COLOR_1);
Players.WriteConsole('Generating elite list...', COLOR_2);
TimeStart := Now;
GenerateEliteList;
Players.WriteConsole('Done in '+ShowTime(Now - TimeStart), COLOR_2);
end;
if Player <> nil then begin//In-Game Admin
if Command = '/admcmds' then begin
Player.WriteConsole('Commands for admins 1/2:', $FFFF00);
Player.WriteConsole('RunMode:', COLOR_1);
Player.WriteConsole('/recountallstats - Recounts all medals and creates new elite list', COLOR_2);
Player.WriteConsole('/delacc <name> - Deletes certain account and it''s replays', COLOR_2);
Player.WriteConsole('/delid <id> - Deletes certain score and it''s replay', COLOR_2);
Player.WriteConsole('/emode - Enable/Disable editing mode for checkpoints', COLOR_2);
Player.WriteConsole('/fmode - Enable/Disable flight mode (Enables god mode)', COLOR_2);
Player.WriteConsole('/gmode - Enable/Disable god mode (Disables flight mode)', COLOR_2);
Player.WriteConsole('/swap <cp1> <cp2> - Swaps checkpoints'' position', COLOR_2);
Player.WriteConsole('/cpadd - Creates new checkpoint', COLOR_2);
Player.WriteConsole('/cpdel - Deletes last checkpoint', COLOR_2);
Player.WriteConsole('/cplaps <amount> - Sets amount of laps', COLOR_2);
Player.WriteConsole('/cpsave - Saves current checkpoints'' setting', COLOR_2);
Player.WriteConsole('/replay <id> - Replays certain score', COLOR_2);
Player.WriteConsole('/replay2 <id> <id> - Replays two scores at the same time', COLOR_2);
Player.WriteConsole('/replaystop - Stops all replays', COLOR_2);
Player.WriteConsole('PlayersDB:', COLOR_1);
Player.WriteConsole('/checkid <playerid(1-32)> - Check all nicks and entries for certain hwid', COLOR_2);
Player.WriteConsole('/checknick <nick> - Check all hwids and entries for certain nick', COLOR_2);
Player.WriteConsole('/checkhw <hwid> - Check all nicks and entries for certain hwid', COLOR_2);
Player.WriteConsole('/admcmds2 - Commands for admins 2/2', $FFFF00);
end;
if Command = '/admcmds2' then begin
Player.WriteConsole('Commands for admins 2/2:', $FFFF00);
Player.WriteConsole('MapListReader:', COLOR_1);
Player.WriteConsole('/createsortedmaplist - Create sorted MapList if current one is outdated', COLOR_2);
Player.WriteConsole('/addmap <map name> - Add map to MapList (Default Soldat command)', COLOR_2);
Player.WriteConsole('/delmap <map name> - Remove map from MapList (Default Soldat command)', COLOR_2);
Player.WriteConsole('MapListRandomizer:', COLOR_1);
Player.WriteConsole('/mlrand - Randomizes MapList', COLOR_2);
end;
if (Copy(Command, 1, 8) = '/delacc ') and (Copy(Command, 9, Length(Command)) <> nil) then
if DB_Query(DB_ID, 'SELECT Name FROM Accounts WHERE Name = '''+EscapeApostrophe(Copy(Command, 9, Length(Command)))+''' LIMIT 1;') then begin
if DB_NextRow(DB_ID) then begin
for i := 1 to 32 do
if (Players[i].Active) and (Players[i].Name = Copy(Command, 9, Length(Command))) then
_LoggedIn[i] := FALSE;
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
TempStrL := File.CreateStringList;
if Not DB_Query(DB_ID, 'SELECT Id FROM Scores WHERE Account = '''+EscapeApostrophe(Copy(Command, 9, Length(Command)))+''';') then
Player.WriteConsole('RunModeError45: '+DB_Error, COLOR_1)
else
While DB_NextRow(DB_ID) Do
TempStrL.Append(DB_GetString(DB_ID, 0));
DB_FinishQuery(DB_ID);
for i := 0 to TempStrL.Count-1 do
if Not DB_Update(DB_ID, 'DROP TABLE '''+TempStrL[i]+''';') then
Player.WriteConsole('RunModeError46: '+DB_Error, COLOR_1);
TempStrL.Free;
if Not DB_Update(DB_ID, 'DELETE FROM Scores WHERE Account = '''+EscapeApostrophe(Copy(Command, 9, Length(Command)))+''';') then
Player.WriteConsole('RunModeError47: '+DB_Error, COLOR_1);
if Not DB_Update(DB_ID, 'DELETE FROM Accounts WHERE Name = '''+EscapeApostrophe(Copy(Command, 9, Length(Command)))+''';') then
Player.WriteConsole('RunModeError48: '+DB_Error, COLOR_1);
DB_Update(DB_ID, 'COMMIT;');
Player.WriteConsole('Account "'+Copy(Command, 9, Length(Command))+'" has been deleted', COLOR_1);
end else
Player.WriteConsole('Account "'+Copy(Command, 9, Length(Command))+'" doesn''t exists', COLOR_1);
DB_FinishQuery(DB_ID);
end else
Player.WriteConsole('RunModeError49: '+DB_Error, COLOR_1);
if (Copy(Command, 1, 7) = '/delid ') and (Copy(Command, 8, Length(Command)) <> nil) then begin
if Not DB_Update(DB_ID, 'DELETE FROM Scores WHERE Id = '''+EscapeApostrophe(Copy(Command, 8, Length(Command)))+''';') then
Player.WriteConsole('RunModeError50: '+DB_Error, COLOR_1)
else
Player.WriteConsole('Score with Id '+Copy(Command, 8, Length(Command))+' has been deleted', COLOR_1);
if Not DB_Update(DB_ID, 'DROP TABLE '''+EscapeApostrophe(Copy(Command, 8, Length(Command)))+''';') then
Player.WriteConsole('RunModeError51: '+DB_Error, COLOR_1)
else
Player.WriteConsole('Replay with Id '+Copy(Command, 8, Length(Command))+' has been deleted', COLOR_1);
end;
if Command = '/fmode' then begin
_LapsPassed[Player.ID] := 0;
_CheckPointPassed[Player.ID] := 0;
SetLength(_Record[Player.ID], 0);
if _FlightMode[Player.ID] then begin
_FlightMode[Player.ID] := False;
Player.WriteConsole('Flight mode has been disabled', COLOR_1);
end else
begin
_GodMode[Player.ID] := True;
_FlightMode[Player.ID] := True;
_LastPosX[Player.ID] := Player.X;
_LastPosY[Player.ID] := Player.Y;
Player.WriteConsole('Flight mode has been enabled', COLOR_1);
end;
end;
if Command = '/gmode' then begin
_LapsPassed[Player.ID] := 0;
_CheckPointPassed[Player.ID] := 0;
if _GodMode[Player.ID] then begin
_FlightMode[Player.ID] := False;
_GodMode[Player.ID] := False;
Player.WriteConsole('God mode has been disabled', COLOR_1);
end else
begin
_GodMode[Player.ID] := True;
Player.WriteConsole('God mode has been enabled', COLOR_1);
end;
end;
if Command = '/emode' then begin
for i := 1 to 32 do begin
_LapsPassed[i] := 0;
_CheckPointPassed[i] := 0;
end;
if _EditMode then begin
_EditMode := False;
Players.WriteConsole('Editing mode has been disabled', COLOR_1);
end else
begin
_EditMode := True;
Players.WriteConsole('Editing mode has been enabled', COLOR_1);
end;
end;
if (Copy(Command, 1, 6) = '/swap ') or (Command = '/swap') then
if Copy(Command, 7, length(Command)) <> nil then begin
Try
StrToIntConv := StrToInt(GetPiece(Command, ' ', 1));
StrToIntConv2 := StrToInt(GetPiece(Command, ' ', 2));
if (StrToIntConv <= length(_CheckPoint)) and (StrToIntConv2 <= length(_CheckPoint)) and (StrToIntConv > 0) and (StrToIntConv2 > 0) then begin
TempX := _CheckPoint[StrToIntConv-1].X;
TempY := _CheckPoint[StrToIntConv-1].Y;
_CheckPoint[StrToIntConv-1].X := _CheckPoint[StrToIntConv2-1].X;
_CheckPoint[StrToIntConv-1].Y := _CheckPoint[StrToIntConv2-1].Y;
_CheckPoint[StrToIntConv2-1].X := TempX;
_CheckPoint[StrToIntConv2-1].Y := TempY;
Player.WriteConsole('Checkpoints "'+GetPiece(Command, ' ', 1)+'" and "'+GetPiece(Command, ' ', 2)+'" have been swapped', COLOR_1);
end else
Player.WriteConsole('Out of bounds', COLOR_1);
Except
Player.WriteConsole('Invalid parameters', COLOR_1);
end;
end else
Player.WriteConsole('Lack of parameters for command "/swap <cp1> <cp2>"', COLOR_2);
if Command = '/cpadd' then begin
for i := 1 to 32 do begin
_LapsPassed[i] := 0;
_CheckPointPassed[i] := 0;
end;
SetLength(_CheckPoint, Length(_CheckPoint)+1);
_CheckPoint[High(_CheckPoint)].X := Player.X;
_CheckPoint[High(_CheckPoint)].Y := Player.Y;
end;
if Command = '/cpdel' then
if High(_CheckPoint) <> -1 then begin
for i := 1 to 32 do begin
_LapsPassed[i] := 0;
_CheckPointPassed[i] := 0;
end;
SetLength(_CheckPoint, High(_CheckPoint));
end else
Player.WriteConsole('All checkpoints has been deleted', $FF0000);
if (Copy(Command, 1, 8) = '/cplaps ') and (Length(Command)>8) then begin
Delete(Command, 1, 8);
try
StrToIntConv := StrToInt(Command);
except
Player.WriteConsole('Invalid integer', $FF0000);
exit;
end;
for i := 1 to 32 do begin
_LapsPassed[i] := 0;
_CheckPointPassed[i] := 0;
end;
_Laps := StrToIntConv;
end;
if Command = '/cpsave' then
if length(_CheckPoint) <= 1 then
Player.WriteConsole('Not enough checkpoints', $FF0000)
else begin
Ini := File.CreateINI('~/maps_config.ini');
Ini.CaseSensitive := True;
if Ini.SectionExists(Game.CurrentMap) then
Ini.EraseSection(Game.CurrentMap);
for i := 0 to High(_CheckPoint) do begin
Ini.WriteFloat(Game.CurrentMap, IntToStr(i)+'X', _CheckPoint[i].X);
Ini.WriteFloat(Game.CurrentMap, IntToStr(i)+'Y', _CheckPoint[i].Y);
end;
Ini.WriteInteger(Game.CurrentMap, 'Laps', _Laps);
Ini.Free;
Player.WriteConsole('Checkpoints'' setting saved', $00FF00);
end;
if (Copy(Command, 1, 8) = '/replay ') and (Length(Command)>8) then begin
Delete(Command, 1, 8);
Players.WriteConsole('Loading replay '+Command+'...', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT PosX, PosY FROM '''+EscapeApostrophe(Command)+''';') then
Players.WriteConsole('RunModeError52: '+DB_Error, COLOR_1)
else begin
SetLength(_Replay, 0);
_ReplayTime := 0;
While DB_NextRow(DB_ID) Do begin
SetLength(_Replay, Length(_Replay)+1);
_Replay[High(_Replay)].X := DB_GetDouble(DB_ID, 0);
_Replay[High(_Replay)].Y := DB_GetDouble(DB_ID, 1);
end;
if Length(_Replay) > 0 then begin
DB_FinishQuery(DB_ID);
if Not DB_Query(DB_ID, 'SELECT * FROM (SELECT 1+(SELECT count(*) FROM Scores a WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' AND (a.Time < b.Time OR (a.Time = b.Time AND a.Date < b.Date))) AS Position, Time, Date, Id, Account FROM Scores b WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''') WHERE Id = '''+EscapeApostrophe(Command)+''' LIMIT 1;') then
WriteLn('RunModeError112: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then begin
Players.WriteConsole('Score for current map with ID '+Command+' not found', COLOR_2);