Schneider1988

[FS]Keep your Lane - by Schneider

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