Yossef_Jones

FS

May 17th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 38.68 KB | None | 0 0
  1. /*
  2. This TruckMission FilterScript is made by =>Sandra<= on the 10th of March 2008
  3. Do not remove any credits!
  4. */
  5.  
  6. #include <a_samp>
  7. #include <dini>
  8.  
  9. #define MAX_MISSIONS 25
  10.  
  11. #define MissionFile "Truckmissions/%d.mission"
  12. #define DefaultCheckpointSize 5
  13. #define DefaultTruckModel 515
  14. #define DefaultTrailerModel 435
  15. #define DefaultPrize 1000
  16.  
  17. //Colors
  18. #define COLOR_RED 0xFF0000AA
  19. #define COLOR_GREEN 0x00FF00AA
  20. #define COLOR_BLUE 0x0000FFAA
  21. #define COLOR_YELLOW 0xFFFF00AA
  22. #define COLOR_ORANGE 0xFFA500AA
  23. #define COLOR_MENU 0xADFF2FAA //Green/Yellow
  24. #define COLOR_MENUHEADER 0x7CFC00AA
  25. #define COLOR_AQUA 0x66CDAAAA
  26.  
  27. //Actions
  28. #define CHANGE_NAME 1
  29. #define CHANGE_PRIZE 2
  30. #define CHANGE_MODEL 3
  31. #define CHANGE_CPSIZE 4
  32. #define CHANGE_TRAILER 5
  33. #define CHANGE_COLOR1 6
  34. #define CHANGE_COLOR2 7
  35. #define CHANGE_TIMELIMIT 8
  36.  
  37. /*
  38. ===============Usable Truck & Trailer Models:
  39. Truck-Models:
  40. 403 - Linerunner
  41. 514 - Petrol Tanker
  42. 515 - RoadTrain
  43.  
  44. Trailer-Models:
  45. 435 - Trailer 1
  46. 450 - Trailer 2
  47. 591 - Trailer 3
  48. 584 - PetrolTrailer
  49. =============================================
  50. */
  51.  
  52. enum Minfo
  53. {
  54.     Ready,
  55.     DoesExists,
  56.     Float:StartX,
  57.     Float:StartY,
  58.     Float:StartZ,
  59.     Float:StartAngle,
  60.     Float:EndX,
  61.     Float:EndY,
  62.     Float:EndZ,
  63.     CpSize,
  64.     Prize,
  65.     Name[50],
  66.     TruckModel,
  67.     TruckColor1,
  68.     TruckColor2,
  69.     Highscore,
  70.     HighscoreName[MAX_PLAYER_NAME],
  71.     IsGettingPlayed,
  72.     TickcountBeforeStart,
  73.     TrailerModel,
  74.     UseTrailer,
  75.     TimeLimit,
  76.     Timer,
  77. }
  78. new MissionInfo[MAX_MISSIONS][Minfo];
  79.  
  80. new VehNames[212][] =
  81. {
  82.    "Landstalker", "Bravura",   "Buffalo",   "Linerunner",   "Pereniel",   "Sentinel",   "Dumper",   "Firetruck",   "Trashmaster",   "Stretch",
  83.    "Manana",   "Infernus",   "Voodoo",   "Pony",   "Mule",   "Cheetah",   "Ambulance",   "Leviathan",   "Moonbeam",   "Esperanto",   "Taxi",
  84.    "Washington",   "Bobcat",   "Mr Whoopee",   "BF Injection",   "Hunter",   "Premier",   "Enforcer",   "Securicar",   "Banshee",   "Predator",
  85.    "Bus",   "Rhino",   "Barracks",   "Hotknife",   "Trailer",   "Previon",   "Coach",   "Cabbie",   "Stallion",   "Rumpo",   "RC Bandit",  "Romero",
  86.    "Packer",   "Monster",   "Admiral",   "Squalo",   "Seasparrow",   "Pizzaboy",   "Tram",   "Trailer",   "Turismo",   "Speeder",   "Reefer",   "Tropic",   "Flatbed",
  87.    "Yankee",   "Caddy",   "Solair",   "Berkley's RC Van",   "Skimmer",   "PCJ-600",   "Faggio",   "Freeway",   "RC Baron",   "RC Raider",
  88.    "Glendale",   "Oceanic",   "Sanchez",   "Sparrow",   "Patriot",   "Quad",   "Coastguard",   "Dinghy",   "Hermes",   "Sabre",   "Rustler",
  89.    "ZR3 50",   "Walton",   "Regina",   "Comet",   "BMX",   "Burrito",   "Camper",   "Marquis",   "Baggage",   "Dozer",   "Maverick",   "News Chopper",
  90.    "Rancher",   "FBI Rancher",   "Virgo",   "Greenwood",   "Jetmax",   "Hotring",   "Sandking",   "Blista Compact",   "Police Maverick",
  91.    "Boxville",   "Benson",   "Mesa",   "RC Goblin",   "Hotring Racer",   "Hotring Racer",   "Bloodring Banger",   "Rancher",   "Super GT",
  92.    "Elegant",   "Journey",   "Bike",   "Mountain Bike",   "Beagle",   "Cropdust",   "Stunt",   "Tanker",   "RoadTrain",   "Nebula",   "Majestic",
  93.    "Buccaneer",   "Shamal",   "Hydra",   "FCR-900",   "NRG-500",   "HPV1000",   "Cement Truck",   "Tow Truck",   "Fortune",   "Cadrona",   "FBI Truck",
  94.    "Willard",   "Forklift",   "Tractor",   "Combine",   "Feltzer",   "Remington",   "Slamvan",   "Blade",   "Freight",   "Streak",   "Vortex",   "Vincent",
  95.    "Bullet",   "Clover",   "Sadler",   "Firetruck",   "Hustler",   "Intruder",   "Primo",   "Cargobob",   "Tampa",   "Sunrise",   "Merit",   "Utility",
  96.    "Nevada",   "Yosemite",   "Windsor",   "Monster",   "Monster",   "Uranus",   "Jester",   "Sultan",   "Stratum",   "Elegy",   "Raindance",   "RC Tiger",
  97.    "Flash",   "Tahoma",   "Savanna",   "Bandito",   "Freight",   "Trailer",   "Kart",   "Mower",   "Duneride",   "Sweeper",   "Broadway",
  98.    "Tornado",   "AT-400",   "DFT-30",   "Huntley",   "Stafford",   "BF-400",   "Newsvan",   "Tug",   "Trailer",   "Emperor",   "Wayfarer",
  99.    "Euros",   "Hotdog",   "Club",   "Trailer",   "Trailer",   "Andromada",   "Dodo",   "RC Cam",   "Launch",   "Police Car (LSPD)",   "Police Car (SFPD)",
  100.    "Police Car (LVPD)",   "Police Ranger",   "Picador",   "S.W.A.T. Van",   "Alpha",   "Phoenix",   "Glendale",   "Sadler",   "Luggage Trailer",
  101.    "Luggage Trailer",   "Stair Trailer",   "Boxville",   "Farm Plow",   "Utility Trailer"
  102. };
  103.  
  104. new TruckmissionPlaying[MAX_PLAYERS];
  105. new FileName[60];
  106. new Question;
  107. new Menu:SettingsMenu1;
  108. new Menu:SettingsMenu2;
  109. new Menu:UseTrailerMenu;
  110. new Menu:ColorMenu;
  111. new SpecialAction[MAX_PLAYERS];
  112. new EditMissionID;
  113. new Truck[MAX_MISSIONS];
  114. new Trailer[MAX_MISSIONS];
  115.  
  116.  
  117. public OnFilterScriptInit()
  118. {
  119.     for(new i=1; i<MAX_MISSIONS; i++)
  120.     {
  121.         format(MissionInfo[i][HighscoreName], MAX_PLAYER_NAME, "Nobody");
  122.         format(FileName, sizeof(FileName), MissionFile, i);
  123.         if(dini_Exists(FileName))
  124.         {
  125.             MissionInfo[i][DoesExists] = 1;
  126.             ReadFile(i);
  127.         }
  128.     }
  129.     SettingsMenu1 = CreateMenu("Settings", 1, 150, 150, 300, 40);
  130.     AddMenuItem(SettingsMenu1, 0, "Change Name");
  131.     AddMenuItem(SettingsMenu1, 0, "Set StartPosition");
  132.     AddMenuItem(SettingsMenu1, 0, "Set Finishposition");
  133.     AddMenuItem(SettingsMenu1, 0, "Change Checkpointsize");
  134.     AddMenuItem(SettingsMenu1, 0, "Change Prize");
  135.     AddMenuItem(SettingsMenu1, 0, "Change Truckmodel");
  136.     AddMenuItem(SettingsMenu1, 0, "Reset Highscore");
  137.     AddMenuItem(SettingsMenu1, 0, "View MissionInfo");
  138.     AddMenuItem(SettingsMenu1, 0, "Reload Mission");
  139.     AddMenuItem(SettingsMenu1, 0, "Next");
  140.     SettingsMenu2 = CreateMenu("Settings", 1, 150, 150, 300, 40);
  141.     AddMenuItem(SettingsMenu2, 0, "Use Trailer");
  142.     AddMenuItem(SettingsMenu2, 0, "Change Trailermodel");
  143.     AddMenuItem(SettingsMenu2, 0, "Change Truckcolor");
  144.     AddMenuItem(SettingsMenu2, 0, "Set TimeLimit");
  145.     AddMenuItem(SettingsMenu2, 0, "Back");
  146.     UseTrailerMenu = CreateMenu(" ", 1, 150, 150, 300, 40);
  147.     SetMenuColumnHeader(UseTrailerMenu, 0, "Do you want to use a trailer?");
  148.     AddMenuItem(UseTrailerMenu, 0, "Yes");
  149.     AddMenuItem(UseTrailerMenu, 0, "No");
  150.     AddMenuItem(UseTrailerMenu, 0, "Back");
  151.     ColorMenu = CreateMenu("Colors", 1, 150, 150, 300, 40);
  152.     AddMenuItem(ColorMenu, 0, "Change Color 1");
  153.     AddMenuItem(ColorMenu, 0, "Change Color 2");
  154.     AddMenuItem(ColorMenu, 0, "Show Color ID's");
  155.     AddMenuItem(ColorMenu, 0, "Back");
  156.     print("==========================================");
  157.     print("This Truckmission Filterscript is made by:");
  158.     print("                =>Sandra<=                ");
  159.     print("        Do not remove the credits!        ");
  160.     print("==========================================");
  161.     return 1;
  162. }
  163.  
  164. public OnFilterScriptExit()
  165. {
  166.     SaveFiles();
  167.     for(new i; i<MAX_PLAYERS; i++)
  168.     {
  169.         if(IsPlayerConnected(i))
  170.         {
  171.             for(new ID=1; ID<MAX_MISSIONS; ID++)
  172.             {
  173.                 if(IsPlayerInVehicle(i, Truck[ID]))
  174.                 {
  175.                     RemovePlayerFromVehicle(i);
  176.                 }
  177.             }
  178.         }
  179.     }
  180.     for(new ID=1; ID<MAX_MISSIONS; ID++)
  181.     {
  182.         DestroyVehicle(Truck[ID]);
  183.         DestroyVehicle(Trailer[ID]);
  184.     }
  185.     return 1;
  186. }
  187.  
  188. public OnPlayerConnect(playerid)
  189. {
  190.     TruckmissionPlaying[playerid] = 0;
  191.     SpecialAction[playerid] = 0;
  192.     return 1;
  193. }
  194.  
  195. public OnPlayerDisconnect(playerid, reason)
  196. {
  197.     new ID = TruckmissionPlaying[playerid];
  198.     if(ID > 0)
  199.     {
  200.         MissionInfo[ID][IsGettingPlayed] = 0;
  201.         MissionInfo[ID][TickcountBeforeStart] = 0;
  202.         DisablePlayerCheckpoint(playerid);
  203.         SetVehicleToRespawn(Truck[ID]);
  204.         SetVehicleToRespawn(Trailer[ID]);
  205.         KillTimer(MissionInfo[ID][Timer]);
  206.         if(MissionInfo[ID][UseTrailer] == 1)
  207.         {
  208.             DestroyVehicle(Trailer[ID]);
  209.         }
  210.     }
  211.     TruckmissionPlaying[playerid] = 0;
  212.     return 1;
  213. }
  214.  
  215.  
  216. public OnVehicleDeath(vehicleid, killerid)
  217. {
  218.     new PTruck;
  219.     for(new ID=1; ID<MAX_MISSIONS; ID++)
  220.     {
  221.         if(Truck[ID] == vehicleid)
  222.         {
  223.             PTruck = ID;
  224.             break;
  225.         }
  226.     }
  227.     if(PTruck > 0)
  228.     {
  229.         for(new i; i<MAX_PLAYERS; i++)
  230.         {
  231.             if(IsPlayerConnected(i))
  232.             {
  233.                 if(TruckmissionPlaying[i] == PTruck)
  234.                 {
  235.                     GameTextForPlayer(i, "~r~Loser", 5000, 3);
  236.                     TruckmissionPlaying[i] = 0;
  237.                     MissionInfo[PTruck][IsGettingPlayed] = 0;
  238.                     MissionInfo[PTruck][TickcountBeforeStart] = 0;
  239.                     DisablePlayerCheckpoint(i);
  240.                     SendClientMessage(i, COLOR_RED, "You failed the Truckmission!");
  241.                     SetVehicleToRespawn(Truck[PTruck]);
  242.                     TruckmissionPlaying[i] = 0;
  243.                     if(MissionInfo[PTruck][UseTrailer] == 1)
  244.                     {
  245.                         DestroyVehicle(Trailer[PTruck]);
  246.                     }
  247.                 }
  248.             }
  249.         }
  250.     }
  251.     return 1;
  252. }
  253.  
  254. public OnPlayerText(playerid, text[])
  255. {
  256.     if(SpecialAction[playerid] > 0)
  257.     {
  258.         switch(SpecialAction[playerid])
  259.         {
  260.             case CHANGE_NAME:
  261.             {
  262.                 new string[128];
  263.                 format(MissionInfo[EditMissionID][Name], 50, "%s", text);
  264.                 format(string, sizeof(string), "The new name of TruckMission #%d is: \"%s\".", EditMissionID, MissionInfo[EditMissionID][Name]);
  265.                 SendClientMessage(playerid, COLOR_GREEN, string);
  266.                 GameTextForPlayer(playerid, " ", 100, 3);
  267.                 ShowMenuForPlayer(SettingsMenu1, playerid);
  268.                 SpecialAction[playerid] = 0;
  269.                 return 0;
  270.             }
  271.             case CHANGE_PRIZE:
  272.             {
  273.                 if(!IsNumeric(text))
  274.                 {
  275.                     SendClientMessage(playerid, COLOR_RED, "Only numbers allowed!");
  276.                     return 0;
  277.                 }
  278.                 else
  279.                 {
  280.                     new newval = strval(text);
  281.                     new string[128];
  282.                     MissionInfo[EditMissionID][Prize] = newval;
  283.                     format(string, sizeof(string), "The new prize of TruckMission #%d is: $%d", EditMissionID, MissionInfo[EditMissionID][Prize]);
  284.                     SendClientMessage(playerid, COLOR_GREEN, string);
  285.                     GameTextForPlayer(playerid, " ", 100, 3);
  286.                     ShowMenuForPlayer(SettingsMenu1, playerid);
  287.                     SpecialAction[playerid] = 0;
  288.                 }
  289.                 return 0;
  290.             }
  291.             case CHANGE_CPSIZE:
  292.             {
  293.                 if(!IsNumeric(text))
  294.                 {
  295.                     SendClientMessage(playerid, COLOR_RED, "Only numbers allowed!");
  296.                     return 0;
  297.                 }
  298.                 else
  299.                 {
  300.                     new newval = strval(text);
  301.                     new string[128];
  302.                     MissionInfo[EditMissionID][CpSize] = newval;
  303.                     format(string, sizeof(string), "The new CheckpointSize of TruckMission #%d is: %d", EditMissionID, MissionInfo[EditMissionID][CpSize]);
  304.                     SendClientMessage(playerid, COLOR_GREEN, string);
  305.                     GameTextForPlayer(playerid, " ", 100, 3);
  306.                     ShowMenuForPlayer(SettingsMenu1, playerid);
  307.                     SpecialAction[playerid] = 0;
  308.                     return 0;
  309.                 }
  310.             }
  311.             case CHANGE_MODEL:
  312.             {
  313.                 if(!IsNumeric(text))
  314.                 {
  315.                     SendClientMessage(playerid, COLOR_RED, "Only numbers allowed!");
  316.                     return 0;
  317.                 }
  318.                 if(!IsUsableTruck(strval(text)))
  319.                 {
  320.                     SendClientMessage(playerid, COLOR_RED, "Invalid Model. (Available: 403, 514, 515)");
  321.                     return 0;
  322.                 }
  323.                 else
  324.                 {
  325.                     new newval = strval(text);
  326.                     new string[128];
  327.                     MissionInfo[EditMissionID][TruckModel] = newval;
  328.                     format(string, sizeof(string), "The new Truckmodel of TruckMission #%d is: %d (%s)", EditMissionID, MissionInfo[EditMissionID][TruckModel], VehNames[newval-400]);
  329.                     SendClientMessage(playerid, COLOR_GREEN, string);
  330.                     GameTextForPlayer(playerid, " ", 100, 3);
  331.                     ShowMenuForPlayer(SettingsMenu1, playerid);
  332.                     SpecialAction[playerid] = 0;
  333.                     return 0;
  334.                 }
  335.             }
  336.             case CHANGE_TRAILER:
  337.             {
  338.                 if(!IsNumeric(text))
  339.                 {
  340.                     SendClientMessage(playerid, COLOR_RED, "Only numbers allowed!");
  341.                     return 0;
  342.                 }
  343.                 if(!IsUsableTrailer(strval(text)))
  344.                 {
  345.                     SendClientMessage(playerid, COLOR_RED, "Invalid Model. (Available: 435, 450, 584, 591)");
  346.                     return 0;
  347.                 }
  348.                 else
  349.                 {
  350.                     new newval = strval(text);
  351.                     new string[128];
  352.                     MissionInfo[EditMissionID][TrailerModel] = newval;
  353.                     format(string, sizeof(string), "The new TrailerModel of TruckMission #%d is: %d (%s)", EditMissionID, MissionInfo[EditMissionID][TrailerModel], VehNames[newval-400]);
  354.                     SendClientMessage(playerid, COLOR_GREEN, string);
  355.                     GameTextForPlayer(playerid, " ", 100, 3);
  356.                     ShowMenuForPlayer(SettingsMenu2, playerid);
  357.                     SpecialAction[playerid] = 0;
  358.                     return 0;
  359.                 }
  360.             }
  361.             case CHANGE_COLOR1:
  362.             {
  363.                 if(!IsNumeric(text))
  364.                 {
  365.                     SendClientMessage(playerid, COLOR_RED, "Only numbers allowed!");
  366.                     return 0;
  367.                 }
  368.                 else
  369.                 {
  370.                     new newval = strval(text);
  371.                     if(newval < -1 || newval > 126)
  372.                     {
  373.                         SendClientMessage(playerid, COLOR_RED, "Pick a number between -1 and 126!");
  374.                         return 0;
  375.                     }
  376.                     new string[128];
  377.                     MissionInfo[EditMissionID][TruckColor1] = newval;
  378.                     format(string, sizeof(string), "The new Truckcolor1 of TruckMission #%d is: %d", EditMissionID, MissionInfo[EditMissionID][TruckColor1]);
  379.                     SendClientMessage(playerid, COLOR_GREEN, string);
  380.                     GameTextForPlayer(playerid, " ", 100, 3);
  381.                     ShowMenuForPlayer(SettingsMenu2, playerid);
  382.                     SpecialAction[playerid] = 0;
  383.                     return 0;
  384.                 }
  385.             }
  386.             case CHANGE_COLOR2:
  387.             {
  388.                 if(!IsNumeric(text))
  389.                 {
  390.                     SendClientMessage(playerid, COLOR_RED, "Only numbers allowed!");
  391.                     return 0;
  392.                 }
  393.                 else
  394.                 {
  395.                     new newval = strval(text);
  396.                     if(newval < -1 || newval > 126)
  397.                     {
  398.                         SendClientMessage(playerid, COLOR_RED, "Pick a number between -1 and 126!");
  399.                         return 0;
  400.                     }
  401.                     new string[128];
  402.                     MissionInfo[EditMissionID][TruckColor2] = newval;
  403.                     format(string, sizeof(string), "The new Truckcolor2 of TruckMission #%d is: %d", EditMissionID, MissionInfo[EditMissionID][TruckColor2]);
  404.                     SendClientMessage(playerid, COLOR_GREEN, string);
  405.                     GameTextForPlayer(playerid, " ", 100, 3);
  406.                     ShowMenuForPlayer(SettingsMenu2, playerid);
  407.                     SpecialAction[playerid] = 0;
  408.                     return 0;
  409.                 }
  410.             }
  411.             case CHANGE_TIMELIMIT:
  412.             {
  413.                 if(!IsNumeric(text))
  414.                 {
  415.                     SendClientMessage(playerid, COLOR_RED, "Only numbers allowed!");
  416.                     return 0;
  417.                 }
  418.                 else
  419.                 {
  420.                     new newval = strval(text);
  421.                     if(newval < 0)
  422.                     {
  423.                         SendClientMessage(playerid, COLOR_RED, "You can't set a negative number!");
  424.                         return 0;
  425.                     }
  426.                     new string[128];
  427.                     MissionInfo[EditMissionID][TimeLimit] = newval;
  428.                     format(string, sizeof(string), "The new timelimit of TruckMission #%d is %d seconds", EditMissionID, MissionInfo[EditMissionID][TimeLimit]);
  429.                     SendClientMessage(playerid, COLOR_GREEN, string);
  430.                     GameTextForPlayer(playerid, " ", 100, 3);
  431.                     ShowMenuForPlayer(SettingsMenu2, playerid);
  432.                     SpecialAction[playerid] = 0;
  433.                     return 0;
  434.                 }
  435.             }
  436.         }
  437.     }
  438.     return 1;
  439. }
  440.  
  441.  
  442. public OnPlayerCommandText(playerid, cmdtext[])
  443. {
  444.     new cmd[256], tmp[256], idx;
  445.     cmd = strtok(cmdtext, idx);
  446.    
  447.     if (strcmp("/createmission", cmdtext, true) == 0)
  448.     {
  449.         new NewID;
  450.         if(!IsPlayerAdmin(playerid)) return 0;
  451.         for(new i=1; i<MAX_MISSIONS; i++)
  452.         {
  453.             if(MissionInfo[i][DoesExists] == 0)
  454.             {
  455.                 NewID = i;
  456.                 new string[128];
  457.                 format(string, sizeof(string), "The ID of this new Truckmission is: %d.  Use: \"/editmission %d\" to edit this mission.", NewID, NewID);
  458.                 SendClientMessage(playerid, COLOR_YELLOW, string);
  459.                 MissionInfo[NewID][DoesExists] = 1;
  460.                 CreateNewFile(NewID);
  461.                 break;
  462.             }
  463.         }
  464.         if(NewID == 0)
  465.         {
  466.             SendClientMessage(playerid, COLOR_RED, "Limit of Truckmissions reached! You can increase this limit in the .pwn file!");
  467.         }
  468.         return 1;
  469.     }
  470.    
  471.     if(strcmp(cmd, "/deletemission", true) == 0)
  472.     {
  473.         if(!IsPlayerAdmin(playerid)) return 0;
  474.         new string[128];
  475.         tmp = strtok(cmdtext, idx);
  476.         if(!strlen(tmp))
  477.         {
  478.             SendClientMessage(playerid,COLOR_RED, "Use: /deletemission [MissionID]");
  479.             return 1;
  480.         }
  481.         new ID = strval(tmp);
  482.         if(MissionInfo[ID][DoesExists] == 1)
  483.         {
  484.             format(FileName, sizeof(FileName), MissionFile, ID);
  485.             dini_Remove(FileName);
  486.             MissionInfo[ID][DoesExists] = 0;
  487.             format(string, sizeof(string), "You deleted Truckmission #%d.", ID);
  488.             SendClientMessage(playerid, COLOR_ORANGE, string);
  489.             DestroyVehicle(Truck[ID]);
  490.             DestroyVehicle(Trailer[ID]);
  491.         }
  492.         else
  493.         {
  494.             format(string, sizeof(string), "Truckmission #%d does not exists!", ID);
  495.             SendClientMessage(playerid, COLOR_RED, string);
  496.         }
  497.         return 1;
  498.     }
  499.    
  500.     if(strcmp(cmd, "/editmission", true) == 0)
  501.     {
  502.         if(!IsPlayerAdmin(playerid)) return 0;
  503.         new string[128];
  504.         tmp = strtok(cmdtext, idx);
  505.         if(!strlen(tmp))
  506.         {
  507.             SendClientMessage(playerid,COLOR_RED, "Use: /editmission [MissionID]");
  508.             return 1;
  509.         }
  510.         new ID = strval(tmp);
  511.         if(MissionInfo[ID][DoesExists] == 1)
  512.         {
  513.             format(string, sizeof(string), "Settings for Truckmission #%d.", ID);
  514.             SetMenuColumnHeader(SettingsMenu1, 0, string);
  515.             ShowMenuForPlayer(SettingsMenu1, playerid);
  516.             TogglePlayerControllable(playerid, 0);
  517.             EditMissionID = ID;
  518.         }
  519.         else
  520.         {
  521.             format(string, sizeof(string), "Truckmission #%d does not exists!", ID);
  522.             SendClientMessage(playerid, COLOR_RED, string);
  523.         }
  524.         return 1;
  525.     }
  526.    
  527.     if(strcmp(cmd, "/missioninfo", true) == 0)
  528.     {
  529.         if(!IsPlayerAdmin(playerid)) return 0;
  530.         new string[128];
  531.         tmp = strtok(cmdtext, idx);
  532.         if(!strlen(tmp))
  533.         {
  534.             SendClientMessage(playerid,COLOR_RED, "Use: /missioninfo [MissionID]");
  535.             return 1;
  536.         }
  537.         new ID = strval(tmp);
  538.         if(MissionInfo[ID][DoesExists] == 1)
  539.         {
  540.             GetMissionInfo(playerid, ID);
  541.             return 1;
  542.         }
  543.         else
  544.         {
  545.             format(string, sizeof(string), "Truckmission #%d does not exists!", ID);
  546.             SendClientMessage(playerid, COLOR_RED, string);
  547.         }
  548.         return 1;
  549.     }
  550.  
  551.     if(strcmp(cmdtext, "/yes", true)==0)
  552.     {
  553.         if(!IsPlayerAdmin(playerid)) return 0;
  554.         if(Question == 0)
  555.         {
  556.             SendClientMessage(playerid, COLOR_RED, "There is no question for you at the moment.");
  557.             return 1;
  558.         }
  559.         if(Question == 1)
  560.         {
  561.             if(IsPlayerInAnyVehicle(playerid))
  562.             {
  563.                 GetVehiclePos(GetPlayerVehicleID(playerid), MissionInfo[EditMissionID][StartX], MissionInfo[EditMissionID][StartY], MissionInfo[EditMissionID][StartZ]);
  564.                 GetVehicleZAngle(GetPlayerVehicleID(playerid), MissionInfo[EditMissionID][StartAngle]);
  565.             }
  566.             else
  567.             {
  568.                 GetPlayerPos(playerid, MissionInfo[EditMissionID][StartX], MissionInfo[EditMissionID][StartY], MissionInfo[EditMissionID][StartZ]);
  569.                 GetPlayerFacingAngle(playerid, MissionInfo[EditMissionID][StartAngle]);
  570.             }
  571.             GameTextForPlayer(playerid, "~g~New StartPosition Saved!", 4000, 4);
  572.             Question = 0;
  573.             ShowMenuForPlayer(SettingsMenu1, playerid);
  574.             return 1;
  575.         }
  576.         if(Question == 2)
  577.         {
  578.             GetPlayerPos(playerid, MissionInfo[EditMissionID][EndX], MissionInfo[EditMissionID][EndY], MissionInfo[EditMissionID][EndZ]);
  579.             GameTextForPlayer(playerid, "~g~New FinishPosition Saved!", 4000, 4);
  580.             Question = 0;
  581.             ShowMenuForPlayer(SettingsMenu1, playerid);
  582.             return 1;
  583.         }
  584.     }
  585.    
  586.     if(strcmp(cmdtext, "/no", true)==0)
  587.     {
  588.         if(!IsPlayerAdmin(playerid)) return 0;
  589.         if(Question == 0)
  590.         {
  591.             SendClientMessage(playerid, COLOR_RED, "There is no question for you at the moment.");
  592.             return 1;
  593.         }
  594.         else
  595.         {
  596.             GameTextForPlayer(playerid, " ", 100, 3);
  597.             ShowMenuForPlayer(SettingsMenu1, playerid);
  598.         }
  599.         return 1;
  600.     }
  601.    
  602.     if(strcmp(cmd, "/startmission", true)==0)
  603.     {
  604.         if(TruckmissionPlaying[playerid] > 0) return SendClientMessage(playerid, COLOR_RED, "You are already playing a Truckmission!");
  605.         new IsInATruck;
  606.         new ID;
  607.         for(new i=1; i<MAX_MISSIONS; i++)
  608.         {
  609.             if(IsPlayerInVehicle(playerid, Truck[i]))
  610.             {
  611.                 ID = i;
  612.                 IsInATruck = 1;
  613.                 break;
  614.             }
  615.         }
  616.         if(IsInATruck == 0) return SendClientMessage(playerid, COLOR_RED, "You are not inside a Mission-Truck!");
  617.         new string[128];
  618.         if(!IsMissionReady(ID))
  619.         {
  620.             SendClientMessage(playerid, COLOR_RED, "This mission is not ready yet!");
  621.             return 1;
  622.         }
  623.         if(MissionInfo[ID][IsGettingPlayed] == 0)
  624.         {
  625.             MissionInfo[ID][IsGettingPlayed] = 1;
  626.             TruckmissionPlaying[playerid] = ID;
  627.             if(MissionInfo[ID][UseTrailer] == 1)
  628.             {
  629.                 Trailer[ID] = CreateVehicle(MissionInfo[ID][TrailerModel], 0, 0, 0, 0, -1, -1, -1);//CreateVehicle(435, 1614.4490,-1825.0944,13.5061, 82.2873, 0, 1, 60);
  630.                 AttachTrailerToVehicle(Trailer[ID], Truck[ID]);
  631.             }
  632.             if(MissionInfo[ID][TimeLimit] > 0)
  633.             {
  634.                 MissionInfo[ID][Timer] = SetTimerEx("MissionTimer", (MissionInfo[ID][TimeLimit]*1000), 0, "id", playerid, ID);
  635.                 format(string, sizeof(string), "Take this truck to the checkpoint within %d seconds!", MissionInfo[ID][TimeLimit]);
  636.                 SendClientMessage(playerid, COLOR_AQUA, string);
  637.             }
  638.             else
  639.             {
  640.                 SendClientMessage(playerid, COLOR_AQUA, "Take this Truck to the checkpoint marked on the radar as fast as you can!");
  641.             }
  642.             TogglePlayerControllable(playerid, 1);
  643.             MissionInfo[ID][TickcountBeforeStart] = GetTickCount();
  644.            
  645.             SetPlayerCheckpoint(playerid, MissionInfo[ID][EndX], MissionInfo[ID][EndY], MissionInfo[ID][EndZ], MissionInfo[ID][CpSize]);
  646.         }
  647.         else
  648.         {
  649.             format(string, sizeof(string), "Sorry, someone else is already playing Truckmission #%d", ID);
  650.             SendClientMessage(playerid, COLOR_RED, string);
  651.         }
  652.         return 1;
  653.     }
  654.    
  655.     if(strcmp(cmd, "/stopmission", true)==0)
  656.     {
  657.         if(TruckmissionPlaying[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not playing a Truckmission!");
  658.         RemovePlayerFromVehicle(playerid);
  659.         new ID = TruckmissionPlaying[playerid];
  660.         TruckmissionPlaying[playerid] = 0;
  661.         MissionInfo[ID][IsGettingPlayed] = 0;
  662.         MissionInfo[ID][TickcountBeforeStart] = 0;
  663.         DisablePlayerCheckpoint(playerid);
  664.         SendClientMessage(playerid, COLOR_AQUA, "You stopped your current Truckmission!");
  665.         SetVehicleToRespawn(Truck[ID]);
  666.         KillTimer(MissionInfo[ID][Timer]);
  667.         if(MissionInfo[ID][UseTrailer] == 1)
  668.         {
  669.             DestroyVehicle(Trailer[ID]);
  670.         }
  671.         return 1;
  672.     }
  673.     if(strcmp(cmdtext, "/exit", true)==0)
  674.     {
  675.         TogglePlayerControllable(playerid, 1);
  676.         RemovePlayerFromVehicle(playerid);
  677.         return 1;
  678.     }
  679.    
  680.     if(strcmp(cmdtext, "/truckmissions", true)==0)
  681.     {
  682.         new string[128];
  683.         new count;
  684.         new busy[5];
  685.         SendClientMessage(playerid, COLOR_MENUHEADER, "=======Available Truckmissions:=========");
  686.         for(new i=1; i<MAX_MISSIONS; i++)
  687.         {
  688.             if(MissionInfo[i][DoesExists] == 1)
  689.             {
  690.                 if(MissionInfo[i][IsGettingPlayed] == 1) busy = "Busy";
  691.                 if(MissionInfo[i][IsGettingPlayed] == 0) busy = "Free";
  692.                 format(string, sizeof(string), "#%d = \"%s\"   %s", i, MissionInfo[i][Name], busy);
  693.                 SendClientMessage(playerid, COLOR_MENU, string);
  694.                 count++;
  695.             }
  696.         }
  697.         if(count > 9)
  698.         {
  699.             SendClientMessage(playerid, COLOR_ORANGE, "Use PageUp and PageDown to scroll through te chat");
  700.         }
  701.         return 1;
  702.     }
  703.     if(strcmp(cmdtext, "/truckmodels", true)==0)
  704.     {
  705.         if(!IsPlayerAdmin(playerid)) return 0;
  706.         SendClientMessage(playerid, COLOR_MENUHEADER, "=====Available Truck- & Trailermodels:=====");
  707.         SendClientMessage(playerid, COLOR_MENU, "Trucks: 403, 514, 515");
  708.         SendClientMessage(playerid, COLOR_MENU, "Trailers: 435, 450, 584, 591");
  709.         SendClientMessage(playerid, COLOR_MENUHEADER, "===========================================");
  710.         return 1;
  711.     }
  712.    
  713.     if(strcmp(cmdtext, "/truckhelp", true)==0)
  714.     {
  715.         SendClientMessage(playerid, COLOR_MENUHEADER, "=============Available Commands:==========");
  716.         SendClientMessage(playerid, COLOR_MENU, "/startmission, /exit, /stopmission, /truckmissions");
  717.         if(IsPlayerAdmin(playerid))
  718.         {
  719.             SendClientMessage(playerid, COLOR_MENUHEADER, "AdminCommands:");
  720.             SendClientMessage(playerid, COLOR_MENU, "/createmission, /deletemission <id>");
  721.             SendClientMessage(playerid, COLOR_MENU, "/editmission <id>, /missioninfo <id>");
  722.             SendClientMessage(playerid, COLOR_MENU, "/missionteleport <id>, /truckmodels");
  723.         }
  724.         return 1;
  725.     }
  726.    
  727.     if(strcmp(cmd, "/missionteleport", true) == 0)
  728.     {
  729.         if(!IsPlayerAdmin(playerid)) return 0;
  730.         new string[128];
  731.         tmp = strtok(cmdtext, idx);
  732.         if(!strlen(tmp))
  733.         {
  734.             SendClientMessage(playerid,COLOR_RED, "Use: /missionteleport [MissionID]");
  735.             return 1;
  736.         }
  737.         new ID = strval(tmp);
  738.         if(MissionInfo[ID][DoesExists] == 1)
  739.         {
  740.             SetPlayerPos(playerid, MissionInfo[ID][StartX], MissionInfo[ID][StartY], (MissionInfo[ID][StartZ]+4));
  741.             return 1;
  742.         }
  743.         else
  744.         {
  745.             format(string, sizeof(string), "Truckmission #%d does not exists!", ID);
  746.             SendClientMessage(playerid, COLOR_RED, string);
  747.         }
  748.         return 1;
  749.     }
  750.     if(strcmp(cmd, "/c", true) == 0)
  751.     {
  752.         if(!IsPlayerAdmin(playerid)) return 0;
  753.         new Float:x,Float:y,Float:z, Float:a;
  754.         tmp = strtok(cmdtext, idx);
  755.         new vid = strval(tmp);
  756.         if(vid < 400 || vid > 609)
  757.         {
  758.             SendClientMessage(playerid,COLOR_RED,"Gebruik: /car [400-609]");
  759.             return 1;
  760.         }
  761.         else
  762.         {
  763.             GetPlayerPos(playerid, x, y, z);
  764.             GetPlayerFacingAngle(playerid, a);
  765.             new newcar = CreateVehicle(vid,x, y, z, a, -1, -1, 240000);
  766.             PutPlayerInVehicle(playerid, newcar, 0);
  767.         }
  768.         return 1;
  769.     }
  770.     return 0;
  771. }
  772.  
  773. public OnPlayerExitVehicle(playerid, vehicleid)
  774. {
  775.     new PTruck;
  776.     for(new ID=1; ID<MAX_MISSIONS; ID++)
  777.     {
  778.         if(IsPlayerInVehicle(playerid, Truck[ID]))
  779.         {
  780.             PTruck = ID;
  781.             break;
  782.         }
  783.     }
  784.     if(PTruck > 0)
  785.     {
  786.         SendClientMessage(playerid, COLOR_RED, "You have 10 seconds to get back in your truck, or else the mission will be over!");
  787.         SetTimerEx("ExitedTruck", 10000, 0, "id", playerid, PTruck);
  788.     }
  789.        
  790.     return 1;
  791. }
  792.  
  793. public OnPlayerStateChange(playerid, newstate, oldstate)
  794. {
  795.     if(newstate == 2)
  796.     {
  797.         if(TruckmissionPlaying[playerid] == 0)
  798.         {
  799.             new PTruck;
  800.             for(new ID=1; ID<MAX_MISSIONS; ID++)
  801.             {
  802.                 if(IsPlayerInVehicle(playerid, Truck[ID]))
  803.                 {
  804.                     PTruck = ID;
  805.                     break;
  806.                 }
  807.             }
  808.             if(PTruck > 0)
  809.             {
  810.                 TogglePlayerControllable(playerid, 0);
  811.                 new string[128];
  812.                 format(string, sizeof(string), "With this truck you can play Truckmission #%d", PTruck);
  813.                 SendClientMessage(playerid, COLOR_ORANGE, string);
  814.                 SendClientMessage(playerid, COLOR_ORANGE, "Typ /startmission or else /exit");
  815.             }
  816.         }
  817.     }
  818.     return 1;
  819. }
  820.  
  821. forward ExitedTruck(playerid, ID);
  822. public ExitedTruck(playerid, ID)
  823. {
  824.     if(!IsPlayerInVehicle(playerid, Truck[ID]))
  825.     {
  826.         GameTextForPlayer(playerid, "~r~Loser", 5000, 3);
  827.         TruckmissionPlaying[playerid] = 0;
  828.         MissionInfo[ID][IsGettingPlayed] = 0;
  829.         MissionInfo[ID][TickcountBeforeStart] = 0;
  830.         DisablePlayerCheckpoint(playerid);
  831.         SendClientMessage(playerid, COLOR_RED, "You failed the Truckmission!");
  832.         SetVehicleToRespawn(Truck[ID]);
  833.         KillTimer(MissionInfo[ID][Timer]);
  834.         if(MissionInfo[ID][UseTrailer] == 1)
  835.         {
  836.             DestroyVehicle(Trailer[ID]);
  837.         }
  838.     }
  839. }
  840.        
  841.  
  842. public OnPlayerEnterCheckpoint(playerid)
  843. {
  844.     if(TruckmissionPlaying[playerid] > 0 && IsPlayerInVehicle(playerid, Truck[TruckmissionPlaying[playerid]]))
  845.     {
  846.         new ID = TruckmissionPlaying[playerid];
  847.         if(MissionInfo[ID][UseTrailer] == 1)
  848.         {
  849.             if(!IsTrailerAttachedToVehicle(Truck[ID])) return SendClientMessage(playerid, COLOR_RED, "You lost your trailer!");
  850.             DestroyVehicle(Trailer[ID]);
  851.         }
  852.         KillTimer(MissionInfo[ID][Timer]);
  853.         RemovePlayerFromVehicle(playerid);
  854.         SetVehicleToRespawn(Truck[ID]);
  855.         new TotalTime = ((GetTickCount() - MissionInfo[ID][TickcountBeforeStart])/1000);
  856.         new string[128];
  857.         DisablePlayerCheckpoint(playerid);
  858.         TruckmissionPlaying[playerid] = 0;
  859.         MissionInfo[ID][IsGettingPlayed] = 0;
  860.         format(string, sizeof(string), "You completed Truckmission #%d!!! You won $%d!!!", ID, MissionInfo[ID][Prize]);
  861.         SendClientMessage(playerid, COLOR_YELLOW, string);
  862.         GameTextForPlayer(playerid, "~g~Winner!", 8000, 3);
  863.         PlayerPlaySound(playerid, 1185, 0, 0, 0);
  864.         GivePlayerMoney(playerid, MissionInfo[ID][Prize]);
  865.         SetTimerEx("StopSound", 8000, 3, "i", playerid);
  866.         format(string, sizeof(string), "It took you %d seconds!", TotalTime);
  867.         SendClientMessage(playerid, COLOR_YELLOW, string);
  868.         if(TotalTime < MissionInfo[ID][Highscore])
  869.         {
  870.             new Pname[MAX_PLAYER_NAME];
  871.             GetPlayerName(playerid, Pname, sizeof(Pname));
  872.             format(string, sizeof(string), "%s has broken the recond of Truckmission #%d! New Highscore: %d seconds", Pname, ID, TotalTime);
  873.             SendClientMessageToAll(COLOR_YELLOW, string);
  874.             MissionInfo[ID][Highscore] = TotalTime;
  875.             format(MissionInfo[ID][HighscoreName], MAX_PLAYER_NAME, "%s", Pname);
  876.         }
  877.     }
  878.     return 1;
  879. }
  880.  
  881.  
  882. public OnPlayerSelectedMenuRow(playerid, row)
  883. {
  884.     new Menu:Current = GetPlayerMenu(playerid);
  885.     if(Current == SettingsMenu1)
  886.     {
  887.         switch(row)
  888.         {
  889.             case 0: {GameTextForPlayer(playerid, "~y~Typ the new name ~n~in the chat~", 999999, 3); SpecialAction[playerid] = CHANGE_NAME;}
  890.             case 1: {GameTextForPlayer(playerid, "~y~Are you sure you want this location as new startposition? ~n~~g~/yes ~y~or ~r~/no", 999999, 3); Question = 1;}
  891.             case 2: {GameTextForPlayer(playerid, "~y~Are you sure you want this location as new finishposition? ~n~~g~/yes ~y~or ~r~/no", 999999, 3); Question = 2;}
  892.             case 3: {GameTextForPlayer(playerid, "~y~Typ the new Checkpointsize ~n~in the chat~", 999999, 3); SpecialAction[playerid] = CHANGE_CPSIZE;}
  893.             case 4: {GameTextForPlayer(playerid, "~y~Typ the new Prize ~n~in the chat~", 999999, 3); SpecialAction[playerid] = CHANGE_PRIZE;}
  894.             case 5: {GameTextForPlayer(playerid, "~y~Typ the new model-id ~n~in the chat~", 999999, 3); SpecialAction[playerid] = CHANGE_MODEL;}
  895.             case 6: {GameTextForPlayer(playerid, "~y~Highscores resetted!", 3000, 4); MissionInfo[EditMissionID][Highscore] = 999999; format(MissionInfo[EditMissionID][HighscoreName], 24, "Nobody"); ShowMenuForPlayer(SettingsMenu1, playerid);}
  896.             case 7: {GetMissionInfo(playerid, EditMissionID); ShowMenuForPlayer(SettingsMenu1, playerid);}
  897.             case 8:
  898.             {
  899.                 new id = EditMissionID;
  900.                 DestroyVehicle(Truck[id]);
  901.                 Truck[id] = CreateVehicle(MissionInfo[id][TruckModel], MissionInfo[id][StartX], MissionInfo[id][StartY], MissionInfo[id][StartZ], MissionInfo[id][StartAngle], MissionInfo[id][TruckColor1],MissionInfo[id][TruckColor2], 600000);
  902.                 ShowMenuForPlayer(SettingsMenu1, playerid);
  903.             }
  904.             case 9: {ShowMenuForPlayer(SettingsMenu2, playerid);}
  905.         }
  906.     }
  907.     if(Current == SettingsMenu2)
  908.     {
  909.         switch(row)
  910.         {
  911.             case 0: {ShowMenuForPlayer(UseTrailerMenu, playerid);}
  912.             case 1: {GameTextForPlayer(playerid, "~y~Typ the new model-id ~n~in the chat~", 999999, 3); SpecialAction[playerid] = CHANGE_TRAILER;}
  913.             case 2: {ShowMenuForPlayer(ColorMenu, playerid); }
  914.             case 3: {GameTextForPlayer(playerid, "~y~Typ the new time-limit ~n~(in seconds!) ~n~in the chat~", 999999, 3); SpecialAction[playerid] = CHANGE_TIMELIMIT;}
  915.             case 4: {ShowMenuForPlayer(SettingsMenu1, playerid);}
  916.         }
  917.     }
  918.     if(Current == UseTrailerMenu)
  919.     {
  920.         switch(row)
  921.         {
  922.             case 0: {ShowMenuForPlayer(SettingsMenu2, playerid); MissionInfo[EditMissionID][UseTrailer] = 1; SendClientMessage(playerid, COLOR_YELLOW, "Using a trailer is now enabled for this mission!");}
  923.             case 1: {ShowMenuForPlayer(SettingsMenu2, playerid); MissionInfo[EditMissionID][UseTrailer] = 0; SendClientMessage(playerid, COLOR_YELLOW, "Using a trailer is now disabled for this mission!");}
  924.             case 2: {ShowMenuForPlayer(SettingsMenu2, playerid);}
  925.         }
  926.     }
  927.     if(Current == ColorMenu)
  928.     {
  929.         switch(row)
  930.         {
  931.             case 0: {GameTextForPlayer(playerid, "~y~Typ the new color-id ~n~in the chat~", 999999, 3); SpecialAction[playerid] = CHANGE_COLOR1;}
  932.             case 1: {GameTextForPlayer(playerid, "~y~Typ the new color-id ~n~in the chat~", 999999, 3); SpecialAction[playerid] = CHANGE_COLOR2;}
  933.             case 2:
  934.             {
  935.                 SendClientMessage(playerid, COLOR_MENUHEADER, "=====Common CarColors:============");
  936.                 SendClientMessage(playerid, COLOR_MENU, "Black = 0 ** White = 1 ** LightBlue = 2  ** Red = 3");
  937.                 SendClientMessage(playerid, COLOR_MENU, "Yellow = 6 ** Green = 86 ** LightGrey = 15 ** Purple = 5");
  938.                 SendClientMessage(playerid, COLOR_MENU, "DarkBlue = 79 ** DarkGrey = 13 ** LightBrown = 102");
  939.                 SendClientMessage(playerid, COLOR_MENU, "DarkBrown = 30 ** Pink = 126 ** RandomColor = -1");
  940.                 ShowMenuForPlayer(ColorMenu, playerid);
  941.             }
  942.             case 3: {ShowMenuForPlayer(SettingsMenu2, playerid);}
  943.         }
  944.     }
  945.     return 1;
  946. }
  947.  
  948. public OnPlayerExitedMenu(playerid)
  949. {
  950.     TogglePlayerControllable(playerid, 1);
  951.     return 1;
  952. }
  953.  
  954. stock CreateNewFile(id)
  955. {
  956.     format(FileName, sizeof(FileName), MissionFile, id);
  957.     new name[50];
  958.     format(name, sizeof(name), "Race #%d", id);
  959.     dini_Create(FileName);
  960.     dini_Set(FileName, "Name", name);
  961.     dini_FloatSet(FileName, "StartX", 0.0);
  962.     dini_FloatSet(FileName, "StartY", 0.0);
  963.     dini_FloatSet(FileName, "StartZ", 0.0);
  964.     dini_FloatSet(FileName, "StartAngle", 0.0);
  965.     dini_FloatSet(FileName, "EndX", 0.0);
  966.     dini_FloatSet(FileName, "EndY", 0.0);
  967.     dini_FloatSet(FileName, "EndZ", 0.0);
  968.     dini_IntSet(FileName, "CpSize", DefaultCheckpointSize);
  969.     dini_IntSet(FileName, "TruckModel", DefaultTruckModel);
  970.     dini_IntSet(FileName, "TruckColor1", -1);
  971.     dini_IntSet(FileName, "TruckColor2", -1);
  972.     dini_IntSet(FileName, "UseTrailer", 0);
  973.     dini_IntSet(FileName, "TrailerModel", DefaultTrailerModel);
  974.     dini_IntSet(FileName, "Prize", DefaultPrize);
  975.     dini_IntSet(FileName, "TimeLimit", 0);
  976.     dini_IntSet(FileName, "Highscore", 9999999);
  977.     dini_Set(FileName, "HighscoreName", "Nobody");
  978.     ReadFile(id);
  979. }
  980.  
  981. stock ReadFile(id)
  982. {
  983.     format(FileName, sizeof(FileName), MissionFile, id);
  984.     format(MissionInfo[id][Name], 50, "%s", dini_Get(FileName, "Name"));
  985.     MissionInfo[id][StartX] = dini_Float(FileName, "StartX");
  986.     MissionInfo[id][StartY] = dini_Float(FileName, "StartY");
  987.     MissionInfo[id][StartZ] = dini_Float(FileName, "StartZ");
  988.     MissionInfo[id][StartAngle] = dini_Float(FileName, "StartAngle");
  989.     MissionInfo[id][EndX] = dini_Float(FileName, "EndX");
  990.     MissionInfo[id][EndY] = dini_Float(FileName, "EndY");
  991.     MissionInfo[id][EndZ] = dini_Float(FileName, "EndZ");
  992.     MissionInfo[id][CpSize] = dini_Int(FileName, "CpSize");
  993.     MissionInfo[id][Prize] = dini_Int(FileName, "Prize");
  994.     MissionInfo[id][TimeLimit] = dini_Int(FileName, "TimeLimit");
  995.     MissionInfo[id][TruckModel] = dini_Int(FileName, "TruckModel");
  996.     MissionInfo[id][TruckColor1] = dini_Int(FileName, "TruckColor1");
  997.     MissionInfo[id][TruckColor2] = dini_Int(FileName, "TruckColor2");
  998.     MissionInfo[id][UseTrailer] = dini_Int(FileName, "UseTrailer");
  999.     MissionInfo[id][TrailerModel] = dini_Int(FileName, "TrailerModel");
  1000.     MissionInfo[id][Highscore] = dini_Int(FileName, "Highscore");
  1001.     format(MissionInfo[id][HighscoreName], MAX_PLAYER_NAME, "%s", dini_Get(FileName, "HighscoreName"));
  1002.     Truck[id] = CreateVehicle(MissionInfo[id][TruckModel], MissionInfo[id][StartX], MissionInfo[id][StartY], MissionInfo[id][StartZ], MissionInfo[id][StartAngle], MissionInfo[id][TruckColor1],MissionInfo[id][TruckColor2], 600000);
  1003. }
  1004.  
  1005. SaveFiles()
  1006. {
  1007.     for(new id=1; id<MAX_MISSIONS; id++)
  1008.     {
  1009.         if(MissionInfo[id][DoesExists] == 1)
  1010.         {
  1011.             format(FileName, sizeof(FileName), MissionFile, id);
  1012.             dini_Set(FileName, "Name", MissionInfo[id][Name]);
  1013.             dini_FloatSet(FileName, "StartX", MissionInfo[id][StartX]);
  1014.             dini_FloatSet(FileName, "StartY", MissionInfo[id][StartY]);
  1015.             dini_FloatSet(FileName, "StartZ", MissionInfo[id][StartZ]);
  1016.             dini_FloatSet(FileName, "StartAngle", MissionInfo[id][StartAngle]);
  1017.             dini_FloatSet(FileName, "EndX", MissionInfo[id][EndX]);
  1018.             dini_FloatSet(FileName, "EndY", MissionInfo[id][EndY]);
  1019.             dini_FloatSet(FileName, "EndZ", MissionInfo[id][EndZ]);
  1020.             dini_IntSet(FileName, "CpSize", MissionInfo[id][CpSize]);
  1021.             dini_IntSet(FileName, "TruckModel", MissionInfo[id][TruckModel]);
  1022.             dini_IntSet(FileName, "TruckColor1", MissionInfo[id][TruckColor1]);
  1023.             dini_IntSet(FileName, "TruckColor2", MissionInfo[id][TruckColor2]);
  1024.             dini_IntSet(FileName, "UseTrailer", MissionInfo[id][UseTrailer]);
  1025.             dini_IntSet(FileName, "TrailerModel", MissionInfo[id][TrailerModel]);
  1026.             dini_IntSet(FileName, "Prize", MissionInfo[id][Prize]);
  1027.             dini_IntSet(FileName, "TimeLimit", MissionInfo[id][TimeLimit]);
  1028.             dini_IntSet(FileName, "Highscore", MissionInfo[id][Highscore]);
  1029.             dini_Set(FileName, "HighscoreName", MissionInfo[id][HighscoreName]);
  1030.         }
  1031.     }
  1032. }
  1033.  
  1034. GetMissionInfo(playerid, ID)
  1035. {
  1036.     new string[128];
  1037.     format(string, sizeof(string), "Truckmission #%d:  \"%s\"", ID, MissionInfo[ID][Name]);
  1038.     SendClientMessage(playerid, COLOR_MENUHEADER, string);
  1039.     format(string, sizeof(string), "StartPosition: X:%.2f, Y:%.2f, Z:%.2f  Angle:%.2f ", MissionInfo[ID][StartX], MissionInfo[ID][StartY], MissionInfo[ID][StartZ], MissionInfo[ID][StartAngle]);
  1040.     SendClientMessage(playerid, COLOR_MENU, string);
  1041.     format(string, sizeof(string), "FinishPosition: X:%.2f, Y:%.2f, Z:%.2f", MissionInfo[ID][EndX], MissionInfo[ID][EndY], MissionInfo[ID][EndZ]);
  1042.     SendClientMessage(playerid, COLOR_MENU, string);
  1043.     format(string, sizeof(string), "CheckpointSize: %d,  Prize: $%d", MissionInfo[ID][CpSize], MissionInfo[ID][Prize]);
  1044.     SendClientMessage(playerid, COLOR_MENU, string);
  1045.     format(string, sizeof(string), "TruckModel: %d  (%s), TruckColor1: %d, TruckColor2: %d", MissionInfo[ID][TruckModel], VehNames[(MissionInfo[ID][TruckModel]-400)], MissionInfo[ID][TruckColor1], MissionInfo[ID][TruckColor2]);
  1046.     SendClientMessage(playerid, COLOR_MENU, string);
  1047.     format(string, sizeof(string), "Use Trailer: %d,  TrailerModel: %d,  TimeLimit: %d seconds", MissionInfo[ID][UseTrailer], MissionInfo[ID][TrailerModel], MissionInfo[ID][TimeLimit]);
  1048.     SendClientMessage(playerid, COLOR_MENU, string);
  1049.     format(string, sizeof(string), "Highscore: %d seconds,  Highscore by: \"%s\"", MissionInfo[ID][Highscore], MissionInfo[ID][HighscoreName]);
  1050.     SendClientMessage(playerid, COLOR_MENU, string);
  1051. }
  1052.  
  1053. IsNumeric(const string[])
  1054. {
  1055.     for (new i = 0, j = strlen(string); i < j; i++)
  1056.     {
  1057.         if (string[i] > '9' || string[i] < '0') return 0;
  1058.     }
  1059.     return 1;
  1060. }
  1061.  
  1062.  
  1063. forward StopSound(playerid);
  1064. public StopSound(playerid)
  1065. {
  1066.     PlayerPlaySound(playerid, 1186, 0, 0, 0);
  1067. }
  1068.  
  1069. IsUsableTruck(model)
  1070. {
  1071.     switch(model)
  1072.     {
  1073.         case 403, 514, 515: { return 1; }
  1074.     }
  1075.     return 0;
  1076. }
  1077.  
  1078. IsUsableTrailer(model)
  1079. {
  1080.     switch(model)
  1081.     {
  1082.         case 435, 450, 591, 584: { return 1; }
  1083.     }
  1084.     return 0;
  1085. }
  1086.  
  1087. stock IsMissionReady(ID)
  1088. {
  1089.     if(MissionInfo[ID][StartX] == 0.0 && MissionInfo[ID][StartY] == 0 && MissionInfo[ID][StartZ] == 0)
  1090.     {
  1091.         return 0;
  1092.     }
  1093.     if(MissionInfo[ID][EndX] == 0.0 && MissionInfo[ID][EndY] == 0.0 && MissionInfo[ID][EndZ] == 0.0)
  1094.     {
  1095.         return 0;
  1096.     }
  1097.     if(MissionInfo[ID][TruckModel] == 0 || (MissionInfo[ID][UseTrailer] == 1 && MissionInfo[ID][TrailerModel] == 0) || MissionInfo[ID][CpSize] == 0)
  1098.     {
  1099.         return 0;
  1100.     }
  1101.     return 1;
  1102. }
  1103.  
  1104. forward MissionTimer(playerid, MissionID);
  1105. public MissionTimer(playerid, MissionID)
  1106. {
  1107.     GameTextForPlayer(playerid, "~r~Time is up", 5000, 3);
  1108.     TruckmissionPlaying[playerid] = 0;
  1109.     MissionInfo[MissionID][IsGettingPlayed] = 0;
  1110.     MissionInfo[MissionID][TickcountBeforeStart] = 0;
  1111.     DisablePlayerCheckpoint(playerid);
  1112.     SendClientMessage(playerid, COLOR_RED, "You failed the Truckmission!");
  1113.     SetVehicleToRespawn(Truck[MissionID]);
  1114.     if(MissionInfo[MissionID][UseTrailer] == 1)
  1115.     {
  1116.         DestroyVehicle(Trailer[MissionID]);
  1117.     }
  1118. }
Advertisement
Add Comment
Please, Sign In to add comment