Advertisement
Larceny

MTA Map Loader for SAMP

Jul 30th, 2013
614
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 19.71 KB | None | 0 0
  1. /**
  2.     MTA MAP LOADER
  3.     maploader.inc
  4.     Purpose: Loads mta maps with no needs of conversions
  5.  
  6.     @author Larceny
  7.     @version 1.0 30/07/13
  8. */
  9.  
  10. #if defined _maploader_included
  11.         #endinput
  12. #endif
  13.  
  14. #include <a_samp>
  15.  
  16. #define _maploader_included
  17.  
  18. #if defined MAX_VEHICLE_NAME
  19.     #if MAX_VEHICLE_NAME < 22
  20.         #undef MAX_VEHICLE_NAME
  21.     #endif
  22. #endif
  23.  
  24. #if !defined MAX_VEHICLE_NAME
  25.     #define MAX_VEHICLE_NAME        (22)
  26. #endif
  27.  
  28. #if !defined MAX_FILE_NAME
  29.     #define MAX_FILE_NAME           (64)
  30. #endif
  31.  
  32. #if !defined MAX_ELEMENTS
  33.     #define MAX_ELEMENTS            (500)
  34. #endif
  35.  
  36. #if !defined MAPLOADER_UPDATE
  37.     #define MAPLOADER_UPDATE        (100)
  38. #endif
  39.  
  40. enum E_PICKUP_VEHICLE
  41. {
  42.     E_PICKUP_VEHICLE_MODEL,
  43.     E_PICKUP_VEHICLE_ID,
  44.     Float:E_PICKUP_VEHICLE_X,
  45.     Float:E_PICKUP_VEHICLE_Y,
  46.     Float:E_PICKUP_VEHICLE_Z
  47. }
  48.  
  49. enum E_PICKUP_NITRO
  50. {
  51.     E_PICKUP_NITRO_ID,
  52.     Float:E_PICKUP_NITRO_X,
  53.     Float:E_PICKUP_NITRO_Y,
  54.     Float:E_PICKUP_NITRO_Z
  55. }
  56.  
  57. enum E_PICKUP_REPAIR
  58. {
  59.     E_PICKUP_REPAIR_ID,
  60.     Float:E_PICKUP_REPAIR_X,
  61.     Float:E_PICKUP_REPAIR_Y,
  62.     Float:E_PICKUP_REPAIR_Z
  63. }
  64.  
  65. new
  66.     gMapVehicleData[MAX_ELEMENTS][E_PICKUP_VEHICLE],
  67.     gMapRepairData[MAX_ELEMENTS][E_PICKUP_REPAIR],
  68.     gMapNitroData[MAX_ELEMENTS][E_PICKUP_NITRO];
  69.  
  70. new
  71.     repairs,
  72.     nitros,
  73.     vehiclechanges;
  74.  
  75. /**
  76.     Loads a map from a file.
  77.  
  78.     @param mapname The name of the file (with extension)
  79. */
  80. stock LoadMap(mapname[])
  81. {
  82.     if (!fexist(mapname))
  83.     {
  84.         printf("ERROR: Couldn't load map. File %s does not exist!", mapname);
  85.         return 0;
  86.     }
  87.  
  88.     printf("Loading Map... File %s.", mapname);
  89.  
  90.     new
  91.         File:mapfile,
  92.         line[256];
  93.  
  94.     mapfile = fopen(mapname, io_read);
  95.     while (fread(mapfile, line))
  96.     {
  97.         if (strfind(line, "object id", true) != -1)
  98.         {
  99.             new strDest[32],
  100.                 modelid,
  101.                 Float:PosX,
  102.                 Float:PosY,
  103.                 Float:PosZ,
  104.                 Float:RotX,
  105.                 Float:RotY,
  106.                 Float:RotZ;
  107.  
  108.             strmid(strDest, line, strfind(line, "model=", true)+7, strfind(line, "scale=", true)-2);
  109.             modelid = strval(strDest);
  110.             strdel(strDest, 0, strlen(strDest));
  111.  
  112.             strmid(strDest, line, strfind(line, "posX=", true)+6, strfind(line, "posY=", true)-2);
  113.             PosX = floatstr(strDest);
  114.             strdel(strDest, 0, strlen(strDest));
  115.  
  116.             strmid(strDest, line, strfind(line, "posY=", true)+6, strfind(line, "posZ=", true)-2);
  117.             PosY = floatstr(strDest);
  118.             strdel(strDest, 0, strlen(strDest));
  119.  
  120.             strmid(strDest, line, strfind(line, "posZ=", true)+6, strfind(line, "RotX=", true)-2);
  121.             PosZ = floatstr(strDest);
  122.             strdel(strDest, 0, strlen(strDest));
  123.  
  124.             strmid(strDest, line, strfind(line, "posZ=", true)+6, strfind(line, "RotX=", true)-2);
  125.             PosZ = floatstr(strDest);
  126.             strdel(strDest, 0, strlen(strDest));
  127.  
  128.             strmid(strDest, line, strfind(line, "RotX=", true)+6, strfind(line, "RotY=", true)-2);
  129.             RotX = floatstr(strDest);
  130.             strdel(strDest, 0, strlen(strDest));
  131.  
  132.             strmid(strDest, line, strfind(line, "RotY=", true)+6, strfind(line, "RotZ=", true)-2);
  133.             RotY = floatstr(strDest);
  134.             strdel(strDest, 0, strlen(strDest));
  135.  
  136.             strmid(strDest, line, strfind(line, "RotZ=", true)+6, strfind(line, "></object>", true)-1);
  137.             RotZ = floatstr(strDest);
  138.             strdel(strDest, 0, strlen(strDest));
  139.  
  140.             CreateObject(modelid, PosX, PosY, PosZ, RotX, RotY, RotZ);
  141.  
  142.             //<object id="AMT 8558 (2276)" interior="0" collisions="true" alpha="255" doublesided="false" model="8558" scale="1" dimension="0" posX="886" posY="-2513.5" posZ="117.5" rotX="359.484" rotY="359.995" rotZ="235.481"></object>
  143.         }
  144.         else if (strfind(line, "type=\"repair\"", true) != -1)
  145.         {
  146.             new strDest[32];
  147.  
  148.             strmid(strDest, line, strfind(line, "posX=", true)+6, strfind(line, "posY=", true)-2);
  149.             gMapRepairData[repairs][E_PICKUP_REPAIR_X] = floatstr(strDest);
  150.             strdel(strDest, 0, strlen(strDest));
  151.  
  152.             strmid(strDest, line, strfind(line, "posY=", true)+6, strfind(line, "posZ=", true)-2);
  153.             gMapRepairData[repairs][E_PICKUP_REPAIR_Y] = floatstr(strDest);
  154.             strdel(strDest, 0, strlen(strDest));
  155.  
  156.             strmid(strDest, line, strfind(line, "posZ=", true)+6, strfind(line, "rotX=", true)-2);
  157.             gMapRepairData[repairs][E_PICKUP_REPAIR_Z] = floatstr(strDest);
  158.             strdel(strDest, 0, strlen(strDest));
  159.  
  160.             gMapRepairData[repairs][E_PICKUP_REPAIR_ID] = CreatePickup(1239, 1, gMapRepairData[repairs][E_PICKUP_REPAIR_X], gMapRepairData[repairs][E_PICKUP_REPAIR_Y], gMapRepairData[repairs][E_PICKUP_REPAIR_Z], -1);
  161.             Create3DTextLabel("REPAIR", 0xFFFFFFFF, gMapRepairData[repairs][E_PICKUP_REPAIR_X], gMapRepairData[repairs][E_PICKUP_REPAIR_Y], gMapRepairData[repairs][E_PICKUP_REPAIR_Z], 60.0, 0, 0);
  162.  
  163.  
  164.             repairs++;
  165.             //<racepickup id="racepickup (NRG-500) (33)" type="repair" vehicle="522" respawn="0" posX="739.29999" posY="-3026.6001" posZ="20" rotX="0" rotY="0" rotZ="278.1"></racepickup>
  166.         }
  167.         else if (strfind(line, "type=\"vehiclechange\"", true) != -1)
  168.         {
  169.             new strDest[32];
  170.  
  171.             strmid(strDest, line, strfind(line, "posX=", true)+6, strfind(line, "posY=", true)-2);
  172.             gMapVehicleData[vehiclechanges][E_PICKUP_VEHICLE_X] = floatstr(strDest);
  173.             strdel(strDest, 0, strlen(strDest));
  174.  
  175.             strmid(strDest, line, strfind(line, "posY=", true)+6, strfind(line, "posZ=", true)-2);
  176.             gMapVehicleData[vehiclechanges][E_PICKUP_VEHICLE_Y] = floatstr(strDest);
  177.             strdel(strDest, 0, strlen(strDest));
  178.  
  179.             strmid(strDest, line, strfind(line, "posZ=", true)+6, strfind(line, "rotX=", true)-2);
  180.             gMapVehicleData[vehiclechanges][E_PICKUP_VEHICLE_Z] = floatstr(strDest);
  181.             strdel(strDest, 0, strlen(strDest));
  182.  
  183.             strmid(strDest, line, strfind(line, "vehicle=", true)+9, strfind(line, "respawn=", true)-2);
  184.             gMapVehicleData[vehiclechanges][E_PICKUP_VEHICLE_MODEL] = strval(strDest);
  185.             strdel(strDest, 0, strlen(strDest));
  186.  
  187.             gMapVehicleData[vehiclechanges][E_PICKUP_VEHICLE_ID] = CreatePickup(1239, 1, gMapVehicleData[vehiclechanges][E_PICKUP_VEHICLE_X], gMapVehicleData[vehiclechanges][E_PICKUP_VEHICLE_Y], gMapVehicleData[vehiclechanges][E_PICKUP_VEHICLE_Z], -1);
  188.             Create3DTextLabel(GetVehicleName(gMapVehicleData[vehiclechanges][E_PICKUP_VEHICLE_MODEL]), 0xFFFFFFFF, gMapVehicleData[vehiclechanges][E_PICKUP_VEHICLE_X], gMapVehicleData[vehiclechanges][E_PICKUP_VEHICLE_Y], gMapVehicleData[vehiclechanges][E_PICKUP_VEHICLE_Z], 60.0, 0, 0);
  189.  
  190.             vehiclechanges++;
  191.             //<racepickup id="racepickup (NRG-500) (3)" type="vehiclechange" vehicle="522" respawn="0" alpha="255" interior="0" posX="1185.59961" posY="-3075" posZ="50.3" rotX="0" rotY="0" rotZ="55.797"></racepickup>
  192.         }
  193.         else if (strfind(line, "type=\"nitro\"", true) != -1)
  194.         {
  195.             new strDest[32];
  196.  
  197.             strmid(strDest, line, strfind(line, "posX=", true)+6, strfind(line, "posY=", true)-2);
  198.             gMapNitroData[nitros][E_PICKUP_NITRO_X] = floatstr(strDest);
  199.             strdel(strDest, 0, strlen(strDest));
  200.  
  201.             strmid(strDest, line, strfind(line, "posY=", true)+6, strfind(line, "posZ=", true)-2);
  202.             gMapNitroData[nitros][E_PICKUP_NITRO_Y] = floatstr(strDest);
  203.             strdel(strDest, 0, strlen(strDest));
  204.  
  205.             strmid(strDest, line, strfind(line, "posZ=", true)+6, strfind(line, "rotX=", true)-2);
  206.             gMapNitroData[nitros][E_PICKUP_NITRO_Z] = floatstr(strDest);
  207.             strdel(strDest, 0, strlen(strDest));
  208.  
  209.             gMapNitroData[nitros][E_PICKUP_NITRO_ID] = CreatePickup(1239, 1, gMapNitroData[nitros][E_PICKUP_NITRO_X], gMapNitroData[nitros][E_PICKUP_NITRO_Y], gMapNitroData[nitros][E_PICKUP_NITRO_Z], -1);
  210.             Create3DTextLabel("NITRO", 0xFFFFFFFF, gMapNitroData[nitros][E_PICKUP_NITRO_X], gMapNitroData[nitros][E_PICKUP_NITRO_Y], gMapNitroData[nitros][E_PICKUP_NITRO_Z], 60.0, 0, 0);
  211.  
  212.             nitros++;
  213.             //<racepickup id="racepickup (NRG-500) (51)" type="nitro" vehicle="522" respawn="0" posX="800.59998" posY="-3125.1001" posZ="46.9" rotX="0" rotY="0" rotZ="12.602"></racepickup>
  214.         }
  215.     }
  216.     fclose(mapfile);
  217.     print("Map Loaded.");
  218.     return 1;
  219. }
  220.  
  221. /**
  222.     Returns the name of a vehicle
  223.  
  224.     @param modelid The modelid of the vehicle
  225. */
  226. static stock GetVehicleName(modelid)
  227. {
  228.     new a_VEHICLE_NAME[22];
  229.     switch (modelid) {
  230.         case 400: a_VEHICLE_NAME = "Landstalker";
  231.         case 401: a_VEHICLE_NAME = "Bravura";
  232.         case 402: a_VEHICLE_NAME = "Buffalo";
  233.         case 403: a_VEHICLE_NAME = "Linerunner";
  234.         case 404: a_VEHICLE_NAME = "Perenniel";
  235.         case 405: a_VEHICLE_NAME = "Sentinel";
  236.         case 406: a_VEHICLE_NAME = "Dumper";
  237.         case 407: a_VEHICLE_NAME = "Firetruck";
  238.         case 408: a_VEHICLE_NAME = "Trashmaster";
  239.         case 409: a_VEHICLE_NAME = "Stretch";
  240.         case 410: a_VEHICLE_NAME = "Manana";
  241.         case 411: a_VEHICLE_NAME = "Infernus";
  242.         case 412: a_VEHICLE_NAME = "Voodoo";
  243.         case 413: a_VEHICLE_NAME = "Pony";
  244.         case 414: a_VEHICLE_NAME = "Mule";
  245.         case 415: a_VEHICLE_NAME = "Cheetah";
  246.         case 416: a_VEHICLE_NAME = "Ambulance";
  247.         case 417: a_VEHICLE_NAME = "Leviathan";
  248.         case 418: a_VEHICLE_NAME = "Moonbeam";
  249.         case 419: a_VEHICLE_NAME = "Esperanto";
  250.         case 420: a_VEHICLE_NAME = "Taxi";
  251.         case 421: a_VEHICLE_NAME = "Washigton";
  252.         case 422: a_VEHICLE_NAME = "Bobcat";
  253.         case 423: a_VEHICLE_NAME = "Mr Whoopee";
  254.         case 424: a_VEHICLE_NAME = "BF Injection";
  255.         case 425: a_VEHICLE_NAME = "Hunter";
  256.         case 426: a_VEHICLE_NAME = "Premier";
  257.         case 427: a_VEHICLE_NAME = "Enforcer";
  258.         case 428: a_VEHICLE_NAME = "Securicar";
  259.         case 429: a_VEHICLE_NAME = "Banshee";
  260.         case 430: a_VEHICLE_NAME = "Predator";
  261.         case 431: a_VEHICLE_NAME = "Bus";
  262.         case 432: a_VEHICLE_NAME = "Rhino";
  263.         case 433: a_VEHICLE_NAME = "Barracks";
  264.         case 434: a_VEHICLE_NAME = "Hotknife";
  265.         case 435: a_VEHICLE_NAME = "Article Trailer";
  266.         case 436: a_VEHICLE_NAME = "Previon";
  267.         case 437: a_VEHICLE_NAME = "Coach";
  268.         case 438: a_VEHICLE_NAME = "Cabbie";
  269.         case 439: a_VEHICLE_NAME = "Stallion";
  270.         case 440: a_VEHICLE_NAME = "Rumpo";
  271.         case 441: a_VEHICLE_NAME = "RC Bandit";
  272.         case 442: a_VEHICLE_NAME = "Romero";
  273.         case 443: a_VEHICLE_NAME = "Packer";
  274.         case 444: a_VEHICLE_NAME = "Monster";
  275.         case 445: a_VEHICLE_NAME = "Admiral";
  276.         case 446: a_VEHICLE_NAME = "Squallo";
  277.         case 447: a_VEHICLE_NAME = "Seasparrow";
  278.         case 448: a_VEHICLE_NAME = "Pizzaboy";
  279.         case 449: a_VEHICLE_NAME = "Tram";
  280.         case 450: a_VEHICLE_NAME = "Article Trailer 2";
  281.         case 451: a_VEHICLE_NAME = "Turismo";
  282.         case 452: a_VEHICLE_NAME = "Speeder";
  283.         case 453: a_VEHICLE_NAME = "Reefer";
  284.         case 454: a_VEHICLE_NAME = "Tropic";
  285.         case 455: a_VEHICLE_NAME = "Flatbed";
  286.         case 456: a_VEHICLE_NAME = "Yankee";
  287.         case 457: a_VEHICLE_NAME = "Caddy";
  288.         case 458: a_VEHICLE_NAME = "Solair";
  289.         case 459: a_VEHICLE_NAME = "Topfun Van";
  290.         case 460: a_VEHICLE_NAME = "Skimmer";
  291.         case 461: a_VEHICLE_NAME = "PCJ-600";
  292.         case 462: a_VEHICLE_NAME = "Faggio";
  293.         case 463: a_VEHICLE_NAME = "Freeway";
  294.         case 464: a_VEHICLE_NAME = "RC Baron";
  295.         case 465: a_VEHICLE_NAME = "RC Raider";
  296.         case 466: a_VEHICLE_NAME = "Glendale";
  297.         case 467: a_VEHICLE_NAME = "Oceanic";
  298.         case 468: a_VEHICLE_NAME = "Sanchez";
  299.         case 469: a_VEHICLE_NAME = "Sparrow";
  300.         case 470: a_VEHICLE_NAME = "Patriot";
  301.         case 471: a_VEHICLE_NAME = "Quad";
  302.         case 472: a_VEHICLE_NAME = "Coastguard";
  303.         case 473: a_VEHICLE_NAME = "Dinghy";
  304.         case 474: a_VEHICLE_NAME = "Hermes";
  305.         case 475: a_VEHICLE_NAME = "Sabre";
  306.         case 476: a_VEHICLE_NAME = "Rustler";
  307.         case 477: a_VEHICLE_NAME = "ZR-350";
  308.         case 478: a_VEHICLE_NAME = "Walton";
  309.         case 479: a_VEHICLE_NAME = "Regina";
  310.         case 480: a_VEHICLE_NAME = "Comet";
  311.         case 481: a_VEHICLE_NAME = "BMX";
  312.         case 482: a_VEHICLE_NAME = "Burrito";
  313.         case 483: a_VEHICLE_NAME = "Camper";
  314.         case 484: a_VEHICLE_NAME = "Marquis";
  315.         case 485: a_VEHICLE_NAME = "Baggage";
  316.         case 486: a_VEHICLE_NAME = "Dozer";
  317.         case 487: a_VEHICLE_NAME = "Maverick";
  318.         case 488: a_VEHICLE_NAME = "San News Maverick";
  319.         case 489: a_VEHICLE_NAME = "Rancher";
  320.         case 490: a_VEHICLE_NAME = "FBI Rancher";
  321.         case 491: a_VEHICLE_NAME = "Virgo";
  322.         case 492: a_VEHICLE_NAME = "Greenwood";
  323.         case 493: a_VEHICLE_NAME = "Jetmax";
  324.         case 494: a_VEHICLE_NAME = "Hotring Racer";
  325.         case 495: a_VEHICLE_NAME = "Sandking";
  326.         case 496: a_VEHICLE_NAME = "Blista Compact";
  327.         case 497: a_VEHICLE_NAME = "Police Maverick";
  328.         case 498: a_VEHICLE_NAME = "Boxville";
  329.         case 499: a_VEHICLE_NAME = "Benson";
  330.         case 500: a_VEHICLE_NAME = "Mesa";
  331.         case 501: a_VEHICLE_NAME = "RC Goblin";
  332.         case 502: a_VEHICLE_NAME = "Hotring Racer";
  333.         case 503: a_VEHICLE_NAME = "Hotring Racer";
  334.         case 504: a_VEHICLE_NAME = "Bloodring Banger";
  335.         case 505: a_VEHICLE_NAME = "Rancher";
  336.         case 506: a_VEHICLE_NAME = "Super GT";
  337.         case 507: a_VEHICLE_NAME = "Elegant";
  338.         case 508: a_VEHICLE_NAME = "Journey";
  339.         case 509: a_VEHICLE_NAME = "Bike";
  340.         case 510: a_VEHICLE_NAME = "Mountain Bike";
  341.         case 511: a_VEHICLE_NAME = "Beagle";
  342.         case 512: a_VEHICLE_NAME = "Cropduster";
  343.         case 513: a_VEHICLE_NAME = "Stuntplane";
  344.         case 514: a_VEHICLE_NAME = "Tanker";
  345.         case 515: a_VEHICLE_NAME = "Roadtrain";
  346.         case 516: a_VEHICLE_NAME = "Nebula";
  347.         case 517: a_VEHICLE_NAME = "Majestic";
  348.         case 518: a_VEHICLE_NAME = "Buccaneer";
  349.         case 519: a_VEHICLE_NAME = "Shamal";
  350.         case 520: a_VEHICLE_NAME = "Hydra";
  351.         case 521: a_VEHICLE_NAME = "FCR-900";
  352.         case 522: a_VEHICLE_NAME = "NRG-500";
  353.         case 523: a_VEHICLE_NAME = "HPV-1000";
  354.         case 524: a_VEHICLE_NAME = "Cement Truck";
  355.         case 525: a_VEHICLE_NAME = "TowTruck";
  356.         case 526: a_VEHICLE_NAME = "Fortune";
  357.         case 527: a_VEHICLE_NAME = "Cadrona";
  358.         case 528: a_VEHICLE_NAME = "FBI Truck";
  359.         case 529: a_VEHICLE_NAME = "Willard";
  360.         case 530: a_VEHICLE_NAME = "Forklift";
  361.         case 531: a_VEHICLE_NAME = "Tractor";
  362.         case 532: a_VEHICLE_NAME = "Combine Harvester";
  363.         case 533: a_VEHICLE_NAME = "Feltzer";
  364.         case 534: a_VEHICLE_NAME = "Remington";
  365.         case 535: a_VEHICLE_NAME = "Slamvan";
  366.         case 536: a_VEHICLE_NAME = "Blade";
  367.         case 537: a_VEHICLE_NAME = "Freight (Train)";
  368.         case 538: a_VEHICLE_NAME = "Brownstreak (Train)";
  369.         case 539: a_VEHICLE_NAME = "Vortex";
  370.         case 540: a_VEHICLE_NAME = "Vincent";
  371.         case 541: a_VEHICLE_NAME = "Bullet";
  372.         case 542: a_VEHICLE_NAME = "Clover";
  373.         case 543: a_VEHICLE_NAME = "Sadler";
  374.         case 544: a_VEHICLE_NAME = "Firetruck LA";
  375.         case 545: a_VEHICLE_NAME = "Hustler";
  376.         case 546: a_VEHICLE_NAME = "Intruder";
  377.         case 547: a_VEHICLE_NAME = "Primo";
  378.         case 548: a_VEHICLE_NAME = "Cargobob";
  379.         case 549: a_VEHICLE_NAME = "Tampa";
  380.         case 550: a_VEHICLE_NAME = "Sunrise";
  381.         case 551: a_VEHICLE_NAME = "Merit";
  382.         case 552: a_VEHICLE_NAME = "Utility Van";
  383.         case 553: a_VEHICLE_NAME = "Nevada";
  384.         case 554: a_VEHICLE_NAME = "Yosemite";
  385.         case 555: a_VEHICLE_NAME = "Windsor";
  386.         case 556: a_VEHICLE_NAME = "Monster ''A''";
  387.         case 557: a_VEHICLE_NAME = "Monster ''B''";
  388.         case 558: a_VEHICLE_NAME = "Uranus";
  389.         case 559: a_VEHICLE_NAME = "Jester";
  390.         case 560: a_VEHICLE_NAME = "Sultan";
  391.         case 561: a_VEHICLE_NAME = "Stratum";
  392.         case 562: a_VEHICLE_NAME = "Elegy";
  393.         case 563: a_VEHICLE_NAME = "Raindance";
  394.         case 564: a_VEHICLE_NAME = "RC Tiger";
  395.         case 565: a_VEHICLE_NAME = "Flash";
  396.         case 566: a_VEHICLE_NAME = "Tahoma";
  397.         case 567: a_VEHICLE_NAME = "Savanna";
  398.         case 568: a_VEHICLE_NAME = "Bandito";
  399.         case 569: a_VEHICLE_NAME = "Freight Flat Trailer";
  400.         case 570: a_VEHICLE_NAME = "Streak Trailer";
  401.         case 571: a_VEHICLE_NAME = "Kart";
  402.         case 572: a_VEHICLE_NAME = "Mower";
  403.         case 573: a_VEHICLE_NAME = "Dune";
  404.         case 574: a_VEHICLE_NAME = "Sweeper";
  405.         case 575: a_VEHICLE_NAME = "Broadway";
  406.         case 576: a_VEHICLE_NAME = "Tornado";
  407.         case 577: a_VEHICLE_NAME = "AT400";
  408.         case 578: a_VEHICLE_NAME = "DFT-30";
  409.         case 579: a_VEHICLE_NAME = "Huntley";
  410.         case 580: a_VEHICLE_NAME = "Stafford";
  411.         case 581: a_VEHICLE_NAME = "BF-400";
  412.         case 582: a_VEHICLE_NAME = "Newsvan";
  413.         case 583: a_VEHICLE_NAME = "Tug";
  414.         case 584: a_VEHICLE_NAME = "Petrol Trailer";
  415.         case 585: a_VEHICLE_NAME = "Emperor";
  416.         case 586: a_VEHICLE_NAME = "Wayfarer";
  417.         case 587: a_VEHICLE_NAME = "Euros";
  418.         case 588: a_VEHICLE_NAME = "Hotdog";
  419.         case 589: a_VEHICLE_NAME = "Club";
  420.         case 590: a_VEHICLE_NAME = "Freight Box Trailer";
  421.         case 591: a_VEHICLE_NAME = "Article Trailer 3";
  422.         case 592: a_VEHICLE_NAME = "Andromada";
  423.         case 593: a_VEHICLE_NAME = "Dodo";
  424.         case 594: a_VEHICLE_NAME = "RC Cam";
  425.         case 595: a_VEHICLE_NAME = "Launch";
  426.         case 596: a_VEHICLE_NAME = "Police Car (LSPD)";
  427.         case 597: a_VEHICLE_NAME = "Police Car (SFPD)";
  428.         case 598: a_VEHICLE_NAME = "Police Car (LVPD)";
  429.         case 599: a_VEHICLE_NAME = "Police Ranger";
  430.         case 600: a_VEHICLE_NAME = "Picador";
  431.         case 601: a_VEHICLE_NAME = "S.W.A.T";
  432.         case 602: a_VEHICLE_NAME = "Alpha";
  433.         case 603: a_VEHICLE_NAME = "Phoenix";
  434.         case 604: a_VEHICLE_NAME = "Glendale Shit";
  435.         case 605: a_VEHICLE_NAME = "Sadler Shit";
  436.         case 606: a_VEHICLE_NAME = "Baggage Trailer ''A''";
  437.         case 607: a_VEHICLE_NAME = "Baggage Trailer ''B''";
  438.         case 608: a_VEHICLE_NAME = "Tug Stairs Trailer";
  439.         case 609: a_VEHICLE_NAME = "Boxville";
  440.         case 610: a_VEHICLE_NAME = "Farm Trailer";
  441.         case 611: a_VEHICLE_NAME = "Utility Trailer";
  442.         default: a_VEHICLE_NAME = "Unknown Vehicle";
  443.     }
  444.     return a_VEHICLE_NAME;
  445. }
  446.  
  447. forward maploader_Update();
  448. public maploader_Update()
  449. {
  450.     new
  451.         Float:fPlayerPos[3];
  452.  
  453.     for (new slots = GetMaxPlayers( ), i; i < slots; i++)
  454.     {
  455.         if (!IsPlayerConnected(i))
  456.             continue;
  457.  
  458.         if (!IsPlayerInAnyVehicle(i))
  459.             continue;
  460.        
  461.         GetPlayerPos(i, fPlayerPos[0], fPlayerPos[1], fPlayerPos[2]);
  462.  
  463.         for (new p; p < repairs; p++)
  464.         {
  465.             if(IsPlayerInRangeOfPoint(i, 4.0, gMapRepairData[p][E_PICKUP_REPAIR_X], gMapRepairData[p][E_PICKUP_REPAIR_Y], gMapRepairData[p][E_PICKUP_REPAIR_Z]))
  466.             {
  467.                 new Float:vHealth;
  468.                 GetVehicleHealth(GetPlayerVehicleID(i), vHealth);
  469.                 if (vHealth == 1000)
  470.                     continue;
  471.                 RepairVehicle(GetPlayerVehicleID(i));
  472.                 PlayerPlaySound(i, 1133, 0.0, 0.0, 0.0);
  473.             }
  474.         }
  475.  
  476.         for (new p; p < nitros; p++)
  477.         {
  478.             if(IsPlayerInRangeOfPoint(i, 4.0, gMapNitroData[p][E_PICKUP_NITRO_X], gMapNitroData[p][E_PICKUP_NITRO_Y], gMapNitroData[p][E_PICKUP_NITRO_Z]))
  479.             {
  480.                 AddVehicleComponent(GetPlayerVehicleID(i), 1010);
  481.                 PlayerPlaySound(i, 1133, 0.0, 0.0, 0.0);
  482.             }
  483.         }
  484.  
  485.         for (new p; p < vehiclechanges; p++)
  486.         {
  487.             if(IsPlayerInRangeOfPoint(i, 4.0, gMapVehicleData[p][E_PICKUP_VEHICLE_X], gMapVehicleData[p][E_PICKUP_VEHICLE_Y], gMapVehicleData[p][E_PICKUP_VEHICLE_Z]))
  488.             {
  489.                 if(GetVehicleModel(GetPlayerVehicleID(i)) == gMapVehicleData[p][E_PICKUP_VEHICLE_MODEL])
  490.                     continue;
  491.  
  492.                 new
  493.                     Float:Velocity[3],
  494.                     Float:Position[4],
  495.                     vehicleid;
  496.  
  497.                 GetVehicleVelocity(GetPlayerVehicleID(i), Velocity[0], Velocity[1], Velocity[2]);
  498.                 GetVehiclePos(GetPlayerVehicleID(i), Position[0], Position[1], Position[2]);
  499.                 GetVehicleZAngle(GetPlayerVehicleID(i), Position[3]);
  500.  
  501.                 DestroyVehicle(GetPlayerVehicleID(i));
  502.  
  503.                 vehicleid = CreateVehicle(gMapVehicleData[p][E_PICKUP_VEHICLE_MODEL], Position[0], Position[1], Position[2], Position[3], -1, -1, 60);
  504.                 PutPlayerInVehicle(i, vehicleid, false);
  505.                 SetVehicleVelocity(vehicleid, Velocity[0], Velocity[1], Velocity[2]);
  506.  
  507.                 PlayerPlaySound(i, 1133, 0.0, 0.0, 0.0);
  508.             }
  509.         }
  510.     }
  511.     return 1;
  512. }
  513.  
  514. #if !defined FILTERSCRIPT
  515. public OnGameModeInit()
  516. {
  517.     SetTimer("maploader_Update", MAPLOADER_UPDATE, true);
  518.     return CallLocalFunction("maploader_OnGameModeInit", "");
  519. }
  520. #if defined _ALS_OnGameModeInit
  521.     #undef OnGameModeInit
  522. #else
  523.     #define _ALS_OnGameModeInit
  524. #endif
  525. #define OnGameModeInit maploader_OnGameModeInit
  526. forward maploader_OnGameModeInit();
  527. #else
  528. public OnFilterScriptInit()
  529. {
  530.     SetTimer("maploader_Update", MAPLOADER_UPDATE, true);
  531.     return CallLocalFunction("maploader_OnFilterScriptInit", "");
  532. }
  533. #if defined _ALS_OnFilterScriptInit
  534.     #undef OnFilterScriptInit
  535. #else
  536.     #define _ALS_OnFilterScriptInit
  537. #endif
  538. #define OnFilterScriptInit maploader_OnFilterScriptInit
  539. forward maploader_OnFilterScriptInit();
  540. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement