Advertisement
Guest User

Run Mode 0.0.4

a guest
Feb 5th, 2017
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 39.19 KB | None | 0 0
  1. unit Run;
  2.  
  3. interface
  4.  
  5. implementation
  6. var Decl: byte;
  7.  
  8. const
  9.     DeffaultMoveSpeed = 0.30;   //> is faster < is slow
  10.     MouseMovementAccuracy = 0.001;  // def 0.001
  11.     MovementOffsetSpeedAdd = 0.0073; //0.0004 deffault
  12.  
  13.     CursorMaxSearch     = 125;
  14.  
  15.     DeffaultCheckPointRange = 50;
  16.     MinimalCheckPointRange = 40;
  17.    
  18.     BigTextLayer = 2;
  19.  
  20. type
  21.     TCheckPoints = record
  22.             Check, RunerActive, StartFinish: boolean;
  23.             CheckPointsId, Typ, lap:integer;
  24.             Pos: array[1..2] of single;
  25.             Range: single;
  26.             LastPoss: single;
  27.             TimeToActive: array[1..7] of integer;
  28.             PlayerPos: array[1..2] of single;
  29.             EditMode: array[1..32] of boolean;
  30. end;
  31.  
  32. type
  33.     TPlayerStat = record
  34.         RunMode:boolean;
  35.         CheckPointGet,Lap:integer;
  36.         Timer:int64;
  37. end;
  38.  
  39. var
  40.     MapCheckPoints: TStringList;
  41.     PlInfo: array[1..32] of TPlayerStat;
  42.     CheckPoint: TCheckPoints;
  43.     SpeedMovementText: single;
  44.     bot:boolean; botprev: TStringList; xio:int64;
  45.    
  46. procedure SaveCheckPoint();
  47. begin
  48.     if (CheckPoint.Check) then begin
  49.         if (CheckPoint.CheckPointsID>MapCheckPoints.Count) then begin
  50.             MapCheckPoints.Append('X'+floattostr(CheckPoint.Pos[1])+'Y'+floattostr(CheckPoint.Pos[2])+'R'+floattostr(CheckPoint.Range)+'T'+inttostr(CheckPoint.Typ)+'L'+inttostr(CheckPoint.Lap));
  51.             MapCheckPoints.SaveToFile(Script.Dir+'data/mapsdata/'+Game.CurrentMap);
  52.             CheckPoint.Check:=false;
  53.         end else
  54.         begin
  55.             MapCheckPoints.Insert(CheckPoint.CheckPointsID,'X'+floattostr(CheckPoint.Pos[1])+'Y'+floattostr(CheckPoint.Pos[2])+'R'+floattostr(CheckPoint.Range)+'T'+inttostr(CheckPoint.Typ)+'L'+inttostr(CheckPoint.Lap));
  56.             MapCheckPoints.Delete(CheckPoint.CheckPointsID+1);
  57.             MapCheckPoints.SaveToFile(Script.Dir+'data/mapsdata/'+Game.CurrentMap);
  58.             CheckPoint.Check:=false;
  59.         end;
  60.     end;
  61. end;
  62.  
  63. procedure SaveSetLap();
  64. var TempX,TempY,TempRange: single; temptyp:byte;
  65. begin
  66.     TempX:=strtofloat(GetPiece(GetPiece(MapCheckPoints[0],'X',1),'Y',0)); TempY:=strtofloat(GetPiece(GetPiece(MapCheckPoints[0],'Y',1),'R',0)); TempRange:=strtofloat(GetPiece(GetPiece(MapCheckPoints[0],'R',1),'T',0)); temptyp:=strtoint(GetPiece(GetPiece(MapCheckPoints[0],'T',1),'L',0));
  67.     MapCheckPoints.Insert(0,'X'+floattostr(TempX)+'Y'+floattostr(TempY)+'R'+floattostr(TempRange)+'T'+inttostr(temptyp)+'L'+inttostr(CheckPoint.Lap));
  68.     MapCheckPoints.Delete(1);
  69.     MapCheckPoints.SaveToFile(Script.Dir+'data/mapsdata/'+Game.CurrentMap);
  70. end;
  71.  
  72. procedure SaveSetType(i,typett:integer);
  73. var TempX,TempY,TempRange: single; temptyp:byte;
  74. begin
  75.     TempX:=strtofloat(GetPiece(GetPiece(MapCheckPoints[i],'X',1),'Y',0)); TempY:=strtofloat(GetPiece(GetPiece(MapCheckPoints[i],'Y',1),'R',0)); TempRange:=strtofloat(GetPiece(GetPiece(MapCheckPoints[i],'R',1),'T',0)); temptyp:=strtoint(GetPiece(GetPiece(MapCheckPoints[i],'T',1),'L',0));
  76.     MapCheckPoints.Insert(i,'X'+floattostr(TempX)+'Y'+floattostr(TempY)+'R'+floattostr(TempRange)+'T'+inttostr(typett)+'L'+inttostr(CheckPoint.Lap));
  77.     MapCheckPoints.Delete(i+1);
  78.     MapCheckPoints.SaveToFile(Script.Dir+'data/mapsdata/'+Game.CurrentMap);
  79. end;
  80.  
  81. function FindCheckPoint(ID: byte; MaxDistance: integer): integer;
  82. var i: integer; TempX, TempY, X2, Y2, CursorMaxDist, NearestDistCursor, MaxDist, Dist: single;
  83. begin
  84.     MaxDist:=MaxDistance*MaxDistance;   CursorMaxDist:=CursorMaxSearch*CursorMaxSearch;
  85.     Result:=-1;
  86.     if (MapCheckPoints.Count=0) then exit;
  87.     for i := 0 to MapCheckPoints.Count-1 do begin
  88.         TempX:=strtofloat(GetPiece(GetPiece(MapCheckPoints[i],'X',1),'Y',0));
  89.         TempY:=strtofloat(GetPiece(GetPiece(MapCheckPoints[i],'Y',1),'R',0));
  90.         X2:=TempX;  Y2:=TempY;
  91.  
  92.         X2:=X2-Players[ID].MouseAimX;   Y2:=Y2-Players[ID].MouseAimY;   NearestDistCursor:=X2*X2+Y2*Y2;
  93.         X2:=TempX;  Y2:=TempY;
  94.         X2:=X2-Players[ID].X;   Y2:=Y2-Players[ID].Y;   Dist:=X2*X2+Y2*Y2;
  95.  
  96.         if (NearestDistCursor<CursorMaxDist) and (Dist<MaxDist) then begin
  97.             Result:=i;
  98.             CursorMaxDist:=NearestDistCursor;
  99.         end;
  100.     end;
  101. end;
  102.  
  103. procedure OffAndReset(ID:byte);
  104. begin
  105.     CheckPoint.RunerActive:=false;
  106.     PlInfo[ID].RunMode:=false;
  107.     PlInfo[ID].CheckPointGet:=0;
  108.     PlInfo[ID].Timer:=0;
  109.     PlInfo[ID].Lap:=1;
  110.     Players[ID].Team:=5;
  111. end;
  112.  
  113. function Commands(Player: TActivePlayer; Text: string): Boolean;
  114. var selectid,b:integer; TempX,TempY,TempRange:single; i:byte;
  115. begin
  116.     if (Text='/playbot') then begin
  117.         if (File.Exists(Script.Dir+'data/mapsdata/aplos')) then begin
  118.             xio:=0;
  119.             botprev := File.CreateStringListFromFile(Script.Dir+'data/mapsdata/aplos');
  120.             if (bot) then bot:=false else bot:=true;
  121.         end;
  122.     end;
  123.     if (Text='/play') then begin
  124.         if (CheckPoint.RunerActive) then begin
  125.             for b := 1 to 32 do if (Players[b].Active) and (PlInfo[b].RunMode) then begin
  126.                 if (Player.ID=b) then begin
  127.                     OffAndReset(Player.ID);
  128.                     Players.WriteConsole(Player.Name+' stoped runs!',$FFBB);
  129.                 end else Player.WriteConsole('Now play: '+Players[b].Name+', plese wait for end his game.',$FFBB);
  130.             end;
  131.         end else
  132.         begin
  133.             if (MapCheckPoints.Count>2) then begin
  134.                 for i := 1 to 32 do if (Players[i].Active) and (i<>Player.ID) and (Players[i].Team<>5) then Players[i].Team:=5;
  135.                 if not (PlInfo[Player.ID].RunMode) then begin
  136.                     PlInfo[Player.ID].RunMode:=true;    CheckPoint.RunerActive:=true; File.Delete(Script.Dir+'data/mapsdata/aplos');
  137.                     Players[Player.ID].Team:=4;
  138.                     PlInfo[Player.ID].CheckPointGet:=0;
  139.                     PlInfo[Player.ID].Timer:=0;
  140.                     PlInfo[Player.ID].Lap:=1;
  141.                     Player.Move(strtofloat(GetPiece(GetPiece(MapCheckPoints[0],'X',1),'Y',0)),strtofloat(GetPiece(GetPiece(MapCheckPoints[0],'Y',1),'R',0)));
  142.                     Players.WriteConsole(Player.Name+' its run begins!',$FFBB);
  143.                 end;
  144.             end else Player.WriteConsole('This map has too few checkpoints, minimal must be 3.',$FFBB);
  145.         end;
  146.     end;
  147.     if (Player.IsAdmin) then begin
  148.         if (Text='/editmodehelp') then begin
  149.             Player.WriteConsole('Movement keys :        Default        : Description',$FFBB);
  150.             Player.WriteConsole('Movement key  :        A,W,S,D        : Move Checkpoint',$FFBB);
  151.             Player.WriteConsole('Jet key       : Right Mouse & Move <> : Press and move left or right to set',$FFBB);
  152.             Player.WriteConsole('------------- : --------------------- : movement speed /setcheckpointspeed',$FFBB);
  153.             Player.WriteConsole('Reload ket    :           R           : Press to save all settings checkpoint /savecheckpoint',$FFBB);
  154.             Player.WriteConsole('Shooting key  : Left M. on checkpoint : Press to start edit checkpoint /selectcheckpoint',$FFBB);
  155.             Player.WriteConsole('------------- : no editing checkpoint : -----------',$FFBB);
  156.             Player.WriteConsole('Throw key     : F checkpoing is edit  : Cancel edit /canceleditcheckpoint',$FFBB);
  157.             Player.WriteConsole('Throw key     : F checkpoint non edit : Press to delete checkpoint edit /deletecheckpoint',$FFBB);
  158.             Player.WriteConsole('------------- :  mouse on checkpoint  : -----------',$FFBB);
  159.             Player.WriteConsole('Change Weap   :          q            : Press to start create checkpoint',$FFBB);
  160.             Player.WriteConsole('Shooting key  : If editing checkpoint : Press to set range',$FFBB);
  161.             Player.WriteConsole('------------- :        Left M.        : -----------',$FFBB);
  162.         end;
  163.         if (Text='/canceleditcheckpoint') then begin
  164.             CheckPoint.Check:=false;
  165.             Player.WriteConsole('Interrupt, editing or creating checkpoint.',$FFBB);
  166.         end;
  167.         if (Text='/helpcreate') then begin
  168.                 Player.WriteConsole('Use move keys to move checkpoint.',$FFBB);
  169.                 Player.WriteConsole('Use /setcheckpointspeed <num:1,2,3 or 1.123> to change speed move checkpoint.',$FFBB);
  170.                 Player.WriteConsole('Use /checkpointrange <num:1,2,3 or 1.123> to change range checkpoint.',$FFBB);
  171.                 Player.WriteConsole('Use /setrunlaps <num:1,2,3> to change run laps.',$FFBB);
  172.                 Player.WriteConsole('Use /savecheckpoint to accept and save checkpoint.',$FFBB);
  173.                 Player.WriteConsole('Use /selectcheckpoint <num> to edit checkpoint.',$FFBB);
  174.                 Player.WriteConsole('Use /deletecheckpoint <num> to delete checkpoint.',$FFBB);
  175.                 Player.WriteConsole('Use /editmode to ON useful checkpoint editor.',$FFBB);
  176.         end;
  177.         if (Text='/createcheckpoint') then begin
  178.             if (CheckPoint.Check=false) then begin
  179.                 CheckPoint.Check:=true;
  180.                 CheckPoint.CheckPointsID:=MapCheckPoints.Count+1;
  181.                 CheckPoint.Range:=DeffaultCheckPointRange;
  182.                 CheckPoint.Typ:=2;
  183.                 CheckPoint.Pos[1]:=Player.X; CheckPoint.PlayerPos[1]:=Player.X;
  184.                 CheckPoint.Pos[2]:=Player.Y; CheckPoint.PlayerPos[2]:=Player.Y;
  185.                 Player.WriteConsole('You start create checkpoint: '+inttostr(CheckPoint.CheckPointsID),$FFBB);
  186.                 Player.WriteConsole('Use move keys to move checkpoint.',$FFBB);
  187.                 Player.WriteConsole('Use /setcheckpointspeed <num:1,2,3 or 1.123> to change speed move checkpoint.',$FFBB);
  188.                 Player.WriteConsole('Use /checkpointrange <num:1,2,3 or 1.123> to change range checkpoint.',$FFBB);
  189.                 Player.WriteConsole('Use /setrunlaps <num:1,2,3> to change run laps.',$FFBB);
  190.                 Player.WriteConsole('Use /savecheckpoint to accept and save checkpoint.',$FFBB);
  191.                 Player.WriteConsole('Use /selectcheckpoint <num> to edit checkpoint.',$FFBB);
  192.                 Player.WriteConsole('Use /deletecheckpoint <num> to delete checkpoint.',$FFBB);
  193.                 Player.WriteConsole('Use /editmode to ON useful checkpoint editor.',$FFBB);
  194.             end else CheckPoint.Check:=false;
  195.         end;
  196.         if (Text='/editmode') then begin
  197.             if (CheckPoint.EditMode[Player.ID]=false) then begin
  198.                 CheckPoint.EditMode[Player.ID]:=true;
  199.                 Player.WriteConsole('Edit mode is on!',$FFBB);
  200.                 Player.WriteConsole('Write /editmodehelp to see help how use.',$FFBB);
  201.             end else
  202.             begin
  203.                 CheckPoint.EditMode[Player.ID]:=false;
  204.                 Player.WriteConsole('Edit mode is off!',$FFBB);
  205.             end;
  206.         end;
  207.         if (Text='/savecheckpoint') then begin
  208.             SaveCheckPoint();
  209.             Player.WriteConsole('Save all settings checkpoint: '+inttostr(CheckPoint.CheckPointsID+1),$FFBB);
  210.         end;
  211.         if (Copy(Text,1,17)='/selectcheckpoint') then begin
  212.             selectid:=-1;
  213.             try
  214.                 delete(Text,1,17);
  215.                 selectid:=strtoint(text)-1;
  216.                 if (selectid>-1) then begin
  217.                     if (selectid<MapCheckPoints.Count) then begin
  218.                         CheckPoint.Check:=true;
  219.                         CheckPoint.CheckPointsID:=selectid;
  220.                         TempX:=strtofloat(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'X',1),'Y',0));
  221.                         TempY:=strtofloat(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'Y',1),'R',0));
  222.                         TempRange:=strtofloat(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'R',1),'T',0));
  223.                         CheckPoint.Typ:=strtoint(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'T',1),'L',0));
  224.                         CheckPoint.Pos[1]:=TempX; CheckPoint.PlayerPos[1]:=TempX;
  225.                         CheckPoint.Pos[2]:=TempY; CheckPoint.PlayerPos[2]:=TempY;
  226.                         CheckPoint.Range:=TempRange;
  227.                         Player.WriteConsole('Select checkpoint:'+text,$FFBB);
  228.                     end else Player.WriteConsole('Checkpoint id is too high. The highest id: '+inttostr(MapCheckPoints.Count),$FFBB);
  229.                 end else Player.WriteConsole('ID must be greater than 0.',$FFBB);
  230.             except
  231.                 Player.WriteConsole('An error occurred, please enter a valid number of checkpoint.',$FFBB);
  232.             end;
  233.         end;
  234.         if (Copy(Text,1,17)='/deletecheckpoint') then begin
  235.             if not (CheckPoint.Check) then begin
  236.                 selectid:=-1;
  237.                 try
  238.                     delete(Text,1,17);
  239.                     selectid:=strtoint(text)-1;
  240.                     if (selectid>-1) then begin
  241.                         if (selectid<MapCheckPoints.Count) then begin
  242.                             Player.WriteConsole('Remove checkpoint:'+text,$FFBB);
  243.                             if (selectid=0) and (GetPiece(GetPiece(MapCheckPoints[0],'T',1),'L',0)='4') then begin
  244.                                 Player.WriteConsole('We see that delete Start/Finish checkpoint. And see lap '+inttostr(CheckPoint.Lap)+', we set laps to 1 ;)',$FFBB);
  245.                                 CheckPoint.Lap:=1;
  246.                                 SaveSetLap();
  247.                             end;
  248.                             if (selectid=0) and (GetPiece(GetPiece(MapCheckPoints[0],'T',1),'L',0)='1') then begin
  249.                                 SaveSetType(MapCheckPoints.Count-1,2);
  250.                                 Player.WriteConsole('We detect you delete start checkpoint. We change finish checkpoint to normal.',$FFBB);
  251.                             end;
  252.                             if (selectid=MapCheckPoints.Count-1) and (GetPiece(GetPiece(MapCheckPoints[MapCheckPoints.Count-1],'T',1),'L',0)='3') then begin
  253.                                 SaveSetType(0,2);
  254.                                 Player.WriteConsole('We detect you delete finish checkpoint. We change start checkpoint to normal.',$FFBB);
  255.                             end;
  256.                             MapCheckPoints.Delete(selectid);
  257.                             MapCheckPoints.SaveToFile(Script.Dir+'data/mapsdata/'+Game.CurrentMap);
  258.                             for b := 0 to MapCheckPoints.Count+1 do Players.WorldText(b+1,'',70,$33CC00,0.0001,0,0);
  259.                         end else Player.WriteConsole('Checkpoint id is too high. The highest id: '+inttostr(MapCheckPoints.Count),$FFBB);
  260.                     end else Player.WriteConsole('ID must be greater than 0.',$FFBB);
  261.                 except
  262.                     Player.WriteConsole('An error occurred, please enter a valid number of checkpoint.',$FFBB);
  263.                 end;
  264.             end else Player.WriteConsole('You can not remove a checkpoint when creating or editing other checkpoint.',$FFBB);
  265.         end;
  266.         if (Copy(Text,1,16)='/checkpointrange') then begin
  267.             if (CheckPoint.Check) then begin
  268.                 try
  269.                     delete(Text,1,16);
  270.                     TempRange:=strtofloat(text);
  271.                     if (TempRange<MinimalCheckPointRange) then begin
  272.                         TempRange:=MinimalCheckPointRange;
  273.                         Player.WriteConsole('Value is higher than the minimum, I set to minimal: '+formatfloat('0.0000',MinimalCheckPointRange),$FFBB);
  274.                     end else Player.WriteConsole('Checkpoint range set to: '+formatfloat('0.0000',TempRange),$FFBB);
  275.                 except
  276.                     Player.WriteConsole('An error occurred, please enter a valid number (can be 123 etc or 1.1234). I set to default value: '+formatfloat('0.0000',DeffaultCheckPointRange),$FFBB);
  277.                     TempRange:=DeffaultCheckPointRange;
  278.                 end;
  279.                 CheckPoint.Range:=TempRange;
  280.             end;
  281.         end;
  282.         if (Copy(Text,1,11)='/setrunlaps') then begin
  283.             if (MapCheckPoints.Count>2) then begin
  284.                 if (GetPiece(GetPiece(MapCheckPoints[0],'T',1),'L',0)='4') then begin
  285.                     try
  286.                         delete(Text,1,11);
  287.                         selectid:=strtoint(text);
  288.                         if (selectid<=0) then begin
  289.                             selectid:=1;
  290.                             Player.WriteConsole('The minimum number of laps is 1. Changed to the minimum value.',$FFBB);
  291.                         end else Player.WriteConsole('Changed the number of laps on '+inttostr(selectid)+'.',$FFBB);
  292.                     except
  293.                         Player.WriteConsole('An error occurred, please enter a valid number (can be 123 etc). I set to last value: '+inttostr(Checkpoint.Lap),$FFBB);
  294.                         selectid:=Checkpoint.Lap;
  295.                     end;
  296.                     CheckPoint.Lap:=selectid;
  297.                     SaveSetLap();
  298.                 end else
  299.                 begin
  300.                     Player.WriteConsole('First plese change "Checkpoint 1!" or "[   Start   ]" change to checkpoint Start/Finish.',$FFBB);
  301.                     Player.WriteConsole('To change first start edit checkpoint 1 next write /setcheckpointtype 4 and save checkpoint.',$FFBB);
  302.                 end;
  303.             end else Player.WriteConsole('First create minimum 3 checkpoints.',$FFBB);
  304.         end;
  305.         if (Copy(Text,1,18)='/setcheckpointtype') then begin
  306.             if (CheckPoint.Check) then begin
  307.                 if (MapCheckPoints.Count>2) then begin
  308.                     try
  309.                         delete(Text,1,18);
  310.                         selectid:=strtoint(text);
  311.                         if (selectid>0) then begin
  312.                             if (selectid<5) then begin
  313.                                 if (CheckPoint.CheckPointsId<=MapCheckPoints.Count) then begin
  314.                                     case selectid of
  315.                                         1:  begin
  316.                                                 if (CheckPoint.CheckPointsId=0) then begin
  317.                                                     CheckPoint.Typ:=selectid;
  318.                                                     Player.WriteConsole('Checkpoint change to start.',$FFBB);
  319.                                                     if (GetPiece(GetPiece(MapCheckPoints[MapCheckPoints.Count-1],'T',1),'L',0)<>'3') then begin
  320.                                                         SaveSetType(MapCheckPoints.Count-1,3);
  321.                                                         Player.WriteConsole('We setup for you to finish checkpoint type on the last checkpoint.',$FFBB);
  322.                                                     end;
  323.                                                     if (CheckPoint.Lap>1) then begin
  324.                                                         Player.WriteConsole('We see that disable laps mode. And see lap '+inttostr(CheckPoint.Lap)+', we set laps to 1 ;)',$FFBB);
  325.                                                         CheckPoint.Lap:=1;
  326.                                                         SaveSetLap();
  327.                                                     end;
  328.                                                 end else Player.WriteConsole('To set to start checkpoint id must be 1.',$FFBB);
  329.                                             end;
  330.                                         2:  begin
  331.                                                 CheckPoint.Typ:=selectid;
  332.                                                 Player.WriteConsole('Checkpoint change to normal.',$FFBB);
  333.                                                 if (CheckPoint.CheckPointsId=0) then begin
  334.                                                     if (GetPiece(GetPiece(MapCheckPoints[0],'T',1),'L',0)='1') then begin
  335.                                                         SaveSetType(0,2);
  336.                                                         Player.WriteConsole('You set start checkpoint to normal we set checkpoint finish also to normal checkpoin for you.',$FFBB);
  337.                                                     end;
  338.                                                     if (GetPiece(GetPiece(MapCheckPoints[0],'T',1),'L',0)='4') then begin
  339.                                                         Player.WriteConsole('We detect checkpoint Start/Finish and we disable this checkpoint.',$FFBB);
  340.                                                         if (CheckPoint.Lap>1) then begin
  341.                                                             Player.WriteConsole('We see that disable laps mode. And see lap '+inttostr(CheckPoint.Lap)+', we set laps to 1 ;)',$FFBB);
  342.                                                             CheckPoint.Lap:=1;
  343.                                                             SaveSetLap();
  344.                                                         end;
  345.                                                     end;
  346.                                                 end;
  347.                                                 if (CheckPoint.CheckPointsId=MapCheckPoints.Count-1) then begin
  348.                                                     if (GetPiece(GetPiece(MapCheckPoints[0],'T',1),'L',0)='1') then begin
  349.                                                         SaveSetType(0,2);
  350.                                                         Player.WriteConsole('You set finish checkpoint to normal we set checkpoint start also to normal checkpoin for you.',$FFBB);
  351.                                                     end;
  352.                                                 end;
  353.                                             end;
  354.                                         3:  begin
  355.                                                 if (CheckPoint.CheckPointsId=MapCheckPoints.Count-1) then begin
  356.                                                     CheckPoint.Typ:=selectid;
  357.                                                     Player.WriteConsole('Checkpoint change to end.',$FFBB);
  358.                                                     if (GetPiece(GetPiece(MapCheckPoints[0],'T',1),'L',0)<>'1') then begin
  359.                                                         SaveSetType(0,1);
  360.                                                         Player.WriteConsole('We setup for you to start checkpoint type on at the first checkpoint.',$FFBB);
  361.                                                     end;
  362.                                                     if (CheckPoint.Lap>1) then begin
  363.                                                         Player.WriteConsole('We see that disable laps mode. And see lap '+inttostr(CheckPoint.Lap)+', we set laps to 1 ;)',$FFBB);
  364.                                                         CheckPoint.Lap:=1;
  365.                                                         SaveSetLap();
  366.                                                     end;
  367.                                                 end else Player.WriteConsole('To set to start checkpoint id must be '+inttostr(MapCheckPoints.Count)+'.'+inttostr(CheckPoint.CheckPointsId),$FFBB);
  368.                                             end;
  369.                                         4:  begin
  370.                                                 if (CheckPoint.CheckPointsId=0) then begin
  371.                                                     CheckPoint.Typ:=selectid;
  372.                                                     if (GetPiece(GetPiece(MapCheckPoints[MapCheckPoints.Count-1],'T',1),'L',0)='3') then begin
  373.                                                         SaveSetType(MapCheckPoints.Count-1,2);
  374.                                                         Player.WriteConsole('We find finish checkpoint and change to normal checkpoint.',$FFBB);
  375.                                                     end else Player.WriteConsole('Checkpoint change to start and end.',$FFBB);
  376.                                                 end else Player.WriteConsole('To set to start checkpoint id must be 1.',$FFBB);
  377.                                             end;
  378.                                     end;
  379.                                 end else Player.WriteConsole('Plese first save new checkpoint next edit and start change checkpoint type.',$FFBB);
  380.                             end else Player.WriteConsole('Checkpoint type too high number. 1 start, 2 normal, 3 end, 4 start and end',$FFBB);
  381.                         end else Player.WriteConsole('Checkpoint type too low number. 1 start, 2 normal, 3 end, 4 start and end',$FFBB);
  382.                     except
  383.                         Player.WriteConsole('An error occurred, please enter a valid number(1-4). We set to normal checkpoint.',$FFBB);
  384.                         selectid:=2;
  385.                     end;
  386.                 end else Player.WriteConsole('Must create minimum 3 checkpoint to start change type.',$FFBB);
  387.             end else Player.WriteConsole('First start edit checkpoint.',$FFBB);
  388.         end;
  389.         if (Copy(Text,1,19)='/setcheckpointspeed') then begin
  390.             try
  391.                 delete(Text,1,19);
  392.                 TempRange:=strtofloat(text);
  393.                 if (TempRange<0.01) then begin
  394.                     TempRange:=0.01;
  395.                     Player.WriteConsole('Value is higher than the minimum, I set to minimal: 0.01',$FFBB);
  396.                 end else
  397.                 begin
  398.                     Player.WriteConsole('Last speed: '+formatfloat('0.0000',SpeedMovementText)+', default: '+formatfloat('0.0000',DeffaultMoveSpeed),$FFBB);
  399.                     Player.WriteConsole('Checkpoint movement speed set to: '+formatfloat('0.0000',TempRange),$FFBB);
  400.                 end;
  401.             except
  402.                 Player.WriteConsole('An error occurred, please enter a valid number (can be 123 etc or 1.1234). I set to default value: '+formatfloat('0.0000',DeffaultMoveSpeed),$FFBB);
  403.                 TempRange:=DeffaultMoveSpeed;
  404.             end;
  405.             SpeedMovementText:=TempRange;
  406.         end;
  407.     end;
  408.     Result:=False;
  409. end;
  410.  
  411. procedure ChangeAfter(Next: string);
  412. begin
  413.     if (File.Exists(Script.Dir+'data/mapsdata/'+next)) then begin
  414.         MapCheckPoints := File.CreateStringListFromFile(Script.Dir+'data/mapsdata/'+next);
  415.         if (MapCheckPoints.Count>0) then begin
  416.             CheckPoint.Lap := strtoint(GetPiece(MapCheckPoints[0],'L',1));
  417.             if (CheckPoint.Lap<1) then CheckPoint.Lap:=1;
  418.         end else CheckPoint.Lap:=1;
  419.     end else
  420.     begin
  421.         MapCheckPoints := File.CreateStringList();
  422.         CheckPoint.Lap:=1;
  423.     end;
  424. end;
  425.  
  426. function DistplayTime(times:double):string;
  427. var min,sec,ms: integer; temp: double;
  428. begin
  429.     min := trunc(times/3600.0);
  430.     sec := trunc((times-(min*3600.0))/60.0);
  431.     temp:= times-((min*3600.0)+(sec*60.0));
  432.     ms  := trunc(temp/60.0*1000);
  433.     if (min>0) then Result:=inttostr(min)+'min, ';
  434.     if (sec>0) then if (result<>'') then Result:=Result+inttostr(sec)+'sec, ' else Result:=inttostr(sec)+'sec, ';
  435.     if (ms>0) then if (result<>'') then Result:=Result+inttostr(ms)+'ms' else Result:=inttostr(ms)+'ms';
  436.     if (Result[Length(Result)]=',') then Result:=Copy(Result,1,Length(Result)-1);
  437. end;
  438.  
  439. procedure AppOnIdleSC3(Ticks: integer);
  440. var SearchRunnerID,CheckPType: byte; i,b: integer; tempcolor: longint; TempX,TempY,TempRange,TempAcc,XTam,YTam: single; kd: double;  NS, NW: TNewWeapon; TempTimes: string;
  441. begin
  442.     //--- Search Runner ID ---\\
  443.     SearchRunnerID:=33;
  444.     for i := 1 to 32 do if (Players[i].Active) and (PlInfo[i].RunMode) then SearchRunnerID:=i;
  445.     //--- Display Timer ---\\
  446.     if (CheckPoint.RunerActive) and (SearchRunnerID<33) then begin
  447.         PlInfo[SearchRunnerID].Timer := PlInfo[SearchRunnerID].Timer+1;
  448.         TempTimes := DistplayTime(PlInfo[SearchRunnerID].Timer);
  449.         Players[SearchRunnerID].BigText(BigTextLayer,'Your time: '+TempTimes, 20,$FFBB,0.065,12,425);
  450.         for i := 1 to 32 do begin
  451.             if (Players[i].Active) and (i<>SearchRunnerID) then begin
  452.                 Players[i].BigText(BigTextLayer,Players[SearchRunnerID].Name+' time: '+TempTimes, 20,$FFBB,0.065,12,425);
  453.             end;
  454.         end;
  455.     end;
  456.     //--- Display All Checkpoints ---\\
  457.     for i := 0 to MapCheckPoints.Count-iif(CheckPoint.StartFinish,0,1) do begin
  458.         if (CheckPoint.CheckPointsID=i) and (CheckPoint.Check) then continue;
  459.         //--- Get Temp Checkpoin Info ---\\
  460.         if (i=MapCheckPoints.Count) then begin
  461.             TempX:=strtofloat(GetPiece(GetPiece(MapCheckPoints[0],'X',1),'Y',0));
  462.             TempY:=strtofloat(GetPiece(GetPiece(MapCheckPoints[0],'Y',1),'R',0));
  463.             TempRange:=strtofloat(GetPiece(GetPiece(MapCheckPoints[0],'R',1),'T',0));
  464.             CheckPType:=strtoint(GetPiece(GetPiece(MapCheckPoints[0],'T',1),'L',0));
  465.         end else
  466.         begin
  467.             TempX:=strtofloat(GetPiece(GetPiece(MapCheckPoints[i],'X',1),'Y',0));
  468.             TempY:=strtofloat(GetPiece(GetPiece(MapCheckPoints[i],'Y',1),'R',0));
  469.             TempRange:=strtofloat(GetPiece(GetPiece(MapCheckPoints[i],'R',1),'T',0));
  470.             CheckPType:=strtoint(GetPiece(GetPiece(MapCheckPoints[i],'T',1),'L',0));
  471.         end;
  472.         if (CheckPoint.RunerActive) and (SearchRunnerID<33) then begin
  473.             if (PlInfo[SearchRunnerID].CheckPointGet=i) then begin
  474.                 TempAcc:=Distance(TempX,TempY,Players[SearchRunnerID].X,Players[SearchRunnerID].Y);
  475.                 if (TempAcc<=TempRange) then begin
  476.                     PlInfo[SearchRunnerID].CheckPointGet:=PlInfo[SearchRunnerID].CheckPointGet+1;
  477.                     if (PlInfo[SearchRunnerID].CheckPointGet=MapCheckPoints.Count+iif(CheckPoint.StartFinish,1,0)) then begin
  478.                         if (PlInfo[SearchRunnerID].Lap=CheckPoint.Lap) then begin
  479.                             OffAndReset(SearchRunnerID);
  480.                             Players.WriteConsole(Players[SearchRunnerID].Name+' have time: '+TempTimes,$FFBB);
  481.                             Players[SearchRunnerID].BigText(BigTextLayer,'Your time: '+TempTimes, 250,$FFBB,0.065,12,425);
  482.                             for b := 1 to 32 do begin
  483.                                 if (Players[b].Active) and (b<>SearchRunnerID) then begin
  484.                                     Players[b].BigText(BigTextLayer,Players[SearchRunnerID].Name+' time: '+TempTimes, 250,$FFBB,0.065,12,425);
  485.                                 end;
  486.                             end;
  487.                         end else
  488.                         begin
  489.                             PlInfo[SearchRunnerID].Lap:=PlInfo[SearchRunnerID].Lap+1;
  490.                             PlInfo[SearchRunnerID].CheckPointGet:=0;
  491.                         end;
  492.                     end;
  493.                 end;
  494.             end;
  495.             //--- Get Checkpoint Color ---\\
  496.             if (i<PlInfo[SearchRunnerID].CheckPointGet) then tempcolor:=$FF9900 else tempcolor:=$33CC00;
  497.             //--- Display Checkpoint If Runer Active ---\\
  498.             case (CheckPType) of
  499.                 1:  begin Players.WorldText(i+1,'[   Start   ]',70,tempcolor,0.055,TempX-31.95,TempY); CheckPoint.StartFinish:=false; end;
  500.                 2:  Players.WorldText(i+1,'Checkpoint '+inttostr(i+1)+'!',70,tempcolor,0.055,TempX-43.5,TempY);
  501.                 3:  begin Players.WorldText(i+1,'[  Finish!  ]',70,tempcolor,0.055,TempX-34,TempY); CheckPoint.StartFinish:=false; end;
  502.                 4:  if (PlInfo[SearchRunnerID].CheckPointGet>1) then begin
  503.                         CheckPoint.StartFinish:=true;
  504.                         if (CheckPoint.Lap>1) then Players.WorldText(i+MapCheckPoints.Count+12,'[  Lap '+inttostr(PlInfo[SearchRunnerID].Lap)+'/'+inttostr(CheckPoint.Lap)+'!  ]',70,tempcolor+12000,0.035,TempX-22.8,TempY-6.5);
  505.                         Players.WorldText(i+1,'[  Finish!  ]',70,tempcolor,0.055,TempX-34,TempY);
  506.                     end else
  507.                     begin
  508.                         CheckPoint.StartFinish:=false;
  509.                         if (CheckPoint.Lap>1) then Players.WorldText(i+MapCheckPoints.Count+12,'[  Lap '+inttostr(PlInfo[SearchRunnerID].Lap)+'/'+inttostr(CheckPoint.Lap)+'!  ]',70,tempcolor+12000,0.035,TempX-22.8,TempY-6.5);
  510.                         Players.WorldText(i+1,'[   Start   ]',70,tempcolor,0.055,TempX-31.95,TempY);
  511.                     end;
  512.             end;
  513.         end else
  514.         begin
  515.             //--- If No Runer Active Display Checkpoint ---\\
  516.             case (CheckPType) of
  517.                 1:  Players.WorldText(i+1,'[   Start   ]',70,$33CC00,0.055,TempX-31.95,TempY);
  518.                 2:  Players.WorldText(i+1,'Checkpoint '+inttostr(i+1)+'!',70,$33CC00,0.055,TempX-43.5,TempY);
  519.                 3:  Players.WorldText(i+1,'[  Finish!  ]',70,$33CC00,0.055,TempX-34,TempY);
  520.                 4:  begin
  521.                         if (CheckPoint.Lap>1) then Players.WorldText(i+MapCheckPoints.Count+12,'[  Lap '+inttostr(CheckPoint.Lap)+'  ]',70,$FF9900+12000,0.035,TempX-17,TempY-6.5);
  522.                         Players.WorldText(i+1,'[Start/Finish]',70,$33CC00,0.055,TempX-45.5,TempY);
  523.                     end;
  524.             end;
  525.         end;
  526.     end;
  527.     //-- Disable Edit Mode And More If Player Is Runing --\\
  528.         if (CheckPoint.RunerActive) then WriteLnFile(Script.Dir+'data/mapsdata/aplos',Floattostr(Players[SearchRunnerID].X)+':'+Floattostr(Players[SearchRunnerID].Y));
  529.         if (bot) then begin
  530.             XTam:= strtofloat(GetPiece(botprev[xio],':',0));
  531.             YTam:= strtofloat(GetPiece(botprev[xio],':',1));
  532.             map.CreateBullet(XTam,YTam , 0, 0, 0, 5, Players[1]);
  533.             if xio< botprev.count then xio:=xio+1;
  534.             if xio= botprev.count then begin
  535.                 bot:=false;
  536.                 File.Delete(Script.Dir+'data/mapsdata/aplos');
  537.             end;
  538.         end;
  539.     if (CheckPoint.RunerActive) then exit;
  540.     for i := 1 to 32 do begin
  541.         if (Players[i].Active) and (Players[i].IsAdmin) and (CheckPoint.Check) then begin
  542.             //--- Move Text ---\\
  543.             if (Players[i].KeyUp) then CheckPoint.Pos[2]:=CheckPoint.Pos[2]-SpeedMovementText;
  544.             if (Players[i].KeyCrouch) then CheckPoint.Pos[2]:=CheckPoint.Pos[2]+SpeedMovementText;
  545.             if (Players[i].KeyLeft) then CheckPoint.Pos[1]:=CheckPoint.Pos[1]-SpeedMovementText;
  546.             if (Players[i].KeyRight) then CheckPoint.Pos[1]:=CheckPoint.Pos[1]+SpeedMovementText;
  547.             //--- Off Move Player ---\\
  548.             Players[i].Move(CheckPoint.PlayerPos[1],CheckPoint.PlayerPos[2]);
  549.             Players[i].SetVelocity(0,0);
  550.             //--- Display Text ---\\
  551.             Players.WorldText(MapCheckPoints.Count+11,'[-]',55,$FF00FF ,0.025,CheckPoint.Pos[1]-3.8,CheckPoint.Pos[2]);
  552.             Players.WorldText(MapCheckPoints.Count+2,'Pos X: '+FormatFloat('0.0000',CheckPoint.Pos[1])+', Pos Y: '+FormatFloat('0.0000',CheckPoint.Pos[2])+', Range: '+FormatFloat('0.0000',CheckPoint.Range),70,$FF9999,0.025,CheckPoint.Pos[1]-71.5,CheckPoint.Pos[2]-3.1);
  553.             case (CheckPoint.Typ) of
  554.                 1:  Players.WorldText(MapCheckPoints.Count+3,'[   Start   ]',70,$33CC00,0.055,CheckPoint.Pos[1]-31.95,CheckPoint.Pos[2]);
  555.                 2:  if (CheckPoint.CheckPointsID>MapCheckPoints.Count) then Players.WorldText(MapCheckPoints.Count+3,'Checkpoint '+inttostr(CheckPoint.CheckPointsID)+'!',70,$33CC00,0.055,CheckPoint.Pos[1]-43.5,CheckPoint.Pos[2]) else Players.WorldText(MapCheckPoints.Count+3,'Checkpoint '+inttostr(CheckPoint.CheckPointsID+1)+'!',70,$33CC00,0.055,CheckPoint.Pos[1]-43.5,CheckPoint.Pos[2]);
  556.                 3:  Players.WorldText(MapCheckPoints.Count+3,'[  Finish!  ]',70,$33CC00,0.055,CheckPoint.Pos[1]-34,CheckPoint.Pos[2]);
  557.                 4:  begin
  558.                         if (CheckPoint.Lap>1) then Players.WorldText(MapCheckPoints.Count+13,'[  Lap '+inttostr(CheckPoint.Lap)+'  ]',70,$FF9900+12000,0.035,CheckPoint.Pos[1]-17,CheckPoint.Pos[2]-6.5);
  559.                         Players.WorldText(MapCheckPoints.Count+3,'[Start/Finish]',70,$33CC00,0.055,CheckPoint.Pos[1]-45.5,CheckPoint.Pos[2]);
  560.                     end;
  561.             end;
  562.         end;
  563.         //--- Edit Mode ---\\
  564.         if (Players[i].Active) and (Players[i].IsAdmin) and (CheckPoint.EditMode[i]) then begin
  565.             //--- Set Weapon For Good Mouse Work ---\\
  566.             if (CheckPoint.TimeToActive[6]>0) or (CheckPoint.TimeToActive[3]>0) then begin
  567.                 NS:=TNewWeapon.Create();    NS.WType:=12;   NS.Ammo:=1;
  568.                 NW:=TNewWeapon.Create();    NW.WType:=255;  NW.Ammo:=1;
  569.                 Players[i].ForceWeapon(NS,NW);
  570.                 NS.Free(); NW.Free();
  571.             end else
  572.             begin
  573.                 NS:=TNewWeapon.Create();    NS.WType:=255;  NS.Ammo:=1;
  574.                 NW:=TNewWeapon.Create();    NW.WType:=255;  NW.Ammo:=1;
  575.                 Players[i].ForceWeapon(NS,NW);
  576.                 NS.Free(); NW.Free();
  577.             end;
  578.             //--- Mouse Move Speed Add ---\\
  579.             if (Players[i].KeyJetpack) and (CheckPoint.Check) then begin
  580.                 if (CheckPoint.TimeToActive[1]>=10) then begin
  581.                     if CheckPoint.TimeToActive[1]=10 then begin
  582.                         CheckPoint.LastPoss:=single(Players[i].MouseAimX);
  583.                         CheckPoint.TimeToActive[1]:=CheckPoint.TimeToActive[1]+1;
  584.                     end;
  585.                     TempAcc:=CheckPoint.LastPoss-single(Players[i].MouseAimX);
  586.                     if TempAcc>MouseMovementAccuracy then SpeedMovementText:=SpeedMovementText-MovementOffsetSpeedAdd else if TempAcc<-MouseMovementAccuracy then SpeedMovementText:=SpeedMovementText+MovementOffsetSpeedAdd;
  587.                     if (SpeedMovementText<0.01) then SpeedMovementText:=0.01;
  588.                     CheckPoint.LastPoss:=single(Players[i].MouseAimX);
  589.                     Players.WorldText(MapCheckPoints.Count+4,'SpeedMove: '+FormatFloat('0.0000',SpeedMovementText),70,$33CC00,0.035,Players[i].MouseAimX-38,Players[i].MouseAimY-12.1);
  590.                 end else CheckPoint.TimeToActive[1]:=CheckPoint.TimeToActive[1]+1;
  591.             end else CheckPoint.TimeToActive[1]:=0;
  592.             //--- Key Save Check Point ---\\
  593.             if (Players[i].KeyReload) and (CheckPoint.Check) then begin
  594.                 if (CheckPoint.TimeToActive[2]>=18) then begin
  595.                     Players.WorldText(MapCheckPoints.Count+5,'Save Complete :)',70,$CC3300,0.035,CheckPoint.Pos[1]-32.4,CheckPoint.Pos[2]-8.8);
  596.                     SaveCheckPoint();
  597.                 end else
  598.                 begin
  599.                     //-- Display Save Info --\\
  600.                     kd := (CheckPoint.TimeToActive[2]/18.0)*100;
  601.                     Players.WorldText(MapCheckPoints.Count+5,'Save '+formatfloat('0.00',kd)+'% :)',70,$CC3300,0.035,CheckPoint.Pos[1]-28,CheckPoint.Pos[2]-8.8);
  602.                     CheckPoint.TimeToActive[2]:=CheckPoint.TimeToActive[2]+1;
  603.                 end;
  604.             end else CheckPoint.TimeToActive[2]:=0;
  605.             //--- Key Get Edit ---\\
  606.             if (Players[i].KeyShoot) and (CheckPoint.Check=false) then begin
  607.                 if (CheckPoint.TimeToActive[3]>=45) then begin
  608.                     //-- Start Edit --\\
  609.                     CheckPoint.CheckPointsID:=FindCheckPoint(i,700);
  610.                     if (CheckPoint.CheckPointsID>-1) then begin
  611.                         CheckPoint.Check:=true;
  612.                         TempX:=strtofloat(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'X',1),'Y',0));
  613.                         TempY:=strtofloat(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'Y',1),'R',0));
  614.                         CheckPoint.Typ:=strtoint(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'T',1),'L',0));
  615.                         CheckPoint.Pos[1]:=TempX; CheckPoint.PlayerPos[1]:=TempX;
  616.                         CheckPoint.Pos[2]:=TempY; CheckPoint.PlayerPos[2]:=TempY;
  617.                         CheckPoint.Range:=strtofloat(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'R',1),'T',0));
  618.                         Players.WorldText(MapCheckPoints.Count+6,'Start Editing :)',70,$CC3300,0.035,CheckPoint.Pos[1]-27.5,CheckPoint.Pos[2]-8.8);
  619.                     end else if (CheckPoint.CheckPointsID=-1) then CheckPoint.TimeToActive[3]:=0;
  620.                 end else
  621.                 begin
  622.                     //-- Search Check Point --\\
  623.                     CheckPoint.CheckPointsID:=FindCheckPoint(i,700);
  624.                     if (CheckPoint.CheckPointsID>-1) then begin
  625.                         TempX:=strtofloat(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'X',1),'Y',0));
  626.                         TempY:=strtofloat(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'Y',1),'R',0));
  627.                         //-- Display Start Edit Info --\\
  628.                         kd := (CheckPoint.TimeToActive[3]/45.0)*100;
  629.                         Players.WorldText(MapCheckPoints.Count+6,'Begin Edit '+formatfloat('0.00',kd)+'% :)',70,$CC3300,0.035,TempX-38,TempY-4.2);
  630.                         CheckPoint.TimeToActive[3]:=CheckPoint.TimeToActive[3]+1;
  631.                     end else if (CheckPoint.CheckPointsID=-1) then CheckPoint.TimeToActive[3]:=0;
  632.                 end;
  633.             end else CheckPoint.TimeToActive[3]:=0;
  634.             //--- Key Canceled Edit ---\\
  635.             if (Players[i].KeyThrow) and (CheckPoint.Check) then begin
  636.                 if (CheckPoint.TimeToActive[4]>=18) then begin
  637.                     //-- Canceled Edit --\\
  638.                     Players.WorldText(MapCheckPoints.Count+7,'Canceled Editing!',70,$CC3300,0.035,CheckPoint.Pos[1]-33,CheckPoint.Pos[2]-8.8);
  639.                     CheckPoint.Check:=false;
  640.                 end else
  641.                 begin
  642.                     //-- Display Canceled Edit Info --\\
  643.                     kd := (CheckPoint.TimeToActive[4]/18.0)*100;
  644.                     Players.WorldText(MapCheckPoints.Count+7,'Canceled Editing '+formatfloat('0.00',kd)+'%',70,$CC3300,0.035,CheckPoint.Pos[1]-46.5,CheckPoint.Pos[2]-8.8);
  645.                     CheckPoint.TimeToActive[4]:=CheckPoint.TimeToActive[4]+1;
  646.                 end;
  647.             end else CheckPoint.TimeToActive[4]:=0;
  648.             //--- Key Create Checkpoint ---\\
  649.             if (Players[i].KeyChangeWeap) and (CheckPoint.Check=false) then begin
  650.                 if (CheckPoint.TimeToActive[5]>=25) then begin
  651.                     //-- Ket Create Checkpoint --\\
  652.                     CheckPoint.Check:=true;
  653.                     CheckPoint.CheckPointsID:=MapCheckPoints.Count+1;
  654.                     CheckPoint.Pos[1]:=Players[i].X; CheckPoint.PlayerPos[1]:=Players[i].X;
  655.                     CheckPoint.Pos[2]:=Players[i].Y; CheckPoint.PlayerPos[2]:=Players[i].Y;
  656.                     CheckPoint.Range:=DeffaultCheckPointRange;
  657.                     CheckPoint.Typ:=2;
  658.                     Players.WorldText(MapCheckPoints.Count+8,'Create Create Checkpoint!',70,$CC3300,0.035,CheckPoint.Pos[1]-50.5,CheckPoint.Pos[2]-8.8);
  659.                 end else
  660.                 begin
  661.                     //-- Display Create Checkpoint Info --\\
  662.                     kd := (CheckPoint.TimeToActive[5]/25.0)*100;
  663.                     Players.WorldText(MapCheckPoints.Count+8,'Create Checkpoint '+formatfloat('0.00',kd)+'%',70,$CC3300,0.035,Players[i].X-51,Players[i].Y-8.8);
  664.                     CheckPoint.TimeToActive[5]:=CheckPoint.TimeToActive[5]+1;
  665.                 end;
  666.             end else CheckPoint.TimeToActive[5]:=0;
  667.             //--- Mouse Set Range ---\\
  668.             if (Players[i].KeyShoot) and (CheckPoint.Check) then begin
  669.                 if (CheckPoint.TimeToActive[6]>=22) then begin
  670.                     CheckPoint.Range := Distance(CheckPoint.Pos[1],CheckPoint.Pos[2],single(Players[i].MouseAimX),single(Players[i].MouseAimY));
  671.                     if (CheckPoint.Range<MinimalCheckPointRange) then CheckPoint.Range:=MinimalCheckPointRange;
  672.                     Players.WorldText(MapCheckPoints.Count+9,'Range: '+formatfloat('0.0000',CheckPoint.Range),70,$33CC00,0.035,Players[i].MouseAimX-31.3,Players[i].MouseAimY-12.1);
  673.                 end else CheckPoint.TimeToActive[6]:=CheckPoint.TimeToActive[6]+1;
  674.             end else CheckPoint.TimeToActive[6]:=0;
  675.             //--- Key Delete Checkpoint ---\\
  676.             if (Players[i].KeyThrow) and (CheckPoint.Check=false) then begin
  677.                 if (CheckPoint.TimeToActive[7]>=45) then begin
  678.                     CheckPoint.CheckPointsID:=FindCheckPoint(i,700);
  679.                     if (CheckPoint.CheckPointsID>-1) then begin
  680.                         Players[i].WriteConsole('Remove checkpoint: '+inttostr(CheckPoint.CheckPointsID+1),$FFBB);
  681.                         if (CheckPoint.CheckPointsID=0) and (GetPiece(GetPiece(MapCheckPoints[0],'T',1),'L',0)='4') then begin
  682.                             Players[i].WriteConsole('We see that delete Start/Finish checkpoint. And see lap '+inttostr(CheckPoint.Lap)+', we set laps to 1 ;)',$FFBB);
  683.                             CheckPoint.Lap:=1;
  684.                             SaveSetLap();
  685.                         end;
  686.                         if (CheckPoint.CheckPointsID=0) and (GetPiece(GetPiece(MapCheckPoints[0],'T',1),'L',0)='1') then begin
  687.                             SaveSetType(MapCheckPoints.Count-1,2);
  688.                             Players[i].WriteConsole('We detect you delete start checkpoint. We change finish checkpoint to normal.',$FFBB);
  689.                         end;
  690.                         if (CheckPoint.CheckPointsID=MapCheckPoints.Count-1) and (GetPiece(GetPiece(MapCheckPoints[MapCheckPoints.Count-1],'T',1),'L',0)='3') then begin
  691.                             SaveSetType(0,2);
  692.                             Players[i].WriteConsole('We detect you delete finish checkpoint. We change start checkpoint to normal.',$FFBB);
  693.                         end;
  694.                         TempX:=strtofloat(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'X',1),'Y',0));
  695.                         TempY:=strtofloat(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'Y',1),'R',0));
  696.                         Players.WorldText(MapCheckPoints.Count+10,'Delete Complete :)',70,$CC3300,0.035,TempX-37,TempY-4.2);
  697.                         MapCheckPoints.Delete(CheckPoint.CheckPointsID); CheckPoint.TimeToActive[7]:=0;
  698.                         MapCheckPoints.SaveToFile(Script.Dir+'data/mapsdata/'+Game.CurrentMap);
  699.                         for b := 0 to MapCheckPoints.Count+1 do Players.WorldText(b+1,'',70,$33CC00,0.0001,0,0);
  700.                     end else if (CheckPoint.CheckPointsID=-1) then CheckPoint.TimeToActive[7]:=0;
  701.                 end else
  702.                 begin
  703.                     //-- Display Delete Info --\\-
  704.                     CheckPoint.CheckPointsID:=FindCheckPoint(i,700);
  705.                     if (CheckPoint.CheckPointsID>-1) then begin
  706.                         TempX:=strtofloat(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'X',1),'Y',0));
  707.                         TempY:=strtofloat(GetPiece(GetPiece(MapCheckPoints[CheckPoint.CheckPointsID],'Y',1),'R',0));
  708.                         kd := (CheckPoint.TimeToActive[7]/45.0)*100;
  709.                         Players.WorldText(MapCheckPoints.Count+10,'Delete '+formatfloat('0.00',kd)+'% :)',70,$CC3300,0.035,TempX-32.5,TempY-4.2);
  710.                         CheckPoint.TimeToActive[7]:=CheckPoint.TimeToActive[7]+1;
  711.                     end else if (CheckPoint.CheckPointsID=-1) then CheckPoint.TimeToActive[7]:=0;
  712.                 end;
  713.             end else CheckPoint.TimeToActive[7]:=0;
  714.         end;
  715.     end;
  716. end;
  717.  
  718. Procedure JoinTeam(Player: TActivePlayer; Team: TTeam);
  719. begin
  720.     if (CheckPoint.RunerActive) then begin
  721.         if not (PlInfo[Player.ID].RunMode) and (Team.ID<>5) then Player.Team:=5;
  722.         if (PlInfo[Player.ID].RunMode) and (Team.ID<>4) then begin
  723.             OffAndReset(Player.ID);
  724.             Players.WriteConsole(Player.Name+' stoped runing!',$FFBB);
  725.         end;
  726.     end;
  727. end;
  728.  
  729. procedure LeaveGame(Player: TActivePlayer; Kicked: Boolean);
  730. begin
  731.     if (PlInfo[Player.ID].RunMode) then OffAndReset(Player.ID);
  732.     if (CheckPoint.EditMode[Player.ID]) then begin
  733.         CheckPoint.EditMode[Player.ID]:=false;
  734.         CheckPoint.Check:=false;
  735.     end;
  736. end;
  737.  
  738. initialization
  739. begin
  740.     //---Instal Script ---\\
  741.     for Decl := 1 to 32 do Players[Decl].OnCommand := @Commands;
  742.     for Decl := 1 to 5 do Game.Teams[Decl].OnJoin := @JoinTeam;
  743.     Game.TickThreshold := 1;
  744.     Game.OnLeave := @LeaveGame;
  745.     Map.OnAfterMapChange := @ChangeAfter;
  746.     Game.OnClockTick := @AppOnIdleSC3;
  747.     //-- Vars --\\
  748.     SpeedMovementText:=DeffaultMoveSpeed;
  749.     //--- Load Map Checkpoints ---\\
  750.     if (File.Exists(Script.Dir+'data/mapsdata/'+Game.CurrentMap)) then begin
  751.         MapCheckPoints := File.CreateStringListFromFile(Script.Dir+'data/mapsdata/'+Game.CurrentMap);
  752.         if (MapCheckPoints.Count>0) then begin
  753.             CheckPoint.Lap := strtoint(GetPiece(MapCheckPoints[0],'L',1));
  754.             if (CheckPoint.Lap<1) then CheckPoint.Lap:=1;
  755.         end else CheckPoint.Lap:=1;
  756.     end else
  757.     begin
  758.         MapCheckPoints := File.CreateStringList();
  759.         CheckPoint.Lap:=1;
  760.     end;
  761. end;
  762.  
  763. finalization;
  764. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement