Advertisement
Schneider1988

Keep Your Lane - V2 - Full Version

Dec 23rd, 2014
821
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 73.01 KB | None | 0 0
  1. #include <a_samp>
  2. #include <streamer>
  3. #include <sscanf2>
  4. #include <zcmd>
  5. #include <vehiclematrix>
  6.  
  7. //#define ALLOW_DRIVING_ON_TRAIN_TRACK    //While this define is diabled (commented) players are NOT allowed to drive on traintracks. Remove the // to allow players to drive on the tracks.
  8.  
  9.  
  10. #define MAX_ROADPOINTS_PER_ZONE 500  // This value will define the size of the array in which the RoadPoints in each zone will be stored.
  11.                                      // If this value is too small (there are more RoadPoints in a zone than this value) this system will be terminated.
  12.                                      // On the other hand, if this value is too large your server will be less efficient. Keep an eye on the serverlog...
  13.                                      // ...it will show you the ideal value based on the number of RoadPoints found.
  14.  
  15.  
  16. #define ANGLE_TOLERANCE 25   // Example: if this value is set at 25 degrees and a given RoadPoint has an original angle of 150 degrees, the script will...
  17.                              //          ...trigger OnPlayerWrongLane when a player passes this point with an angle between 125 and 175 degrees.
  18.  
  19.  
  20. #define ROADPOINT_CHECK_INTERVAL 100   // This the interval in milliseconds of which the script will check each player if it's driving on the wrong side of the road.
  21.                              // The lower this value the more precice this system will work, but with many players or having a large script it might slow it down.
  22.  
  23.  
  24. #define BUILD "2.1.1 - Full Version (+Creator)"
  25.  
  26.  
  27. #define TD_DARKRED -16777196
  28. #define TD_BRIGHTGREEN 16711935
  29. #define TD_BRIGHTRED 0xFF0000FF
  30. #define TD_BLUE 0x0000FFFF
  31.  
  32. //New Variables:
  33. new TRP;  //Will store the total amout of RoadPoints created.  (wont get lowered when RoadPoints gets removed until restart. Used to give new Roadpoints an unique ID).
  34. new ATRP;  //This will store the actual total amount of RoadPoints (used for Textdraw)
  35. new RPCreator = -1;   //Will store the playerid of the player who is creating new RoadPoints
  36. new Float:RoadWidth = 2.5;  //Will store the type of RoadPoint during the creation of new RoadPoints (1 = normal road (1 lane) -- 2 = highway (2 lanes).
  37. new Float:AutoCreateDistance = 20.0;  //Stores during AutoCreation the distance entered by the player. The new RoadPoints will be created with this distance from eachother.
  38. new bool:IsCreating; // Bool to check if the AutoCreation-mode is enabled.
  39. new bool:IsPauzed;   // Bool to check if the creation-mode is pauzed or not
  40. new bool:Double;     // Bool to check if double of single directions are being made
  41. new bool:IsDeleting;   //Bool to check if the creator is mass-deleting RoadPoints
  42. new bool:ShowPresets;
  43. new Float:lastX, Float:lastY, Float:lastZ;  //During AutoCreaton-mode a new RoadPoint will created at 'AutoCreateDistance' from these these X, Y and Z coordinates.
  44. new Float:Space = 1.2;   // Stores the space between the 2 driving-directions during double-mode
  45.  
  46. #if defined ALLOW_DRIVING_ON_TRAIN_TRACK
  47.     new bool:AllowTrainTrackDriving = true;
  48. #else
  49.     new bool:AllowTrainTrackDriving = false;
  50. #endif
  51.  
  52. //Textdraws
  53. new Text:Textdraw0;
  54. new Text:Textdraw1;
  55. new Text:Textdraw2;
  56. new Text:Textdraw3;
  57. new Text:Textdraw4;
  58. new Text:Textdraw5;
  59. new Text:Textdraw6;
  60. new Text:Textdraw7;
  61. new Text:Textdraw8;
  62. new Text:Textdraw9;
  63. new Text:Textdraw10;
  64. new Text:Textdraw11;
  65. new Text:Textdraw12;
  66. new Text:Textdraw13;
  67. new Text:Textdraw14;
  68. new Text:Textdraw15;
  69. new Text:Textdraw16;
  70. new Text:Textdraw17;
  71. new Text:Textdraw18;
  72. new Text:Textdraw19;
  73. new Text:Textdraw20;
  74. new Text:Textdraw21;
  75. new Text:Textdraw22;
  76. new Text:Textdraw23;
  77. new Text:Textdraw24;
  78. new Text:Textdraw25;
  79. new Text:Textdraw26;
  80. new Text:Textdraw27;
  81.  
  82. //Textdraw-strings
  83. new td2str[12] = "Pauzed";
  84. new td5str[12] = "2.5";
  85. new td10str[12] = "~g~0.0";
  86. new td12str[12] = "~g~0";
  87. new td15str[12] = "OFF";
  88. new td19str[12] = "0.50";
  89.  
  90. //Preset TextDraw-strings
  91. new pre1str[64] = "#1: Single - 0.00 - 0.00 - 0.00";
  92. new pre2str[64] = "#2: Single - 0.00 - 0.00 - 0.00";
  93. new pre3str[64] = "#3: Single - 0.00 - 0.00 - 0.00";
  94. new pre4str[64] = "#4: Single - 0.00 - 0.00 - 0.00";
  95. new pre5str[64] = "#5: Single - 0.00 - 0.00 - 0.00";
  96.  
  97. //Preset Enum
  98. enum preinfo
  99. {
  100.     predouble,
  101.     predoublestr[12],
  102.     Float:prewidth,
  103.     Float:predistance,
  104.     Float:prespace
  105. }
  106. new Preset[5][preinfo];
  107.  
  108. //Roadpoint Enum
  109. enum rpinfo
  110. {
  111.     ID,      //Holds the unique ID of each RoadPoint
  112.     Float:X,  // Holds the X coordinate of each RoadPoint
  113.     Float:Y,  // Holds the Y coordinate of each RoadPoint
  114.     Float:Z,  // Holds the Z coordinate of each RoadPoint
  115.     Float:A,  // Holds the angle of each roadpoint (Note: this value should be the angle the players are supposed to drive!)
  116.     Float:D,  // Holds the maximum distance a player has to be from this RoadPoint before it's triggered.
  117.     PickupID,  // Holds the pickupID that will be visible to the creator during the Creation-mode so you can see where you have already created RoadPoints.
  118.     MapIconID
  119. }
  120.  
  121. enum tpinfo
  122. {
  123.     Float:tpX,  // Holds the X coordinate of each RoadPoint
  124.     Float:tpY,  // Holds the Y coordinate of each RoadPoint
  125.     Float:tpZ,  // Holds the Z coordinate of each RoadPoint
  126.     Float:tpD,  // Holds the maximum distance a player has to be from this RoadPoint before it's triggered.
  127. }
  128.  
  129. //This is the main array that stores all info about each RoadPoint.
  130. //The first dimention (37) is the number of zones (36 zones as described above + 1 extra zone in case players have custom roads build on the oceans around the map.
  131. //Each zone has (MAX_ROADPOINTS_PER_ZONE) slots available.
  132. new RP[145][MAX_ROADPOINTS_PER_ZONE][rpinfo];
  133. new TP[145][90][tpinfo];
  134. new RPInZone[145];
  135. new TPInZone[145];
  136.  
  137. new CZ[MAX_PLAYERS];
  138.  
  139. //Holds the Object-ids
  140. new Object1;
  141. new Object2;
  142. new Object3;
  143. new Object4;
  144.  
  145. //Publics
  146. public OnFilterScriptInit()
  147. {
  148.     new Float:minX, Float:maxX, Float:minY, Float:maxY;
  149.     maxY = 3000.0;
  150.     minY = 2500.0;
  151.     for(new i; i<12; i++)
  152.     {
  153.         minX = -3000.0;
  154.         maxX = -2500;
  155.         for(new j; j<12; j++)
  156.         {
  157.             CreateDynamicRectangle(minX, minY, maxX, maxY);
  158.             minX = floatadd(minX, 500.0);
  159.             maxX = floatadd(maxX, 500.0);
  160.         }
  161.         maxY = floatsub(maxY, 500.0);
  162.         minY = floatsub(minY, 500.0);
  163.     }
  164.     ResetRoadPointInfo(); //Will destroy and reset all values and pickups.
  165.     LoadPresets();  // Load the presets from the file
  166.     CreateTextDraws();  // Create the Textdraws
  167.  
  168.     print("\n--------------------------------------");
  169.     printf(" [FS]Keep Your Lane - Build %s", BUILD);
  170.     print("            by Schneider 2014");
  171.     print("--------------------------------------\n");
  172.    
  173.     //This timer will trigger a function that will calculate the optimal value of MAX_ROADPOINTS_PER_ZONE...
  174.     SetTimer("CheckEfficiency", 3000, 0);
  175.     SetTimer("CheckRoadPoints", ROADPOINT_CHECK_INTERVAL, 1);   //Start the main timer that checks each players position on the road.
  176.  
  177.     ReadRoadPoints(); // This function will read and load all RoadPoints from the KYLRoadPoints.txt file.
  178.     if(AllowTrainTrackDriving == false)
  179.     {
  180.         ReadTrainPoints();
  181.     }
  182.     return 1;
  183. }
  184.  
  185. public OnFilterScriptExit()
  186. {
  187.     SavePresets();    // Save the presets to its file
  188.    
  189.     //Delete objects and textdraws
  190.     if(IsValidDynamicObject(Object1)) DestroyDynamicObject(Object1);
  191.     if(IsValidDynamicObject(Object2)) DestroyDynamicObject(Object2);
  192.     if(IsValidDynamicObject(Object3)) DestroyDynamicObject(Object3);
  193.     if(IsValidDynamicObject(Object4)) DestroyDynamicObject(Object4);
  194.     TextDrawDestroy(Textdraw0);
  195.     TextDrawDestroy(Textdraw1);
  196.     TextDrawDestroy(Textdraw2);
  197.     TextDrawDestroy(Textdraw3);
  198.     TextDrawDestroy(Textdraw4);
  199.     TextDrawDestroy(Textdraw5);
  200.     TextDrawDestroy(Textdraw6);
  201.     TextDrawDestroy(Textdraw7);
  202.     TextDrawDestroy(Textdraw8);
  203.     TextDrawDestroy(Textdraw9);
  204.     TextDrawDestroy(Textdraw10);
  205.     TextDrawDestroy(Textdraw11);
  206.     TextDrawDestroy(Textdraw12);
  207.     TextDrawDestroy(Textdraw13);
  208.     TextDrawDestroy(Textdraw14);
  209.     TextDrawDestroy(Textdraw15);
  210.     TextDrawDestroy(Textdraw16);
  211.     TextDrawDestroy(Textdraw17);
  212.     TextDrawDestroy(Textdraw18);
  213.     TextDrawDestroy(Textdraw19);
  214.     TextDrawDestroy(Textdraw20);
  215.     TextDrawDestroy(Textdraw21);
  216.     TextDrawDestroy(Textdraw22);
  217.     TextDrawDestroy(Textdraw23);
  218.     TextDrawDestroy(Textdraw24);
  219.     TextDrawDestroy(Textdraw25);
  220.     TextDrawDestroy(Textdraw26);
  221.     TextDrawDestroy(Textdraw27);
  222.  
  223.     // Delete the mapicons and pickups
  224.     for(new zone; zone<145; zone++)
  225.     {
  226.         for(new slot; slot<MAX_ROADPOINTS_PER_ZONE; slot++)
  227.         {
  228.             if(IsValidDynamicPickup(RP[zone][slot][PickupID]))
  229.             {
  230.                 DestroyDynamicPickup(RP[zone][slot][PickupID]);
  231.                 RP[zone][slot][PickupID] = -1;
  232.             }
  233.             if(IsValidDynamicMapIcon(RP[zone][slot][MapIconID]))
  234.             {
  235.                 DestroyDynamicMapIcon(RP[zone][slot][MapIconID]);
  236.                 RP[zone][slot][MapIconID] = -1;
  237.             }
  238.         }
  239.     }
  240.     ResetRoadPointInfo(); //Will destroy and reset all values and pickups.
  241.     return 1;
  242. }
  243.  
  244. public OnPlayerStateChange(playerid, newstate, oldstate)
  245. {
  246.     if((RPCreator == playerid) && (oldstate == PLAYER_STATE_DRIVER) && (IsCreating == true))  //If RoadPoint-Creator is leaving his vehicle...
  247.     {
  248.         IsCreating = false; //Disable the Creation-mode
  249.         RPCreator = -1;         //Reset the playerid of the RPCreator
  250.         IsPauzed = false;
  251.         IsDeleting = false;
  252.         HideTextDraws(playerid);   //Hide the textdraws
  253.         UpdateObjects(playerid, 1, -1);   //Delete the objects
  254.        
  255.         //Delete mapicons and pickups
  256.         for(new zone; zone<145; zone++)
  257.         {
  258.             for(new slot; slot<MAX_ROADPOINTS_PER_ZONE; slot++)
  259.             {
  260.                 if(IsValidDynamicPickup(RP[zone][slot][PickupID]))
  261.                 {
  262.                     DestroyDynamicPickup(RP[zone][slot][PickupID]);
  263.                     RP[zone][slot][PickupID] = -1;
  264.                 }
  265.                 if(IsValidDynamicMapIcon(RP[zone][slot][MapIconID]))
  266.                 {
  267.                     DestroyDynamicMapIcon(RP[zone][slot][MapIconID]);
  268.                     RP[zone][slot][MapIconID] = -1;
  269.                 }
  270.             }
  271.         }
  272.         SendClientMessage(playerid, 0x00FF00AA, "RoadPoint-Creation Mode Disabled");
  273.     }
  274.     return 1;
  275. }
  276.  
  277.  
  278. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  279. {
  280.     //DebugKeys(playerid, newkeys, oldkeys);
  281.     if((RPCreator == playerid) && (GetPlayerState(playerid) == PLAYER_STATE_DRIVER))
  282.     {
  283.         if((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE)) // Player presses left-mouse button >>> Select textdraw
  284.         {
  285.             SelectTextDraw(playerid, 0xFFFFFFFF);
  286.         }
  287.         if((newkeys & KEY_HANDBRAKE) && !(oldkeys & KEY_HANDBRAKE))  // Player presses Honk-key >>> Pauze/Activate Roadcreaton
  288.         {
  289.             if(IsDeleting == true)  // If player is in mass-deleting-mode it will be disabled by pressing the handbrake
  290.             {
  291.                 IsDeleting = false;
  292.                 IsPauzed = true;
  293.                
  294.             }
  295.             else  // If the mode is either pauzed or enabled, then switch.
  296.             {
  297.                 if(IsPauzed == false)
  298.                 {
  299.                     IsPauzed = true;
  300.                 }
  301.                 else
  302.                 {
  303.                     IsPauzed = false;
  304.                 }
  305.             }
  306.         }
  307.         if ((newkeys & KEY_ACTION) && !(oldkeys & KEY_ACTION))  // Player Presses (Ctrl)  >>> Create new RoadPoint
  308.         {
  309.             new vid = GetPlayerVehicleID(playerid), Float:vX, Float:vY, Float:vZ, Float:vA;
  310.             GetVehiclePos(vid, vX, vY, vZ);
  311.             GetVehicleZAngle(vid, vA);
  312.             new slot = GetFreeSlot(CZ[playerid]);
  313.             if(slot == -1)
  314.             {
  315.                 SendClientMessage(playerid, 0xFF0000AA, "[Error] - The max amount of RoadPoints per zone has been reached!");
  316.                 SendClientMessage(playerid, 0xFF0000AA, "Increae the MAX_ROADPOINTS_PER_ZONE define at the top of the filterscript and reload");
  317.             }
  318.             else
  319.             {
  320.                 RP[CZ[playerid]][slot][X] = vX;
  321.                 RP[CZ[playerid]][slot][Y] = vY;
  322.                 RP[CZ[playerid]][slot][Z] = vZ;
  323.                 RP[CZ[playerid]][slot][A] = vA;
  324.                 RP[CZ[playerid]][slot][D] = floatdiv(RoadWidth, 2.0);
  325.                 RP[CZ[playerid]][slot][ID] = TRP;
  326.                 RP[CZ[playerid]][slot][PickupID] = CreateDynamicPickup(1318, 23, RP[CZ[playerid]][slot][X], RP[CZ[playerid]][slot][Y], RP[CZ[playerid]][slot][Z], -1, -1, playerid, 200.0);
  327.                 RP[CZ[playerid]][slot][MapIconID] = CreateDynamicMapIcon(RP[CZ[playerid]][slot][X], RP[CZ[playerid]][slot][Y], RP[CZ[playerid]][slot][Z], 56, 0, -1, -1, playerid, 300.0, MAPICON_LOCAL);
  328.                 TRP++;
  329.                 ATRP++;
  330.                 SaveRoadPoint(vX, vY, vZ, vA, RoadWidth);
  331.             }
  332.         }
  333.         UpdateTextDraws(playerid);
  334.     }
  335.     return 1;
  336. }
  337.  
  338.  
  339. //This callback is used to automatically create new RoadPoints:
  340. public OnPlayerUpdate(playerid)
  341. {
  342.     if((IsDeleting == true) && (RPCreator == playerid))
  343.     {
  344.         new slot = GetPlayerRoadPointSlot(playerid);
  345.         if(slot != -1)
  346.         {
  347.             new rpID = GetPlayerRoadPointID(playerid);
  348.             if(rpID != -1)
  349.             {
  350.                 new line = ffindLine(rpID);
  351.                 fdeleteline("KYLRoadPoints.txt", line);
  352.                 if(IsValidDynamicPickup(RP[CZ[playerid]][slot][PickupID]))
  353.                 {
  354.                     DestroyDynamicPickup(RP[CZ[playerid]][slot][PickupID]);
  355.                     RP[CZ[playerid]][slot][PickupID] = -1;
  356.                 }
  357.                 if(IsValidDynamicMapIcon(RP[CZ[playerid]][slot][MapIconID]))
  358.                 {
  359.                     DestroyDynamicMapIcon(RP[CZ[playerid]][slot][MapIconID]);
  360.                     RP[CZ[playerid]][slot][MapIconID] = -1;
  361.                 }
  362.                 RP[CZ[playerid]][slot][X] = 0.0;
  363.                 RP[CZ[playerid]][slot][Y] = 0.0;
  364.                 RP[CZ[playerid]][slot][Z] = 0.0;
  365.                 RP[CZ[playerid]][slot][A] = 0.0;
  366.                 RP[CZ[playerid]][slot][D] = 0.0;
  367.                 RP[CZ[playerid]][slot][ID] = -1;
  368.                 ATRP--;
  369.             }
  370.         }
  371.     }
  372.     else
  373.     {
  374.         if(IsCreating == true && IsPauzed == false)  // Check if AutoCreaton-mode is enabled
  375.         {
  376.             if(RPCreator == playerid)  // Check if playerid is the creator
  377.             {
  378.                 new Float:vX, Float:vY, Float:vZ;  // Create 3 new floats to store the current position
  379.                 new vid = GetPlayerVehicleID(playerid);
  380.                 GetVehiclePos(vid, vX, vY, vZ);  //Retrieve the current vehicle position
  381.                 if(GetDistance(lastX, lastY, lastZ, vX, vY, vZ) >= AutoCreateDistance)  //Check if the distance between the current position and the previous created RoadPoint is equal or larger than the distance set by the creator
  382.                 {
  383.                     if(Double == false)
  384.                     {
  385.                         new Float:vA; //Create new float to store the current vehicle angle
  386.                         GetVehicleZAngle(vid, vA);  //Retrieve the vehicles driving direction
  387.                         new slot = GetFreeSlot(CZ[playerid]);  //Get the first empty slot in the array of that zone
  388.                         if(slot == -1)   //...if there is no empty slot available in the current zone
  389.                         {
  390.                             IsCreating = false;   // Disable the Creation-mode
  391.                             RPCreator = -1;            // Reset the playerid assigned to the RPCreator value
  392.                             SendClientMessage(playerid, 0xFF0000AA, "[Error] - The max amount of RoadPoints per zone has been reached!"); // Send error-message to the creator
  393.                             SendClientMessage(playerid, 0xFF0000AA, "Increae the MAX_ROADPOINTS_PER_ZONE define at the top of the filterscript and reload"); // Send error-message to the creator
  394.                             SendClientMessage(playerid, 0xFF0000AA, "Auto Creation of RoadPoints has been disabled"); // Send error-message to the creator
  395.                             return 1;
  396.                         }
  397.                         else // If an empty slot in the current zone is found...
  398.                         {
  399.  
  400.                             RP[CZ[playerid]][slot][X] = vX;  //Store the current X postion as the new RoadPoint X position
  401.                             RP[CZ[playerid]][slot][Y] = vY;  //Store the current Y postion as the new RoadPoint Y position
  402.                             RP[CZ[playerid]][slot][Z] = vZ;  //Store the current Z postion as the new RoadPoint Z position
  403.                             RP[CZ[playerid]][slot][A] = vA;  //Store the current angle as the new RoadPoint suppossed driving-direction.
  404.                             RP[CZ[playerid]][slot][D] = floatdiv(RoadWidth, 2.0);
  405.                             RP[CZ[playerid]][slot][ID] = TRP; // Set the ID of the new RoadPoint as current amount of RoadPoints
  406.                             RP[CZ[playerid]][slot][MapIconID] = CreateDynamicMapIcon(RP[CZ[playerid]][slot][X], RP[CZ[playerid]][slot][Y], RP[CZ[playerid]][slot][Z], 56, 0, -1, -1, playerid, 300.0, MAPICON_LOCAL);
  407.                             RP[CZ[playerid]][slot][PickupID] = CreateDynamicPickup(1318, 23, RP[CZ[playerid]][slot][X], RP[CZ[playerid]][slot][Y], RP[CZ[playerid]][slot][Z], -1, -1, playerid, 200.0);
  408.                             TRP++;  //Increase the total amount of RoadPoints
  409.                             ATRP++;
  410.                             SaveRoadPoint(vX, vY, vZ, vA, RoadWidth);  // This function will write the newly created RoadPoint to the KYLRoadPoints.txt file.
  411.                             UpdateTextDraws(playerid);
  412.                             lastX = vX;  // Store the current X-position in the lastX variable, to be used on the next update;
  413.                             lastY = vY;  // Store the current Y-position in the lastY variable, to be used on the next update;
  414.                             lastZ = vZ;  // Store the current Z-position in the lastZ variable, to be used on the next update;
  415.                         }
  416.                     }
  417.                     else if(Double == true)
  418.                     {
  419.                         new Float:vA;
  420.                         new Float:rX, Float:rY, Float:rZ, Float:rA;
  421.                         new Float:lX, Float:lY, Float:lZ, Float:lA;
  422.                         GetVehicleZAngle(vid, vA);
  423.                        
  424.                         PositionFromVehicleOffset(vid, floatadd(floatdiv(RoadWidth, 2), floatdiv(Space, 2.0)), 0.0, 0.0, rX, rY, rZ);
  425.                         PositionFromVehicleOffset(vid, -floatadd(floatdiv(RoadWidth, 2), floatdiv(Space, 2.0)), 0.0, 0.0, lX, lY, lZ);
  426.                    
  427.                         rA = vA;
  428.                         lA = floatadd(vA, 180);
  429.                         if(lA >= 360.0)
  430.                         {
  431.                             lA = floatsub(lA, 360.0);
  432.                         }
  433.                         new zone = GetZone(lX, lY); // Retrieve the zone which the player is currently in.
  434.                         new slot = GetFreeSlot(zone);  //Get the first empty slot in the array of that zone
  435.                         if(slot == -1)   //...if there is no empty slot available in the current zone
  436.                         {
  437.                             IsCreating = false;   // Disable the Creation-mode
  438.                             RPCreator = -1;            // Reset the playerid assigned to the RPCreator value
  439.                             SendClientMessage(playerid, 0xFF0000AA, "[Error] - The max amount of RoadPoints per zone has been reached!"); // Send error-message to the creator
  440.                             SendClientMessage(playerid, 0xFF0000AA, "Increae the MAX_ROADPOINTS_PER_ZONE define at the top of the filterscript and reload"); // Send error-message to the creator
  441.                             SendClientMessage(playerid, 0xFF0000AA, "Auto Creation of RoadPoints has been disabled"); // Send error-message to the creator
  442.                             return 1;
  443.                         }
  444.                         else // If an empty slot in the current zone is found...
  445.                         {
  446.                             RP[zone][slot][X] = lX;  //Store the current X postion as the new RoadPoint X position
  447.                             RP[zone][slot][Y] = lY;  //Store the current Y postion as the new RoadPoint Y position
  448.                             RP[zone][slot][Z] = vZ;  //Store the current Z postion as the new RoadPoint Z position
  449.                             RP[zone][slot][A] = lA;  //Store the current angle as the new RoadPoint suppossed driving-direction.
  450.                             RP[zone][slot][D] = floatdiv(RoadWidth, 2.0);
  451.                             RP[zone][slot][ID] = TRP; // Set the ID of the new RoadPoint as current amount of RoadPoints
  452.  
  453.                             RP[zone][slot][MapIconID] = CreateDynamicMapIcon(lX, lY, lZ, 56, 0, -1, -1, playerid, 300.0, MAPICON_LOCAL);
  454.                             RP[zone][slot][PickupID] = CreateDynamicPickup(1318, 23, lX, lY, lZ, -1, -1, playerid, 200.0);
  455.                             SaveRoadPoint(lX, lY, lZ, lA, RoadWidth);  // This function will write the newly created RoadPoint to the KYLRoadPoints.txt file.
  456.  
  457.                             TRP++;
  458.                             ATRP++;
  459.                             UpdateTextDraws(playerid);
  460.                         }
  461.                         zone = GetZone(rX, rY); // Retrieve the zone which the player is currently in.
  462.                         slot = GetFreeSlot(zone);  //Get the first empty slot in the array of that zone
  463.                         if(slot == -1)   //...if there is no empty slot available in the current zone
  464.                         {
  465.                             IsCreating = false;   // Disable the Creation-mode
  466.                             RPCreator = -1;            // Reset the playerid assigned to the RPCreator value
  467.                             SendClientMessage(playerid, 0xFF0000AA, "[Error] - The max amount of RoadPoints per zone has been reached!"); // Send error-message to the creator
  468.                             SendClientMessage(playerid, 0xFF0000AA, "Increae the MAX_ROADPOINTS_PER_ZONE define at the top of the filterscript and reload"); // Send error-message to the creator
  469.                             SendClientMessage(playerid, 0xFF0000AA, "Auto Creation of RoadPoints has been disabled"); // Send error-message to the creator
  470.                             return 1;
  471.                         }
  472.                         else
  473.                         {
  474.                             RP[zone][slot][X] = rX;  //Store the current X postion as the new RoadPoint X position
  475.                             RP[zone][slot][Y] = rY;  //Store the current Y postion as the new RoadPoint Y position
  476.                             RP[zone][slot][Z] = rZ;  //Store the current Z postion as the new RoadPoint Z position
  477.                             RP[zone][slot][A] = rA;  //Store the current angle as the new RoadPoint suppossed driving-direction.
  478.                             RP[zone][slot][D] = floatdiv(RoadWidth, 2.0);
  479.                             RP[zone][slot][ID] = TRP; // Set the ID of the new RoadPoint as current amount of RoadPoints
  480.                             RP[zone][slot][MapIconID] = CreateDynamicMapIcon(rX, rY, rZ, 56, 0, -1, -1, playerid, 300.0, MAPICON_LOCAL);
  481.                             RP[zone][slot][PickupID] = CreateDynamicPickup(1318, 23, rX, rY, rZ, -1, -1, playerid, 200.0);
  482.                             SaveRoadPoint(rX, rY, rZ, rA, RoadWidth);
  483.  
  484.                             TRP++;  //Increase the total amount of RoadPoints
  485.                             ATRP++;
  486.                             UpdateTextDraws(playerid);
  487.  
  488.                             lastX = vX;  // Store the current X-position in the lastX variable, to be used on the next update;
  489.                             lastY = vY;  // Store the current Y-position in the lastY variable, to be used on the next update;
  490.                             lastZ = vZ;  // Store the current Z-position in the lastZ variable, to be used on the next update;
  491.                         }
  492.  
  493.  
  494.  
  495.                     }
  496.                 }
  497.             }
  498.         }
  499.     }
  500.        
  501.     return 1;
  502. }
  503.  
  504. public OnPlayerEnterDynamicArea(playerid, areaid)
  505. {
  506.     CZ[playerid] = (areaid-1);
  507.     return 1;
  508. }
  509.  
  510. public OnPlayerLeaveDynamicArea(playerid, areaid)
  511. {
  512.     if(CZ[playerid] == (areaid-1))
  513.     {
  514.         CZ[playerid] = 144;
  515.     }
  516.     return 1;
  517. }
  518.  
  519. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  520. {
  521.     if(clickedid == Textdraw8)  // Delete RoadPoint
  522.     {
  523.         CancelSelectTextDraw(playerid);
  524.         new slot = GetPlayerRoadPointSlot(playerid);
  525.         if(slot == -1) return SendClientMessage(playerid, 0xFF0000AA, "[Error] - You are not near a RoadPoint)");
  526.         new rpID = GetPlayerRoadPointID(playerid);
  527.         if(rpID != -1)
  528.         {
  529.             new line = ffindLine(rpID);
  530.             fdeleteline("KYLRoadPoints.txt", line);
  531.             if(IsValidDynamicPickup(RP[CZ[playerid]][slot][PickupID]))
  532.             {
  533.                 DestroyDynamicPickup(RP[CZ[playerid]][slot][PickupID]);
  534.                 RP[CZ[playerid]][slot][PickupID] = -1;
  535.             }
  536.             if(IsValidDynamicMapIcon(RP[CZ[playerid]][slot][MapIconID]))
  537.             {
  538.                 DestroyDynamicMapIcon(RP[CZ[playerid]][slot][MapIconID]);
  539.                 RP[CZ[playerid]][slot][MapIconID] = -1;
  540.             }
  541.             RP[CZ[playerid]][slot][X] = 0.0;
  542.             RP[CZ[playerid]][slot][Y] = 0.0;
  543.             RP[CZ[playerid]][slot][Z] = 0.0;
  544.             RP[CZ[playerid]][slot][A] = 0.0;
  545.             RP[CZ[playerid]][slot][D] = 0.0;
  546.             RP[CZ[playerid]][slot][ID] = -1;
  547.             SendClientMessage(playerid, 0x00FF0000AA, "RoadPoint deleted");
  548.             ATRP--;
  549.         }
  550.         else
  551.         {
  552.             SendClientMessage(playerid, 0xFF0000AA, "[Error] - Invalid RoadPoint");
  553.         }
  554.     }
  555.    
  556.     if(clickedid == Textdraw2)  //Pauze/Enable
  557.     {
  558.         CancelSelectTextDraw(playerid);
  559.         if(IsPauzed == false)
  560.         {
  561.             IsPauzed = true;
  562.         }
  563.         else
  564.         {
  565.             IsPauzed = false;
  566.         }
  567.     }
  568.    
  569.     if(clickedid == Textdraw4)  // Smaller RoadType
  570.     {
  571.         if(RoadWidth > 1.0)
  572.         {
  573.             RoadWidth = floatsub(RoadWidth, 0.25);
  574.             if(RoadWidth < 1.0)
  575.             {
  576.                 RoadWidth = 1.0;
  577.             }
  578.         }
  579.         if(Double == true)
  580.         {
  581.             UpdateObjects(playerid, 1, 1);
  582.         }
  583.         else
  584.         {
  585.             UpdateObjects(playerid, 0, 0);
  586.         }
  587.     }
  588.  
  589.     if(clickedid == Textdraw6)  // LargerRoadType
  590.     {
  591.         RoadWidth = floatadd(RoadWidth, 0.25);
  592.         if(Double == true)
  593.         {
  594.             UpdateObjects(playerid, 1, 1);
  595.         }
  596.         else
  597.         {
  598.             UpdateObjects(playerid, 0, 0);
  599.         }
  600.  
  601.     }
  602.     if(clickedid == Textdraw9)   // Lower Distance
  603.     {
  604.         AutoCreateDistance = floatsub(AutoCreateDistance, 1.0);
  605.     }
  606.     if(clickedid == Textdraw13)  // Increase Distance
  607.     {
  608.         AutoCreateDistance = floatadd(AutoCreateDistance, 1.0);
  609.     }
  610.  
  611.     if(clickedid == Textdraw15)  // Enable/Disable Double
  612.     {
  613.         if(Double == true)
  614.         {
  615.             Double = false;
  616.             UpdateObjects(playerid, 1, 0);
  617.         }
  618.         else
  619.         {
  620.             Double = true;
  621.             UpdateObjects(playerid, 0, 1);
  622.         }
  623.     }
  624.     if(clickedid == Textdraw17)   // Decrease space
  625.     {
  626.         Space = floatsub(Space, 0.20);
  627.         if(Space < 0.2)
  628.         {
  629.             Space = 0.2;
  630.         }
  631.         UpdateObjects(playerid, 1, 1);
  632.     }
  633.  
  634.     if(clickedid == Textdraw18)  // Increase space
  635.     {
  636.         Space = floatadd(Space, 0.20);
  637.        
  638.         UpdateObjects(playerid, 1, 1);
  639.     }
  640.  
  641.     if(clickedid == Textdraw23)  // Preset 1;
  642.     {
  643.         RoadWidth = Preset[0][prewidth];
  644.         AutoCreateDistance = Preset[0][predistance];
  645.         Space = Preset[0][prespace];
  646.         if(Double == false)
  647.         {
  648.             if(Preset[0][predouble] == 1) { Double = true; UpdateObjects(playerid, 0, 1); }
  649.             else { Double = false; UpdateObjects(playerid, 0, 0); }
  650.         }
  651.         else
  652.         {
  653.             if(Preset[0][predouble] == 1) { Double = true; UpdateObjects(playerid, 1, 1); }
  654.             else { Double = false; UpdateObjects(playerid, 1, 0); }
  655.         }
  656.     }
  657.     if(clickedid == Textdraw24)  // Preset 2;
  658.     {
  659.         RoadWidth = Preset[1][prewidth];
  660.         AutoCreateDistance = Preset[1][predistance];
  661.         Space = Preset[1][prespace];
  662.         if(Double == false)
  663.         {
  664.             if(Preset[1][predouble] == 1) { Double = true; UpdateObjects(playerid, 0, 1); }
  665.             else { Double = false; UpdateObjects(playerid, 0, 0); }
  666.         }
  667.         else
  668.         {
  669.             if(Preset[1][predouble] == 1) { Double = true; UpdateObjects(playerid, 1, 1); }
  670.             else { Double = false; UpdateObjects(playerid, 1, 0); }
  671.         }
  672.     }
  673.     if(clickedid == Textdraw25)  // Preset 3;
  674.     {
  675.         RoadWidth = Preset[2][prewidth];
  676.         AutoCreateDistance = Preset[2][predistance];
  677.         Space = Preset[2][prespace];
  678.         if(Double == false)
  679.         {
  680.             if(Preset[2][predouble] == 1) { Double = true; UpdateObjects(playerid, 0, 1); }
  681.             else { Double = false; UpdateObjects(playerid, 0, 0); }
  682.         }
  683.         else
  684.         {
  685.             if(Preset[2][predouble] == 1) { Double = true; UpdateObjects(playerid, 1, 1); }
  686.             else { Double = false; UpdateObjects(playerid, 1, 0); }
  687.         }
  688.     }
  689.     if(clickedid == Textdraw26)  // Preset 4;
  690.     {
  691.         RoadWidth = Preset[3][prewidth];
  692.         AutoCreateDistance = Preset[3][predistance];
  693.         Space = Preset[3][prespace];
  694.         if(Double == false)
  695.         {
  696.             if(Preset[3][predouble] == 1) { Double = true; UpdateObjects(playerid, 0, 1); }
  697.             else { Double = false; UpdateObjects(playerid, 0, 0); }
  698.         }
  699.         else
  700.         {
  701.             if(Preset[3][predouble] == 1) {
  702.             Double = true; UpdateObjects(playerid, 1, 1); }
  703.             else { Double = false; UpdateObjects(playerid, 1, 0); }
  704.         }
  705.     }
  706.     if(clickedid == Textdraw27)  // Preset 1;
  707.     {
  708.         RoadWidth = Preset[4][prewidth];
  709.         AutoCreateDistance = Preset[4][predistance];
  710.         Space = Preset[4][prespace];
  711.         if(Double == false)
  712.         {
  713.             if(Preset[4][predouble] == 1) { Double = true; UpdateObjects(playerid, 0, 1); }
  714.             else { Double = false; UpdateObjects(playerid, 0, 0); }
  715.         }
  716.         else
  717.         {
  718.             if(Preset[4][predouble] == 1) { Double = true; UpdateObjects(playerid, 1, 1); }
  719.             else { Double = false; UpdateObjects(playerid, 1, 0); }
  720.         }
  721.     }
  722.     UpdateTextDraws(playerid);
  723.     return 1;
  724. }
  725.  
  726.  
  727. COMMAND:getzone(playerid, params[])
  728. {
  729.     new Float:x, Float:y, Float:z, zone;
  730.     GetPlayerPos(playerid, x, y, z);
  731.     zone = GetZone(x, y);
  732.     new str[32];
  733.     format(str, 32, "Zone: %d", zone);
  734.     SendClientMessage(playerid, -1, str);
  735.     return 1;
  736. }
  737.  
  738. COMMAND:createrp(playerid, params[])
  739. {
  740.     if(!IsPlayerAdmin(playerid)) return 0;
  741.     if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, 0xFF0000AA, "[Error] - You need to be driving a vehicle first!");
  742.     if(IsCreating == true)
  743.     {
  744.         IsCreating = false;
  745.         RPCreator = -1;
  746.         Double = false;
  747.         IsPauzed = true;
  748.         IsDeleting = false;
  749.        
  750.         HideTextDraws(playerid);
  751.        
  752.         UpdateObjects(playerid, 1, -1);
  753.        
  754.         SendClientMessage(playerid, 0x00FF00AA, "Auto RP-Creation Mode Disabled");
  755.         for(new zone; zone<145; zone++)
  756.         {
  757.             for(new slot; slot<MAX_ROADPOINTS_PER_ZONE; slot++)
  758.             {
  759.                 if(IsValidDynamicPickup(RP[zone][slot][PickupID]))
  760.                 {
  761.                     DestroyDynamicPickup(RP[zone][slot][PickupID]);
  762.                     RP[zone][slot][PickupID] = -1;
  763.                 }
  764.                 if(IsValidDynamicMapIcon(RP[zone][slot][MapIconID]))
  765.                 {
  766.                     DestroyDynamicMapIcon(RP[zone][slot][MapIconID]);
  767.                     RP[zone][slot][MapIconID] = -1;
  768.                 }
  769.             }
  770.         }
  771.         return 1;
  772.     }
  773.     RPCreator = playerid;
  774.     IsCreating = true;
  775.     IsPauzed = true;
  776.     for(new zone; zone<145; zone++)
  777.     {
  778.         for(new slot; slot<MAX_ROADPOINTS_PER_ZONE; slot++)
  779.         {
  780.             if((RP[zone][slot][X] != 0.0) && (RP[zone][slot][Y] != 0.0) && (RP[zone][slot][Z] != 0.0))
  781.             {
  782.                 RP[zone][slot][PickupID] = CreateDynamicPickup(1318, 23, RP[zone][slot][X], RP[zone][slot][Y], RP[zone][slot][Z], -1, -1, playerid, 200.0);
  783.                 RP[zone][slot][MapIconID] = CreateDynamicMapIcon(RP[zone][slot][X], RP[zone][slot][Y], RP[zone][slot][Z], 56, 0, -1, -1, playerid, 300.0, MAPICON_LOCAL);
  784.             }
  785.         }
  786.     }
  787.     if(Double == true) UpdateObjects(playerid, -1, 1);
  788.     else UpdateObjects(playerid, -1, 0);
  789.    
  790.     new Float:x, Float:y, Float:z;
  791.     GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  792.     SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  793.     UpdateTextDraws(playerid);
  794.     ShowTextDraws(playerid);
  795.    
  796.     return 1;
  797. }
  798.  
  799. COMMAND:deleterp(playerid, params[])
  800. {
  801.     if(RPCreator != playerid) return 0;
  802.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "[Error] - You need to be driving a vehicle first!");
  803.     IsPauzed = true;
  804.     IsDeleting = true;
  805.     SendClientMessage(playerid, -1, "You are now deleting every RoadPoint you drive through. To cancel, press the handbrake!");
  806.     UpdateTextDraws(playerid);
  807.     return 1;
  808. }
  809.  
  810. COMMAND:presets(playerid, params[])
  811. {
  812.     if(RPCreator != playerid) return 0;
  813.     if(ShowPresets == false)
  814.     {
  815.         ShowPresets = true;
  816.         TextDrawShowForPlayer(playerid, Textdraw21);
  817.         TextDrawShowForPlayer(playerid, Textdraw22);
  818.         TextDrawShowForPlayer(playerid, Textdraw23);
  819.         TextDrawShowForPlayer(playerid, Textdraw24);
  820.         TextDrawShowForPlayer(playerid, Textdraw25);
  821.         TextDrawShowForPlayer(playerid, Textdraw26);
  822.         TextDrawShowForPlayer(playerid, Textdraw27);
  823.     }
  824.     else
  825.     {
  826.         ShowPresets = false;
  827.         TextDrawHideForPlayer(playerid, Textdraw21);
  828.         TextDrawHideForPlayer(playerid, Textdraw22);
  829.         TextDrawHideForPlayer(playerid, Textdraw23);
  830.         TextDrawHideForPlayer(playerid, Textdraw24);
  831.         TextDrawHideForPlayer(playerid, Textdraw25);
  832.         TextDrawHideForPlayer(playerid, Textdraw26);
  833.         TextDrawHideForPlayer(playerid, Textdraw27);
  834.     }
  835.     UpdateTextDraws(playerid);
  836.     return 1;
  837. }
  838.  
  839. COMMAND:savepreset(playerid, params[])
  840. {
  841.     if(RPCreator != playerid) return 0;
  842.     new slot;
  843.     if(sscanf(params, "d", slot)) return SendClientMessage(playerid, 0xFF0000FF, "Error: Use /savepreset [1-5]");
  844.     if((slot < 1) || (slot > 5)) return SendClientMessage(playerid, 0xFF0000FF, "Error: Use /savepreset [1-5]");
  845.     slot--;
  846.     if(Double == true)
  847.     {
  848.         Preset[slot][predouble] = 1;
  849.         format(Preset[slot][predoublestr], 12, "Double");
  850.     }
  851.     else
  852.     {
  853.         Preset[slot][predouble] = 0;
  854.         format(Preset[slot][predoublestr], 12, "Single");
  855.     }
  856.     Preset[slot][prewidth] = RoadWidth;
  857.     Preset[slot][predistance] = AutoCreateDistance;
  858.     Preset[slot][prespace] = Space;
  859.     SendClientMessage(playerid, -1, "Preset saved");
  860.     UpdateTextDraws(playerid);
  861.     SavePresets();
  862.     return 1;
  863. }
  864.  
  865. COMMAND:straight(playerid, params[])
  866. {
  867.     if(RPCreator != playerid) return 0;
  868.     new Float:vA, vid = GetPlayerVehicleID(playerid);
  869.     GetVehicleZAngle(vid, vA);
  870.     if((vA >= 315) || (vA < 45)) SetVehicleZAngle(vid, 0.0);
  871.     if((vA >= 45) && (vA < 135)) SetVehicleZAngle(vid, 90.0);
  872.     if((vA >= 135) && (vA < 225)) SetVehicleZAngle(vid, 180.0);
  873.     if((vA >= 225) && (vA < 315)) SetVehicleZAngle(vid, 270.0);
  874.     return 1;
  875. }
  876.  
  877. stock GetZone(Float:vX, Float:vY)  // This function returns the zone-number based on given X- and Y-coord.
  878. {
  879.     for(new i=1; i<145; i++)
  880.     {
  881.         if(IsPointInDynamicArea(i, vX, vY, 0.0)) return (i-1); //Return the zone (0-143)
  882.     }
  883.     return 144; // Return oceanzone (144)
  884. }
  885.  
  886. stock ResetRoadPointInfo()  // This Function will reset all RoadPoint-related variables and destroys the pickups.
  887. {
  888.     for(new zone; zone<145; zone++) // Loop through all 37 zones.
  889.     {
  890.         for(new slot; slot<MAX_ROADPOINTS_PER_ZONE; slot++)  // Loop through each slot in current zone
  891.         {
  892.             RP[zone][slot][X] = 0.0;  //Reset X Coordinate
  893.             RP[zone][slot][Y] = 0.0;  //Reset Y Coordinate
  894.             RP[zone][slot][Z] = 0.0;  //Reset Z Coordinate
  895.             RP[zone][slot][A] = 0.0;  //Reset Angle
  896.             RP[zone][slot][D] = 0;  //Reset Max Distance
  897.             RP[zone][slot][ID] = -1;  //Reset ID
  898.             RP[zone][slot][PickupID] = -1; //Reset pickup IDif(IsValidDynamicMapIcon(RP[zone][slot][MapIconID]))
  899.             RP[zone][slot][MapIconID] = -1;
  900.         }
  901.     }
  902.     return 1;
  903. }
  904.  
  905. stock SaveRoadPoint(Float:rX, Float:rY, Float:rZ, Float:rA, Float:width) // This function writes the newly created RoadPoint to the KYLRoadPoints.txt file
  906. {
  907.     new File:file=fopen("KYLRoadPoints.txt", io_append);  // Open the file
  908.     new str[64];  // Create new strin
  909.     format(str, sizeof(str), "%.3f %.3f %.3f %.2f %.2f\r\n", rX, rY, rZ, rA, floatdiv(width, 2.0)); // format the string to contain the X, Y, Z coordinates, angle and distance
  910.     fwrite(file, str);  // Write the string to the file
  911.     fclose(file);  // Close the file
  912. }
  913.  
  914. stock ReadRoadPoints() //  This function will read and load all RoadPoints from the KYLRoadPoints.txt file
  915. {
  916.     new File:file;
  917.     if (!fexist("KYLRoadPoints.txt"))
  918.     {
  919.         file = fopen("KYLRoadPoints.txt",io_write);
  920.         fclose(file);
  921.     }
  922.     file=fopen("KYLRoadPoints.txt", io_read);
  923.     new str[64], zone, slot;  // Create new variables to store the string, zone and slot
  924.     new Float:rX, Float:rY, Float:rZ, Float:rA, Float:rType; // Create new temprorarily variables to store the coordinates, angle and distance
  925.     while(fread(file, str))  // Loop through each line in the file
  926.     {
  927.         sscanf(str, "fffff", rX, rY, rZ, rA, rType);  // Retrieve all values from the line and store them in the temporarily variables
  928.         {
  929.             zone = GetZone(rX, rY);  // Get the zone ID based on the X and Y coordinate
  930.             slot = GetFreeSlot(zone);  // Get the ID of the first free slot in this zone
  931.             if(slot != -1)   // If there is an empty slot found
  932.             {
  933.                 RP[zone][slot][X] = rX;  // Store the temporarily X value in the global array
  934.                 RP[zone][slot][Y] = rY;  // Store the temporarily Y value in the global array
  935.                 RP[zone][slot][Z] = rZ;  // Store the temporarily Z value in the global array
  936.                 RP[zone][slot][A] = rA;  // Store the temporarily angle in the global array
  937.                 RP[zone][slot][D] = rType;  // Store the temporarily distance in the global array
  938.                 RP[zone][slot][ID] = TRP; // Give the new RoadPoint an unique ID (based on total amount of created RoadPoints)
  939.                 TRP++;  // Increae number of total created RoadPoints by 1
  940.                 ATRP++;
  941.                 RPInZone[zone]++;
  942.             }
  943.             else  // if no empty slot is found in the current zone:
  944.             {
  945.                 //Send error message to the ServerLog
  946.                 print("------------------------------------------------------------------");
  947.                 printf("FATAL ERROR: Too many RoadPoints in Zone #%02d (Limit: %d)", zone, MAX_ROADPOINTS_PER_ZONE);
  948.                 print("Loading of the RoadPoints has failed");
  949.                 print("Increase the value of MAX_ROADPOINTS_PER_ZONE");
  950.                 print("at the top of the filterscript and reload");
  951.                 print("------------------------------------------------------------------");
  952.                 ResetRoadPointInfo(); // Reset all RoadPoints related info.
  953.                 fclose(file); // Close the fille
  954.                 return 0; // Abort the function
  955.             }
  956.         }
  957.     }
  958.     fclose(file);  // Close the file
  959.     printf("%d roadpoints loaded", TRP); // Show in ServerLog the total amound of created RoadPoints.
  960.     return 1;
  961. }
  962.  
  963. stock ReadTrainPoints() //  This function will read and load all RoadPoints from the KYLRoadPoints.txt file
  964. {
  965.     new File:file;
  966.     if (!fexist("KYLTrainRoadPoints.txt"))
  967.     {
  968.         file = fopen("KYLTrainRoadPoints.txt",io_write);
  969.         fclose(file);
  970.     }
  971.     file=fopen("KYLTrainRoadPoints.txt", io_read);
  972.     new str[64], zone, slot;  // Create new variables to store the string, zone and slot
  973.     new Float:rX, Float:rY, Float:rZ, Float:rD; // Create new temprorarily variables to store the coordinates, angle and distance
  974.     while(fread(file, str))  // Loop through each line in the file
  975.     {
  976.         sscanf(str, "ffff", rX, rY, rZ, rD);  // Retrieve all values from the line and store them in the temporarily variables
  977.         {
  978.             zone = GetZone(rX, rY);  // Get the zone ID based on the X and Y coordinate
  979.             slot = TPInZone[zone];
  980.             if(slot != 90)   // If there is an empty slot found
  981.             {
  982.                 TP[zone][slot][tpX] = rX;  // Store the temporarily X value in the global array
  983.                 TP[zone][slot][tpY] = rY;  // Store the temporarily Y value in the global array
  984.                 TP[zone][slot][tpZ] = rZ;  // Store the temporarily Z value in the global array
  985.                 TP[zone][slot][tpD] = rD-1.0;  // Store the temporarily distance in the global array
  986.                 TPInZone[zone]++;
  987.             }
  988.         }
  989.     }
  990.     fclose(file);  // Close the file
  991.     return 1;
  992. }
  993.  
  994. ffindLine(rpID)  // This function returns the line in KYLRoadPoints.txt which contains all info of the RoadPoints with the given ID.
  995. {
  996.     new line = -1;  // Create varibale to store the linenumber and set it to -1 to start with
  997.     new rpzone = -1, rpslot = -1;  // Create variables to store the zone and slot the RoadPoint is stored in
  998.     for(new zone; zone<145; zone++)  // Loop through all 37 zones
  999.     {
  1000.         for(new slot; slot<MAX_ROADPOINTS_PER_ZONE; slot++)  // In each zone loop through all slots
  1001.         {
  1002.             if(RP[zone][slot][ID] == rpID)  // If the ID stored in the current zone and slot matches the given ID...
  1003.             {
  1004.                 rpzone = zone; // Store the zone-number in the rpzone variable
  1005.                 rpslot = slot; // Store the slot-number in the rpslot variable
  1006.                 break; // Stop the loop.
  1007.             }
  1008.         }
  1009.     }
  1010.    
  1011.     if((rpzone != -1) && (rpslot != -1))  // Check if a matching zone and slot has been found
  1012.     {
  1013.         new str[64]; // Create new string
  1014.         new count = -1; // Create variable that counts the number of lines that has been compared
  1015.         new File:file=fopen("KYLRoadPoints.txt", io_read);  // Open the file
  1016.         new Float:rX, Float:rY, Float:rZ;  // Create variables to temporarily store the coordintes from each line in the file
  1017.         while(fread(file, str))  // Loop through all lines in the file
  1018.         {
  1019.             count++;  // Increae count by 1
  1020.             sscanf(str, "fff", rX, rY, rZ);  // Retrieve the first 3 values from the line and store them in the temporarily variables
  1021.             {
  1022.                 if((floatround(RP[rpzone][rpslot][X]) == floatround(rX)) && (floatround(RP[rpzone][rpslot][Y]) == floatround(rY)) && (floatround(RP[rpzone][rpslot][Z]) == floatround(rZ)))
  1023.                 {
  1024.                     line = (count+1);  // If the coordinates match set the line-variable to the current count
  1025.                     break;
  1026.                 }
  1027.             }
  1028.         }
  1029.         fclose(file); // Close the file
  1030.     }
  1031.     return line; // Return the line-number
  1032. }
  1033.  
  1034.  
  1035.  
  1036. forward Float:GetDistance(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2);
  1037. stock Float:GetDistance(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)  // This function calculates and returns the distance between 2 points.
  1038. {
  1039.     return floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) );
  1040. }
  1041.  
  1042. forward CheckRoadPoints();
  1043. public CheckRoadPoints()   // This is the main function that checks the players position and sees if he's driving on the wrong side of the road:
  1044. {
  1045.     new slot, rtrn; // Create some variables to temporarily store values.
  1046.     for(new i; i<MAX_PLAYERS; i++) // Loop through all players
  1047.     {
  1048.         if(i == RPCreator)  // If the playerid is currently creating new RoadPoints, update the textdraws:
  1049.         {
  1050.             UpdateTextDraws(i);
  1051.         }
  1052.        
  1053.         if(GetPlayerState(i) == PLAYER_STATE_DRIVER) // Check if the player is driving a vehicle
  1054.         {
  1055.             // My original plan was to only scan the players current zone for RoadPoints and check if the player is near any of them, but it caused problems when...
  1056.             //... because RoadPoints near its zone-border wont get triggered if the player is within reach, but on the other side of the border (in an different zone)...
  1057.             //... To solve this problem this script will not only scan the players current zone, but also the 4 surrounding zones for RoadPoints (if none have been found already).
  1058.  
  1059.             // I created the funtion 'IsPlayerOnWrongWay' to check if the player is near a Roadpoint and, if so, check if the player is driving the right or wrong direction.
  1060.             // It will return '-1' if the player is not near any roadpoint in the given zone. Return '0' if the player is near a RoadPoint, but driving the right direction...
  1061.             //..and it will return '1' if the player is near a RoadPoint AND driving the wrong direction.
  1062.             //... this function also returns the slot of the found RoadPoint.
  1063.            
  1064.             rtrn = IsPlayerOnWrongWay(i, CZ[i], slot);   // Check if the player is near any RoadPoint in his current zone.
  1065.             //// If the player is Ghost Driving, the remote callback 'OnPlayerGhostDriving' will be called (in your gamemode), it passes the playerid, zone, XYZ-coords and angle of the RoadPoint
  1066.             if(rtrn == 1) CallRemoteFunction("OnPlayerGhostDriving", "ddffff", i, CZ[i], RP[CZ[i]][slot][X], RP[CZ[i]][slot][Y], RP[CZ[i]][slot][Z], RP[CZ[i]][slot][A]);
  1067.             else if(rtrn == -1)  // If no close RoadPoint is found... scan the next surrounding zone and repeat if for all 4 surrounding zones (unless a point is found.
  1068.             {
  1069.                 new zone = CZ[i]+1;
  1070.                 rtrn = IsPlayerOnWrongWay(i, zone, slot);
  1071.                 if(rtrn == 1) CallRemoteFunction("OnPlayerGhostDriving", "ddffff", i, zone, RP[zone][slot][X], RP[zone][slot][Y], RP[zone][slot][Z], RP[zone][slot][A]);
  1072.                 else if(rtrn == -1)
  1073.                 {
  1074.                     zone = CZ[i]-1;
  1075.                     rtrn = IsPlayerOnWrongWay(i, zone, slot);
  1076.                     if(rtrn == 1) CallRemoteFunction("OnPlayerGhostDriving", "ddffff", i, zone, RP[zone][slot][X], RP[zone][slot][Y], RP[zone][slot][Z], RP[zone][slot][A]);
  1077.                     else if(rtrn == -1)
  1078.                     {
  1079.                         zone = CZ[i]+12;
  1080.                         rtrn = IsPlayerOnWrongWay(i, zone, slot);
  1081.                         if(rtrn == 1) CallRemoteFunction("OnPlayerGhostDriving", "ddffff", i, zone, RP[zone][slot][X], RP[zone][slot][Y], RP[zone][slot][Z], RP[zone][slot][A]);
  1082.                         else if(rtrn == -1)
  1083.                         {
  1084.                             zone = CZ[i]-12;
  1085.                             rtrn = IsPlayerOnWrongWay(i, zone, slot);
  1086.                             if(rtrn == 1) CallRemoteFunction("OnPlayerGhostDriving", "ddffff", i, zone, RP[zone][slot][X], RP[zone][slot][Y], RP[zone][slot][Z], RP[zone][slot][A]);
  1087.                         }
  1088.                     }
  1089.                 }
  1090.             }
  1091.             if(AllowTrainTrackDriving == false)
  1092.             {
  1093.                 new model = GetVehicleModel(GetPlayerVehicleID(i));
  1094.                 if((model != 537) && (model !=538))
  1095.                 {
  1096.                     for(slot = 0; slot<90; slot++)  // Loop through all RoadPoints in the given zone
  1097.                     {
  1098.                         if(IsPlayerInRangeOfPoint(i, TP[CZ[i]][slot][tpD], TP[CZ[i]][slot][tpX], TP[CZ[i]][slot][tpY], TP[CZ[i]][slot][tpZ])) // Check if player is in range of the RoadPoint
  1099.                         {
  1100.                             CallRemoteFunction("OnPlayerDrivingOnTrainTrack", "ddfff", i, CZ[i], TP[CZ[i]][slot][tpX], TP[CZ[i]][slot][tpY], TP[CZ[i]][slot][tpZ]);
  1101.                         }
  1102.                     }
  1103.                 }
  1104.             }
  1105.         }
  1106.     }
  1107.     return 1;
  1108. }
  1109.  
  1110. // This function will scan the given zone for RoadPoints and check if the given player is near them and driving in the right or wrong direction...
  1111. //.. it will return the slot of the Roadpoint in that zone and will return -1, 0, or 1, depending on if any points are found.
  1112. IsPlayerOnWrongWay(playerid, zone, &slot)
  1113. {
  1114.     new Float:cA, Float:MinAngle, Float:MaxAngle;
  1115.     new isfound = -1;  // On default no RoadPoint is found near the player
  1116.     for(slot = 0; slot<MAX_ROADPOINTS_PER_ZONE; slot++)  // Loop through all RoadPoints in the given zone
  1117.     {
  1118.         if(IsPlayerInRangeOfPoint(playerid, RP[zone][slot][D], RP[zone][slot][X], RP[zone][slot][Y], RP[zone][slot][Z])) // Check if player is in range of the RoadPoint
  1119.         {
  1120.             isfound = 0; // Set the variable to '0', this means the player is near a RoadPoint, now we should check if the player is driving the right/wrong direction:
  1121.             GetVehicleZAngle(GetPlayerVehicleID(playerid), cA);  // Get the current driving direction of the player
  1122.             cA = floatsub(cA, 180);  // Invert the direction by subtracting 180 degrees.
  1123.             if(cA < 0)  // check if the angle is below '0'
  1124.             {
  1125.                 cA = floatadd(cA, 360.0);  // add 360 to get it above 0 degrees again.
  1126.             }
  1127.             MinAngle = floatsub(RP[zone][slot][A], ANGLE_TOLERANCE); // Calculate the minimum angle by subtracting the angle tolerance (defined at top of this script)
  1128.             MaxAngle = floatadd(RP[zone][slot][A], ANGLE_TOLERANCE); // Calculate the maximum angle by adding the angle tolerance (defined at top of this script)
  1129.             if((cA > MinAngle) && (cA < MaxAngle))  // Check if the players driving direction is between the mininmum and maximum angle (if yes, he's driving in the wrong direction)
  1130.             {
  1131.                 isfound = 1; // If the player is indeed Ghost Driving, set the varible to '1'.
  1132.             }
  1133.             break; // stop the loop.
  1134.         }
  1135.     }
  1136.     return isfound; // Return the result
  1137. }
  1138.    
  1139.  
  1140. GetPlayerRoadPointSlot(playerid) // This function checks if the player is in range of any RoadPoint and returns its slot ID  (returns -1 if not in range of any point).
  1141. {
  1142.     if(!IsPlayerInAnyVehicle(playerid)) return -1;
  1143.     new rp = -1;
  1144.     for(new slot; slot<MAX_ROADPOINTS_PER_ZONE; slot++)
  1145.     {
  1146.         if(IsPlayerInRangeOfPoint(playerid, 2, RP[CZ[playerid]][slot][X], RP[CZ[playerid]][slot][Y], RP[CZ[playerid]][slot][Z]))
  1147.         {
  1148.             rp = slot;
  1149.         }
  1150.     }
  1151.     return rp;
  1152. }
  1153.  
  1154. stock GetPlayerRoadPointID(playerid)  // This function checks if the player is in range of any RoadPoint and returns its unique ID. (Returns -1 if the player is not in range of any RoadPoint)
  1155. {
  1156.     new slot = GetPlayerRoadPointSlot(playerid);
  1157.     if(slot == -1)
  1158.     {
  1159.         return -1;
  1160.     }
  1161.     else
  1162.     {
  1163.         return RP[CZ[playerid]][slot][ID];
  1164.     }
  1165. }
  1166.  
  1167. stock GetFreeSlot(zone) // This funtion returns the ID of the first empty slot in the given zone. (Returns -1 if no empty slot is found in this zone).
  1168. {
  1169.     new freeslot = -1;
  1170.     for(new slot; slot<MAX_ROADPOINTS_PER_ZONE; slot++)
  1171.     {
  1172.         if(RP[zone][slot][ID] == -1)
  1173.         {
  1174.             freeslot = slot;
  1175.             break;
  1176.         }
  1177.     }
  1178.     return freeslot;
  1179. }
  1180.  
  1181. stock GetLargestZone() // This function returns the zone ID which holds the most RoadPoints. (Used in the CheckEfficiency function).
  1182. {
  1183.     new largestzone = -1;
  1184.     new highestvalue = -1, tmp;
  1185.     for(new zone; zone<145; zone++)
  1186.     {
  1187.         tmp = GetFreeSlot(zone);
  1188.         if(tmp == -1)  //Zone is full
  1189.         {
  1190.             largestzone = zone;
  1191.             highestvalue = MAX_ROADPOINTS_PER_ZONE;
  1192.         }
  1193.         if(tmp > highestvalue)
  1194.         {
  1195.             largestzone = zone;
  1196.             highestvalue = tmp;
  1197.         }
  1198.     }
  1199.     return largestzone;
  1200. }
  1201.  
  1202. forward CheckEfficiency();
  1203. public CheckEfficiency() // This function will check if the defined value of MAX_ROADPOINTS_PER_ZONE is optimal
  1204. {
  1205.     new zone = GetLargestZone();  // Retreive the zone which holds the most RoadPoints
  1206.     new amount = GetFreeSlot(zone);  // Get the amount of RoadPoints in that zone.
  1207.     if((amount <= MAX_ROADPOINTS_PER_ZONE) && (amount > 1))  // Check if this amount is lower than the defined MAX_ROADPOINTS_PER_ZONE
  1208.     {
  1209.         // If so, send a message to the serverlog suggesting the optimal value:
  1210.         print("------------------------------------------------------------------");
  1211.         print("[TIP]: If you are done with creating new RoadPoints you can");
  1212.         print("increase your server's performance by lowering the value");
  1213.         printf("of 'MAX_ROADPOINTS_PER_ZONE' to %d at the top of the Filterscript", amount);
  1214.         print("-------------------------------------------------------------------");
  1215.     }
  1216.     return 1;
  1217. }
  1218.  
  1219. fdeleteline(filename[], line)  // This functions deletes the given line from the file (Function created by: Sacky)
  1220. {
  1221.  
  1222.   new count, string[256], File:file, File:temp;
  1223.   file= fopen(filename, io_read);
  1224.   temp = fopen("tmpfile.tmp", io_write);
  1225.  
  1226.   while (fread(file, string))
  1227.     if (++count != line)
  1228.       fwrite(temp, string);
  1229.  
  1230.   fclose(file);
  1231.   fclose(temp);
  1232.  
  1233.   file= fopen(filename, io_write);
  1234.   temp = fopen("tmpfile.tmp", io_read);
  1235.  
  1236.   while (fread(temp, string))
  1237.     fwrite(file, string);
  1238.  
  1239.   fclose(file);
  1240.   fclose(temp);
  1241.   fremove("tmpfile.tmp");
  1242. }
  1243.  
  1244. stock ShowTextDraws(playerid)
  1245. {
  1246.     TextDrawShowForPlayer(playerid, Textdraw0);
  1247.     TextDrawShowForPlayer(playerid, Textdraw1);
  1248.     TextDrawShowForPlayer(playerid, Textdraw2);
  1249.     TextDrawShowForPlayer(playerid, Textdraw3);
  1250.     TextDrawShowForPlayer(playerid, Textdraw4);
  1251.     TextDrawShowForPlayer(playerid, Textdraw5);
  1252.     TextDrawShowForPlayer(playerid, Textdraw6);
  1253.     TextDrawShowForPlayer(playerid, Textdraw7);
  1254.     TextDrawShowForPlayer(playerid, Textdraw8);
  1255.     TextDrawShowForPlayer(playerid, Textdraw9);
  1256.     TextDrawShowForPlayer(playerid, Textdraw10);
  1257.     TextDrawShowForPlayer(playerid, Textdraw11);
  1258.     TextDrawShowForPlayer(playerid, Textdraw12);
  1259.     TextDrawShowForPlayer(playerid, Textdraw13);
  1260.     TextDrawShowForPlayer(playerid, Textdraw14);
  1261.     TextDrawShowForPlayer(playerid, Textdraw15);
  1262.     if(Double == true)
  1263.     {
  1264.         TextDrawShowForPlayer(playerid, Textdraw16);
  1265.         TextDrawShowForPlayer(playerid, Textdraw17);
  1266.         TextDrawShowForPlayer(playerid, Textdraw18);
  1267.         TextDrawShowForPlayer(playerid, Textdraw19);
  1268.         TextDrawShowForPlayer(playerid, Textdraw20);
  1269.     }
  1270.     return 1;
  1271. }
  1272.  
  1273. stock HideTextDraws(playerid)
  1274. {
  1275.     TextDrawHideForPlayer(playerid, Textdraw0);
  1276.     TextDrawHideForPlayer(playerid, Textdraw1);
  1277.     TextDrawHideForPlayer(playerid, Textdraw2);
  1278.     TextDrawHideForPlayer(playerid, Textdraw3);
  1279.     TextDrawHideForPlayer(playerid, Textdraw4);
  1280.     TextDrawHideForPlayer(playerid, Textdraw5);
  1281.     TextDrawHideForPlayer(playerid, Textdraw6);
  1282.     TextDrawHideForPlayer(playerid, Textdraw7);
  1283.     TextDrawHideForPlayer(playerid, Textdraw8);
  1284.     TextDrawHideForPlayer(playerid, Textdraw9);
  1285.     TextDrawHideForPlayer(playerid, Textdraw10);
  1286.     TextDrawHideForPlayer(playerid, Textdraw11);
  1287.     TextDrawHideForPlayer(playerid, Textdraw12);
  1288.     TextDrawHideForPlayer(playerid, Textdraw13);
  1289.     TextDrawHideForPlayer(playerid, Textdraw14);
  1290.     TextDrawHideForPlayer(playerid, Textdraw15);
  1291.     TextDrawHideForPlayer(playerid, Textdraw16);
  1292.     TextDrawHideForPlayer(playerid, Textdraw17);
  1293.     TextDrawHideForPlayer(playerid, Textdraw18);
  1294.     TextDrawHideForPlayer(playerid, Textdraw19);
  1295.     TextDrawHideForPlayer(playerid, Textdraw20);
  1296.     TextDrawHideForPlayer(playerid, Textdraw21);
  1297.     TextDrawHideForPlayer(playerid, Textdraw22);
  1298.     TextDrawHideForPlayer(playerid, Textdraw23);
  1299.     TextDrawHideForPlayer(playerid, Textdraw24);
  1300.     TextDrawHideForPlayer(playerid, Textdraw25);
  1301.     TextDrawHideForPlayer(playerid, Textdraw26);
  1302.     TextDrawHideForPlayer(playerid, Textdraw27);
  1303.     return 1;
  1304. }
  1305.    
  1306.  
  1307.  
  1308. stock UpdateTextDraws(playerid)
  1309. {
  1310.     TextDrawHideForPlayer(playerid, Textdraw2);
  1311.     TextDrawHideForPlayer(playerid, Textdraw5);
  1312.     TextDrawHideForPlayer(playerid, Textdraw10);
  1313.     TextDrawHideForPlayer(playerid, Textdraw12);
  1314.     TextDrawHideForPlayer(playerid, Textdraw15);
  1315.     if(Double == true)
  1316.     {
  1317.         TextDrawHideForPlayer(playerid, Textdraw16);
  1318.         TextDrawHideForPlayer(playerid, Textdraw17);
  1319.         TextDrawHideForPlayer(playerid, Textdraw18);
  1320.         TextDrawHideForPlayer(playerid, Textdraw19);
  1321.         TextDrawHideForPlayer(playerid, Textdraw20);
  1322.         TextDrawColor(Textdraw15, TD_BRIGHTGREEN);
  1323.         format(td15str, sizeof(td15str), "ON");
  1324.         format(td19str, sizeof(td19str), "%.2f", Space);
  1325.         TextDrawSetString(Textdraw19, td19str);
  1326.         TextDrawShowForPlayer(playerid, Textdraw16);
  1327.         TextDrawShowForPlayer(playerid, Textdraw17);
  1328.         TextDrawShowForPlayer(playerid, Textdraw18);
  1329.         TextDrawShowForPlayer(playerid, Textdraw19);
  1330.         TextDrawShowForPlayer(playerid, Textdraw20);
  1331.     }
  1332.     else
  1333.     {
  1334.         TextDrawHideForPlayer(playerid, Textdraw15);
  1335.         TextDrawHideForPlayer(playerid, Textdraw16);
  1336.         TextDrawHideForPlayer(playerid, Textdraw17);
  1337.         TextDrawHideForPlayer(playerid, Textdraw18);
  1338.         TextDrawHideForPlayer(playerid, Textdraw19);
  1339.         TextDrawHideForPlayer(playerid, Textdraw20);
  1340.         TextDrawColor(Textdraw15, TD_BRIGHTRED);
  1341.         format(td15str, sizeof(td15str), "OFF");
  1342.     }
  1343.     if(IsDeleting == true)
  1344.     {
  1345.         format(td2str, sizeof(td2str), "DELETING!");
  1346.         TextDrawColor(Textdraw2, TD_BRIGHTRED);
  1347.     }
  1348.     else
  1349.     {
  1350.         if(IsPauzed == false)
  1351.         {
  1352.             format(td2str, sizeof(td2str), "Enabled");
  1353.             TextDrawColor(Textdraw2, TD_BRIGHTGREEN);
  1354.         }
  1355.         else
  1356.         {
  1357.             format(td2str, sizeof(td2str), "Pauzed");
  1358.             TextDrawColor(Textdraw2, TD_BRIGHTRED);
  1359.         }
  1360.     }
  1361.     format(td5str, sizeof(td5str), "%.2f", RoadWidth);
  1362.     format(td10str, sizeof(td10str), "%.2f", AutoCreateDistance);
  1363.     format(td12str, sizeof(td12str), "%d", ATRP);
  1364.     TextDrawSetString(Textdraw2, td2str);
  1365.     TextDrawSetString(Textdraw5, td5str);
  1366.     TextDrawSetString(Textdraw10, td10str);
  1367.     TextDrawSetString(Textdraw12, td12str);
  1368.     TextDrawSetString(Textdraw15, td15str);
  1369.     TextDrawShowForPlayer(playerid, Textdraw2);
  1370.     TextDrawShowForPlayer(playerid, Textdraw5);
  1371.     TextDrawShowForPlayer(playerid, Textdraw10);
  1372.     TextDrawShowForPlayer(playerid, Textdraw12);
  1373.     TextDrawShowForPlayer(playerid, Textdraw15);
  1374.     if(ShowPresets == true)
  1375.     {
  1376.         format(pre1str, sizeof(pre1str), "#1: %s - %.2f - %.2f - %.2f", Preset[0][predoublestr], Preset[0][prewidth], Preset[0][predistance], Preset[0][prespace]);
  1377.         format(pre2str, sizeof(pre2str), "#2: %s - %.2f - %.2f - %.2f", Preset[1][predoublestr], Preset[1][prewidth], Preset[1][predistance], Preset[1][prespace]);
  1378.         format(pre3str, sizeof(pre3str), "#3: %s - %.2f - %.2f - %.2f", Preset[2][predoublestr], Preset[2][prewidth], Preset[2][predistance], Preset[2][prespace]);
  1379.         format(pre4str, sizeof(pre4str), "#4: %s - %.2f - %.2f - %.2f", Preset[3][predoublestr], Preset[3][prewidth], Preset[3][predistance], Preset[3][prespace]);
  1380.         format(pre5str, sizeof(pre5str), "#5: %s - %.2f - %.2f - %.2f", Preset[4][predoublestr], Preset[4][prewidth], Preset[4][predistance], Preset[4][prespace]);
  1381.         TextDrawHideForPlayer(playerid, Textdraw23);
  1382.         TextDrawHideForPlayer(playerid, Textdraw24);
  1383.         TextDrawHideForPlayer(playerid, Textdraw25);
  1384.         TextDrawHideForPlayer(playerid, Textdraw26);
  1385.         TextDrawHideForPlayer(playerid, Textdraw27);
  1386.         TextDrawSetString(Textdraw23, pre1str);
  1387.         TextDrawSetString(Textdraw24, pre2str);
  1388.         TextDrawSetString(Textdraw25, pre3str);
  1389.         TextDrawSetString(Textdraw26, pre4str);
  1390.         TextDrawSetString(Textdraw27, pre5str);
  1391.         TextDrawShowForPlayer(playerid, Textdraw23);
  1392.         TextDrawShowForPlayer(playerid, Textdraw24);
  1393.         TextDrawShowForPlayer(playerid, Textdraw25);
  1394.         TextDrawShowForPlayer(playerid, Textdraw26);
  1395.         TextDrawShowForPlayer(playerid, Textdraw27);
  1396.     }
  1397.     return 1;
  1398. }
  1399.    
  1400. CreateTextDraws()
  1401. {
  1402.     Textdraw0 = TextDrawCreate(322.000000, 451.000000, "~n~");    // Background Box
  1403.     TextDrawAlignment(Textdraw0, 2);
  1404.     TextDrawBackgroundColor(Textdraw0, 255);
  1405.     TextDrawFont(Textdraw0, 1);
  1406.     TextDrawLetterSize(Textdraw0, -0.559997, -2.599998);
  1407.     TextDrawColor(Textdraw0, -1);
  1408.     TextDrawSetOutline(Textdraw0, 0);
  1409.     TextDrawSetProportional(Textdraw0, 1);
  1410.     TextDrawSetShadow(Textdraw0, 1);
  1411.     TextDrawUseBox(Textdraw0, 1);
  1412.     TextDrawBoxColor(Textdraw0, 150);
  1413.     TextDrawTextSize(Textdraw0, 35.000000, 642.000000);
  1414.     TextDrawSetSelectable(Textdraw0, 0);
  1415.  
  1416.     Textdraw1 = TextDrawCreate(13.000000, 432.000000, "~y~RoadPoint Creator:");
  1417.     TextDrawBackgroundColor(Textdraw1, 255);
  1418.     TextDrawFont(Textdraw1, 1);
  1419.     TextDrawLetterSize(Textdraw1, 0.200000, 1.200000);
  1420.     TextDrawColor(Textdraw1, -1);
  1421.     TextDrawSetOutline(Textdraw1, 1);
  1422.     TextDrawSetProportional(Textdraw1, 1);
  1423.     TextDrawSetSelectable(Textdraw1, 0);
  1424.  
  1425.     Textdraw2 = TextDrawCreate(83.000000, 432.000000, td2str);         //Current Status  (Pauzed/Enabled)
  1426.     TextDrawBackgroundColor(Textdraw2, 255);
  1427.     TextDrawFont(Textdraw2, 1);
  1428.     TextDrawLetterSize(Textdraw2, 0.310000, 1.200000);
  1429.     TextDrawColor(Textdraw2, -1);
  1430.     TextDrawSetOutline(Textdraw2, 1);
  1431.     TextDrawSetProportional(Textdraw2, 1);
  1432.     TextDrawUseBox(Textdraw2, 1);
  1433.     TextDrawBoxColor(Textdraw2, 0);
  1434.     TextDrawTextSize(Textdraw2, 125.000000, 30.000000);
  1435.     TextDrawSetSelectable(Textdraw2, 1);
  1436.  
  1437.     Textdraw3 = TextDrawCreate(146.000000, 432.000000, "~y~Roadwidth:");
  1438.     TextDrawBackgroundColor(Textdraw3, 255);
  1439.     TextDrawFont(Textdraw3, 1);
  1440.     TextDrawLetterSize(Textdraw3, 0.240000, 1.200000);
  1441.     TextDrawColor(Textdraw3, -1);
  1442.     TextDrawSetOutline(Textdraw3, 1);
  1443.     TextDrawSetProportional(Textdraw3, 1);
  1444.     TextDrawSetSelectable(Textdraw3, 0);
  1445.  
  1446.     Textdraw4 = TextDrawCreate(192.000000, 427.000000, "<");      //Decrease Width Button
  1447.     TextDrawBackgroundColor(Textdraw4, 255);
  1448.     TextDrawFont(Textdraw4, 1);
  1449.     TextDrawLetterSize(Textdraw4, 0.500000, 2.400000);
  1450.     TextDrawColor(Textdraw4, TD_BLUE);
  1451.     TextDrawSetOutline(Textdraw4, 1);
  1452.     TextDrawSetProportional(Textdraw4, 1);
  1453.     TextDrawUseBox(Textdraw4, 1);
  1454.     TextDrawBoxColor(Textdraw4, 0);
  1455.     TextDrawTextSize(Textdraw4, 206.000000, 30.000000);
  1456.     TextDrawSetSelectable(Textdraw4, 1);
  1457.  
  1458.     Textdraw5 = TextDrawCreate(235.000000, 432.000000, td5str);    //Current RoadType
  1459.     TextDrawAlignment(Textdraw5, 2);
  1460.     TextDrawBackgroundColor(Textdraw5, 255);
  1461.     TextDrawFont(Textdraw5, 1);
  1462.     TextDrawLetterSize(Textdraw5, 0.250000, 1.200000);
  1463.     TextDrawColor(Textdraw5, TD_BRIGHTGREEN);
  1464.     TextDrawSetOutline(Textdraw5, 1);
  1465.     TextDrawSetProportional(Textdraw5, 1);
  1466.     TextDrawSetSelectable(Textdraw5, 0);
  1467.  
  1468.     Textdraw6 = TextDrawCreate(267.000000, 427.000000, ">");    //Increase Width Button
  1469.     TextDrawBackgroundColor(Textdraw6, 255);
  1470.     TextDrawFont(Textdraw6, 1);
  1471.     TextDrawLetterSize(Textdraw6, 0.500000, 2.400000);
  1472.     TextDrawColor(Textdraw6, TD_BLUE);
  1473.     TextDrawSetOutline(Textdraw6, 1);
  1474.     TextDrawSetProportional(Textdraw6, 1);
  1475.     TextDrawUseBox(Textdraw6, 1);
  1476.     TextDrawBoxColor(Textdraw6, 0);
  1477.     TextDrawTextSize(Textdraw6, 279.000000, 30.000000);
  1478.     TextDrawSetSelectable(Textdraw6, 1);
  1479.  
  1480.     Textdraw7 = TextDrawCreate(297.000000, 432.000000, "~y~Distance:");
  1481.     TextDrawBackgroundColor(Textdraw7, 255);
  1482.     TextDrawFont(Textdraw7, 1);
  1483.     TextDrawLetterSize(Textdraw7, 0.270000, 1.200000);
  1484.     TextDrawColor(Textdraw7, -1);
  1485.     TextDrawSetOutline(Textdraw7, 1);
  1486.     TextDrawSetProportional(Textdraw7, 1);
  1487.     TextDrawSetSelectable(Textdraw7, 0);
  1488.  
  1489.     Textdraw8 = TextDrawCreate(494.000000, 432.000000, "Delete");    // Delete Button
  1490.     TextDrawBackgroundColor(Textdraw8, 255);
  1491.     TextDrawFont(Textdraw8, 1);
  1492.     TextDrawLetterSize(Textdraw8, 0.289999, 1.200000);
  1493.     TextDrawColor(Textdraw8, -16777016);
  1494.     TextDrawSetOutline(Textdraw8, 1);
  1495.     TextDrawSetProportional(Textdraw8, 1);
  1496.     TextDrawUseBox(Textdraw8, 1);
  1497.     TextDrawBoxColor(Textdraw8, 0);
  1498.     TextDrawTextSize(Textdraw8, 526.000000, 30.000000);
  1499.     TextDrawSetSelectable(Textdraw8, 1);
  1500.  
  1501.     Textdraw9 = TextDrawCreate(341.000000, 427.000000, "<");    //Decreate Distance Button
  1502.     TextDrawBackgroundColor(Textdraw9, 255);
  1503.     TextDrawFont(Textdraw9, 1);
  1504.     TextDrawLetterSize(Textdraw9, 0.500000, 2.400000);
  1505.     TextDrawColor(Textdraw9, TD_BLUE);
  1506.     TextDrawSetOutline(Textdraw9, 1);
  1507.     TextDrawSetProportional(Textdraw9, 1);
  1508.     TextDrawUseBox(Textdraw9, 1);
  1509.     TextDrawBoxColor(Textdraw9, 0);
  1510.     TextDrawTextSize(Textdraw9, 354.000000, 30.000000);
  1511.     TextDrawSetSelectable(Textdraw9, 1);
  1512.  
  1513.     Textdraw10 = TextDrawCreate(368.000000, 432.000000, td10str);    // Current Distance
  1514.     TextDrawAlignment(Textdraw10, 2);
  1515.     TextDrawBackgroundColor(Textdraw10, 255);
  1516.     TextDrawFont(Textdraw10, 1);
  1517.     TextDrawLetterSize(Textdraw10, 0.310000, 1.200000);
  1518.     TextDrawColor(Textdraw10, TD_BRIGHTGREEN);
  1519.     TextDrawSetOutline(Textdraw10, 1);
  1520.     TextDrawSetProportional(Textdraw10, 1);
  1521.     TextDrawSetSelectable(Textdraw10, 0);
  1522.  
  1523.     Textdraw11 = TextDrawCreate(552.00000, 432.000000, "~y~RoadPoints:");
  1524.     TextDrawBackgroundColor(Textdraw11, 255);
  1525.     TextDrawFont(Textdraw11, 1);
  1526.     TextDrawLetterSize(Textdraw11, 0.240000, 1.200000);
  1527.     TextDrawColor(Textdraw11, -1);
  1528.     TextDrawSetOutline(Textdraw11, 1);
  1529.     TextDrawSetProportional(Textdraw11, 1);
  1530.     TextDrawSetSelectable(Textdraw11, 0);
  1531.  
  1532.     Textdraw12 = TextDrawCreate(602.000000, 432.000000, td12str);    // Roadpoints Counter
  1533.     TextDrawBackgroundColor(Textdraw12, 255);
  1534.     TextDrawFont(Textdraw12, 1);
  1535.     TextDrawLetterSize(Textdraw12, 0.239999, 1.200000);
  1536.     TextDrawColor(Textdraw12, TD_BRIGHTGREEN);
  1537.     TextDrawSetOutline(Textdraw12, 1);
  1538.     TextDrawSetProportional(Textdraw12, 1);
  1539.     TextDrawSetSelectable(Textdraw12, 0);
  1540.  
  1541.     Textdraw13 = TextDrawCreate(383.000000, 427.000000, ">");    //Increase Distance Button
  1542.     TextDrawBackgroundColor(Textdraw13, 255);
  1543.     TextDrawFont(Textdraw13, 1);
  1544.     TextDrawLetterSize(Textdraw13, 0.500000, 2.400000);
  1545.     TextDrawColor(Textdraw13, TD_BLUE);
  1546.     TextDrawSetOutline(Textdraw13, 1);
  1547.     TextDrawSetProportional(Textdraw13, 1);
  1548.     TextDrawUseBox(Textdraw13, 1);
  1549.     TextDrawBoxColor(Textdraw13, 0);
  1550.     TextDrawTextSize(Textdraw13, 395.000000, 30.000000);
  1551.     TextDrawSetSelectable(Textdraw13, 1);
  1552.  
  1553.     Textdraw14 = TextDrawCreate(412.000000, 432.000000, "~y~Double:");
  1554.     TextDrawBackgroundColor(Textdraw14, 255);
  1555.     TextDrawFont(Textdraw14, 1);
  1556.     TextDrawLetterSize(Textdraw14, 0.270000, 1.200000);
  1557.     TextDrawColor(Textdraw14, -1);
  1558.     TextDrawSetOutline(Textdraw14, 1);
  1559.     TextDrawSetProportional(Textdraw14, 1);
  1560.     TextDrawSetSelectable(Textdraw14, 0);
  1561.  
  1562.     Textdraw15 = TextDrawCreate(450.000000, 432.000000, td15str);   // Double ON/OFF button
  1563.     TextDrawBackgroundColor(Textdraw15, 255);
  1564.     TextDrawFont(Textdraw15, 1);
  1565.     TextDrawLetterSize(Textdraw15, 0.270000, 1.200000);
  1566.     TextDrawColor(Textdraw15, TD_BRIGHTRED);
  1567.     TextDrawSetOutline(Textdraw15, 1);
  1568.     TextDrawSetProportional(Textdraw15, 1);
  1569.     TextDrawUseBox(Textdraw15, 1);
  1570.     TextDrawBoxColor(Textdraw15, 0);
  1571.     TextDrawTextSize(Textdraw15, 469.000000, 30.000000);
  1572.     TextDrawSetSelectable(Textdraw15, 1);
  1573.  
  1574.     Textdraw20 = TextDrawCreate(855.000000, 428.000000, "~n~");
  1575.     TextDrawAlignment(Textdraw20, 2);
  1576.     TextDrawBackgroundColor(Textdraw20, 255);
  1577.     TextDrawFont(Textdraw20, 1);
  1578.     TextDrawLetterSize(Textdraw20, -0.559997, -2.599998);
  1579.     TextDrawColor(Textdraw20, -1);
  1580.     TextDrawSetOutline(Textdraw20, 0);
  1581.     TextDrawSetProportional(Textdraw20, 1);
  1582.     TextDrawSetShadow(Textdraw20, 1);
  1583.     TextDrawUseBox(Textdraw20, 1);
  1584.     TextDrawBoxColor(Textdraw20, 150);
  1585.     TextDrawTextSize(Textdraw20, 35.000000, 642.000000);
  1586.     TextDrawSetSelectable(Textdraw20, 0);
  1587.  
  1588.     Textdraw16 = TextDrawCreate(537.000000, 408.000000, "~y~Space:");
  1589.     TextDrawBackgroundColor(Textdraw16, 255);
  1590.     TextDrawFont(Textdraw16, 1);
  1591.     TextDrawLetterSize(Textdraw16, 0.289999, 1.500000);
  1592.     TextDrawColor(Textdraw16, -1);
  1593.     TextDrawSetOutline(Textdraw16, 1);
  1594.     TextDrawSetProportional(Textdraw16, 1);
  1595.     TextDrawSetSelectable(Textdraw16, 0);
  1596.  
  1597.     Textdraw17 = TextDrawCreate(570.000000, 405.000000, "<");
  1598.     TextDrawBackgroundColor(Textdraw17, 255);
  1599.     TextDrawFont(Textdraw17, 1);
  1600.     TextDrawLetterSize(Textdraw17, 0.500000, 2.400000);
  1601.     TextDrawColor(Textdraw17, TD_BLUE);
  1602.     TextDrawSetOutline(Textdraw17, 1);
  1603.     TextDrawSetProportional(Textdraw17, 1);
  1604.     TextDrawUseBox(Textdraw17, 1);
  1605.     TextDrawBoxColor(Textdraw17, 0);
  1606.     TextDrawTextSize(Textdraw17, 586.000000, 33.000000);
  1607.     TextDrawSetSelectable(Textdraw17, 1);
  1608.  
  1609.     Textdraw18 = TextDrawCreate(612.000000, 405.000000, ">");
  1610.     TextDrawBackgroundColor(Textdraw18, 255);
  1611.     TextDrawFont(Textdraw18, 1);
  1612.     TextDrawLetterSize(Textdraw18, 0.500000, 2.400000);
  1613.     TextDrawColor(Textdraw18, TD_BLUE);
  1614.     TextDrawSetOutline(Textdraw18, 1);
  1615.     TextDrawSetProportional(Textdraw18, 1);
  1616.     TextDrawUseBox(Textdraw18, 1);
  1617.     TextDrawBoxColor(Textdraw18, 0);
  1618.     TextDrawTextSize(Textdraw18, 626.000000, 35.000000);
  1619.     TextDrawSetSelectable(Textdraw18, 1);
  1620.  
  1621.     Textdraw19 = TextDrawCreate(597.000000, 408.000000, td19str);
  1622.     TextDrawAlignment(Textdraw19, 2);
  1623.     TextDrawBackgroundColor(Textdraw19, 255);
  1624.     TextDrawFont(Textdraw19, 1);
  1625.     TextDrawLetterSize(Textdraw19, 0.329997, 1.700000);
  1626.     TextDrawColor(Textdraw19, TD_BRIGHTGREEN);
  1627.     TextDrawSetOutline(Textdraw19, 1);
  1628.     TextDrawSetProportional(Textdraw19, 1);
  1629.     TextDrawSetSelectable(Textdraw19, 0);
  1630.  
  1631.     Textdraw21 = TextDrawCreate(111.000000, 218.000000, "~n~");
  1632.     TextDrawAlignment(Textdraw21, 2);
  1633.     TextDrawBackgroundColor(Textdraw21, 255);
  1634.     TextDrawFont(Textdraw21, 1);
  1635.     TextDrawLetterSize(Textdraw21, 0.069999, 11.999987);
  1636.     TextDrawColor(Textdraw21, -1);
  1637.     TextDrawSetOutline(Textdraw21, 0);
  1638.     TextDrawSetProportional(Textdraw21, 1);
  1639.     TextDrawSetShadow(Textdraw21, 1);
  1640.     TextDrawUseBox(Textdraw21, 1);
  1641.     TextDrawBoxColor(Textdraw21, 125);
  1642.     TextDrawTextSize(Textdraw21, -10.000000, -180.000000);
  1643.     TextDrawSetSelectable(Textdraw21, 0);
  1644.  
  1645.     Textdraw22 = TextDrawCreate(30.000000, 220.000000, "Presets:~n~#          width - dist. - space");
  1646.     TextDrawBackgroundColor(Textdraw22, 255);
  1647.     TextDrawFont(Textdraw22, 1);
  1648.     TextDrawLetterSize(Textdraw22, 0.290000, 1.000000);
  1649.     TextDrawColor(Textdraw22, -1);
  1650.     TextDrawSetOutline(Textdraw22, 1);
  1651.     TextDrawSetProportional(Textdraw22, 1);
  1652.     TextDrawSetSelectable(Textdraw22, 0);
  1653.  
  1654.     Textdraw23 = TextDrawCreate(30.000000, 245.000000, pre1str);
  1655.     TextDrawBackgroundColor(Textdraw23, 255);
  1656.     TextDrawFont(Textdraw23, 1);
  1657.     TextDrawLetterSize(Textdraw23, 0.270000, 1.100000);
  1658.     TextDrawColor(Textdraw23, -1);
  1659.     TextDrawSetOutline(Textdraw23, 1);
  1660.     TextDrawSetProportional(Textdraw23, 1);
  1661.     TextDrawUseBox(Textdraw23, 1);
  1662.     TextDrawBoxColor(Textdraw23, 150);
  1663.     TextDrawTextSize(Textdraw23, 197.000000, 15.000000);
  1664.     TextDrawSetSelectable(Textdraw23, 1);
  1665.  
  1666.     Textdraw24 = TextDrawCreate(30.000000, 261.000000, pre2str);
  1667.     TextDrawBackgroundColor(Textdraw24, 255);
  1668.     TextDrawFont(Textdraw24, 1);
  1669.     TextDrawLetterSize(Textdraw24, 0.270000, 1.100000);
  1670.     TextDrawColor(Textdraw24, -1);
  1671.     TextDrawSetOutline(Textdraw24, 1);
  1672.     TextDrawSetProportional(Textdraw24, 1);
  1673.     TextDrawUseBox(Textdraw24, 1);
  1674.     TextDrawBoxColor(Textdraw24, 150);
  1675.     TextDrawTextSize(Textdraw24, 197.000000, 15.000000);
  1676.     TextDrawSetSelectable(Textdraw24, 1);
  1677.  
  1678.     Textdraw25 = TextDrawCreate(30.000000, 277.000000, pre3str);
  1679.     TextDrawBackgroundColor(Textdraw25, 255);
  1680.     TextDrawFont(Textdraw25, 1);
  1681.     TextDrawLetterSize(Textdraw25, 0.270000, 1.100000);
  1682.     TextDrawColor(Textdraw25, -1);
  1683.     TextDrawSetOutline(Textdraw25, 1);
  1684.     TextDrawSetProportional(Textdraw25, 1);
  1685.     TextDrawUseBox(Textdraw25, 1);
  1686.     TextDrawBoxColor(Textdraw25, 150);
  1687.     TextDrawTextSize(Textdraw25, 197.000000, 15.000000);
  1688.     TextDrawSetSelectable(Textdraw25, 1);
  1689.  
  1690.     Textdraw26 = TextDrawCreate(30.000000, 293.000000, pre4str);
  1691.     TextDrawBackgroundColor(Textdraw26, 255);
  1692.     TextDrawFont(Textdraw26, 1);
  1693.     TextDrawLetterSize(Textdraw26, 0.270000, 1.100000);
  1694.     TextDrawColor(Textdraw26, -1);
  1695.     TextDrawSetOutline(Textdraw26, 1);
  1696.     TextDrawSetProportional(Textdraw26, 1);
  1697.     TextDrawUseBox(Textdraw26, 1);
  1698.     TextDrawBoxColor(Textdraw26, 150);
  1699.     TextDrawTextSize(Textdraw26, 197.000000, 15.000000);
  1700.     TextDrawSetSelectable(Textdraw26, 1);
  1701.  
  1702.     Textdraw27 = TextDrawCreate(30.000000, 309.000000, pre5str);
  1703.     TextDrawBackgroundColor(Textdraw27, 255);
  1704.     TextDrawFont(Textdraw27, 1);
  1705.     TextDrawLetterSize(Textdraw27, 0.270000, 1.100000);
  1706.     TextDrawColor(Textdraw27, -1);
  1707.     TextDrawSetOutline(Textdraw27, 1);
  1708.     TextDrawSetProportional(Textdraw27, 1);
  1709.     TextDrawUseBox(Textdraw27, 1);
  1710.     TextDrawBoxColor(Textdraw27, 150);
  1711.     TextDrawTextSize(Textdraw27, 197.000000, 15.000000);
  1712.     TextDrawSetSelectable(Textdraw27, 1);
  1713.     return 1;
  1714. }
  1715.  
  1716.  
  1717. stock SavePresets()
  1718. {
  1719.     new File:file;
  1720.     if (!fexist("KYLSettings.txt"))
  1721.     {
  1722.         file = fopen("KYLSettings.txt",io_write);
  1723.         fclose(file);
  1724.     }
  1725.     file=fopen("KYLSettings.txt", io_write);
  1726.     new str[64];
  1727.     for(new slot; slot<5; slot++)
  1728.     {
  1729.         format(str, sizeof(str), "%d %s %.2f %.2f %.2f\r\n", Preset[slot][predouble], Preset[slot][predoublestr], Preset[slot][prewidth], Preset[slot][predistance], Preset[slot][prespace]);
  1730.         fwrite(file, str);
  1731.     }
  1732.     fclose(file);
  1733.     return 1;
  1734. }
  1735.  
  1736. stock LoadPresets()
  1737. {
  1738.     new File:file;
  1739.     if (!fexist("KYLSettings.txt"))
  1740.     {
  1741.         file = fopen("KYLSettings.txt",io_write);
  1742.         fclose(file);
  1743.     }
  1744.     file=fopen("KYLSettings.txt", io_read);
  1745.     new str[64], slot;  // Create new variables to store the string, zone and slot
  1746.     while(fread(file, str))  // Loop through each line in the file
  1747.     {
  1748.        
  1749.         sscanf(str, "ds[12]fff", Preset[slot][predouble], Preset[slot][predoublestr], Preset[slot][prewidth], Preset[slot][predistance], Preset[slot][prespace]);  // Retrieve all values from the line and store them in the temporarily variables
  1750.         slot++;
  1751.     }
  1752.     fclose(file);
  1753.     return 1;
  1754. }
  1755.  
  1756.  
  1757. //This function creates, deletes and/or updates the position of the objects/markers attached to your vehicle during the Creation-process, based on the old state and new state.
  1758. UpdateObjects(playerid, oldstate, newstate)
  1759. {
  1760.  
  1761.     //States:
  1762.     //  -1  = Creation-mode Disabled
  1763.     //  0   = Creating Roadpoints in 1 direction
  1764.     //  1   = Creating Roadpoints in both directions
  1765.    
  1766.     new Float:x, Float:y, Float:z;
  1767.     switch (oldstate)
  1768.     {
  1769.         case -1:
  1770.         {
  1771.             switch (newstate)
  1772.             {
  1773.                 case 0:
  1774.                 {
  1775.                     Object1 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1776.                     AttachDynamicObjectToVehicle(Object1, GetPlayerVehicleID(playerid), (floatdiv(RoadWidth, 2.0)), 0.0, -0.5, 0.0, 0.0, 0.0);
  1777.                     Object2 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1778.                     AttachDynamicObjectToVehicle(Object2, GetPlayerVehicleID(playerid), -(floatdiv(RoadWidth, 2.0)), 0.0, -0.5, 0.0, 0.0, 0.0);
  1779.                     GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  1780.                     SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  1781.                 }
  1782.             }
  1783.         }
  1784.         case 0:
  1785.         {
  1786.             switch (newstate)
  1787.             {
  1788.                 case -1:
  1789.                 {
  1790.                     if(IsValidDynamicObject(Object1)) DestroyDynamicObject(Object1);
  1791.                     if(IsValidDynamicObject(Object2)) DestroyDynamicObject(Object2);
  1792.                     if(IsValidDynamicObject(Object3)) DestroyDynamicObject(Object3);
  1793.                     if(IsValidDynamicObject(Object4)) DestroyDynamicObject(Object4);
  1794.                 }
  1795.                 case 0:
  1796.                 {
  1797.                     if(!IsValidDynamicObject(Object1)) Object1 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1798.                     if(!IsValidDynamicObject(Object2)) Object2 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1799.                     AttachDynamicObjectToVehicle(Object1, GetPlayerVehicleID(playerid), (floatdiv(RoadWidth, 2.0)), 0.0, -0.5, 0.0, 0.0, 0.0);
  1800.                     AttachDynamicObjectToVehicle(Object2, GetPlayerVehicleID(playerid), -(floatdiv(RoadWidth, 2.0)), 0.0, -0.5, 0.0, 0.0, 0.0);
  1801.                     GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  1802.                     SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  1803.                 }
  1804.                 case 1:
  1805.                 {
  1806.                     if(!IsValidDynamicObject(Object1)) Object1 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1807.                     if(!IsValidDynamicObject(Object2)) Object2 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1808.                     Object3 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1809.                     Object4 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1810.                     AttachDynamicObjectToVehicle(Object1, GetPlayerVehicleID(playerid), floatadd(RoadWidth, floatdiv(Space, 2.0)), 0.0, -0.5, 0.0, 0.0, 0.0);
  1811.                     AttachDynamicObjectToVehicle(Object2, GetPlayerVehicleID(playerid), floatdiv(Space, 2.0), 0.0, -0.5, 0.0, 0.0, 0.0);
  1812.                     AttachDynamicObjectToVehicle(Object3, GetPlayerVehicleID(playerid), -floatdiv(Space, 2.0), 0.0, -0.5, 0.0, 0.0, 0.0);
  1813.                     AttachDynamicObjectToVehicle(Object4, GetPlayerVehicleID(playerid), -floatadd(RoadWidth, floatdiv(Space, 2.0)), 0.0, -0.5, 0.0, 0.0, 0.0);
  1814.                     GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  1815.                     SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  1816.                 }
  1817.             }
  1818.         }
  1819.         case 1:
  1820.         {
  1821.             switch (newstate)
  1822.             {
  1823.                 case -1:
  1824.                 {
  1825.                     if(IsValidDynamicObject(Object1)) DestroyDynamicObject(Object1);
  1826.                     if(IsValidDynamicObject(Object2)) DestroyDynamicObject(Object2);
  1827.                     if(IsValidDynamicObject(Object3)) DestroyDynamicObject(Object3);
  1828.                     if(IsValidDynamicObject(Object4)) DestroyDynamicObject(Object4);
  1829.                 }
  1830.                 case 0:
  1831.                 {
  1832.                     if(IsValidDynamicObject(Object1)) DestroyDynamicObject(Object1);
  1833.                     if(IsValidDynamicObject(Object2)) DestroyDynamicObject(Object2);
  1834.                     if(IsValidDynamicObject(Object3)) DestroyDynamicObject(Object3);
  1835.                     if(IsValidDynamicObject(Object4)) DestroyDynamicObject(Object4);
  1836.                     Object1 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1837.                     AttachDynamicObjectToVehicle(Object1, GetPlayerVehicleID(playerid), (floatdiv(RoadWidth, 2.0)), 0.0, -0.5, 0.0, 0.0, 0.0);
  1838.                     Object2 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1839.                     AttachDynamicObjectToVehicle(Object2, GetPlayerVehicleID(playerid), -(floatdiv(RoadWidth, 2.0)), 0.0, -0.5, 0.0, 0.0, 0.0);
  1840.                     GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  1841.                     SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  1842.  
  1843.                 }
  1844.                 case 1:
  1845.                 {
  1846.                     if(!IsValidDynamicObject(Object1)) Object1 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1847.                     if(!IsValidDynamicObject(Object2)) Object2 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1848.                     if(!IsValidDynamicObject(Object3)) Object3 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1849.                     if(!IsValidDynamicObject(Object4)) Object4 = CreateDynamicObject(19133, 0.0, 0.0, 0.0, 0.0, 0,0, -1, -1, -1);
  1850.                     AttachDynamicObjectToVehicle(Object1, GetPlayerVehicleID(playerid), floatadd(RoadWidth, floatdiv(Space, 2.0)), 0.0, -0.5, 0.0, 0.0, 0.0);
  1851.                     AttachDynamicObjectToVehicle(Object2, GetPlayerVehicleID(playerid), floatdiv(Space, 2.0), 0.0, -0.5, 0.0, 0.0, 0.0);
  1852.                     AttachDynamicObjectToVehicle(Object3, GetPlayerVehicleID(playerid), -floatdiv(Space, 2.0), 0.0, -0.5, 0.0, 0.0, 0.0);
  1853.                     AttachDynamicObjectToVehicle(Object4, GetPlayerVehicleID(playerid), -floatadd(RoadWidth, floatdiv(Space, 2.0)), 0.0, -0.5, 0.0, 0.0, 0.0);
  1854.                     GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  1855.                     SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  1856.                 }
  1857.             }
  1858.         }
  1859.     }
  1860.     return 1;
  1861. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement