NewbProgramming

Grand Larceny

Jul 23rd, 2017
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 38.00 KB | None | 0 0
  1. using SampSharp.GameMode;
  2. using SampSharp.GameMode.Controllers;
  3. using SampSharp.GameMode.Definitions;
  4. using SampSharp.GameMode.SAMP;
  5. using SampSharp.GameMode.World;
  6. using System;
  7. using System.IO;
  8. using SampSharp.GameMode.Events;
  9. using SampSharp.GameMode.Display;
  10.  
  11. namespace GrandLarceny
  12. {
  13.     public class GameMode : BaseMode
  14.     {
  15.         // DEFINES
  16.         readonly Color COLOR_NORMAL_PLAYER = Color.FromInteger(0xFFBB7777, ColorFormat.RGBA);
  17.  
  18.         // SPAWNS
  19.         // Police dept spawns LS/SF/LV.
  20.         readonly SpawnPoint[] policeSpawns = new[] {
  21.             new SpawnPoint(1568.2250,-1693.5483,5.8906,177.0983),
  22.             new SpawnPoint(-1604.8442,732.9442,-5.2344,37.6041),
  23.             new SpawnPoint(2343.4553,2455.5994,14.9688,96.5022)
  24.         };
  25.  
  26.         // Medical dept spawns LS/SF/LV.
  27.         readonly SpawnPoint[] medicalSpawns = new[] {
  28.             new SpawnPoint(1568.2250,-1693.5483,5.8906,177.0983),
  29.             new SpawnPoint(-1604.8442,732.9442,-5.2344,37.6041),
  30.             new SpawnPoint(1609.5922,1820.9641,10.8280,348.1614)
  31.         };
  32.  
  33.         // Army spawns LS/SF/LV.
  34.         readonly SpawnPoint[] armySpawns = new[] {
  35.             new SpawnPoint(2786.2183,-2436.7859,13.6340,82.3043),
  36.             new SpawnPoint(-1308.4493,504.9661,11.1953,132.5),
  37.             new SpawnPoint(272.6040,1989.7307,17.6406,268.3605)
  38.         };
  39.  
  40.         readonly SpawnPoint[] lossantosSpawns = new[] {
  41.             new SpawnPoint(1751.1097,-2106.4529,13.5469,183.1979), // El-Corona - Outside random house
  42.             new SpawnPoint(2652.6418,-1989.9175,13.9988,182.7107), // Random house in willowfield - near playa de seville and stadium
  43.             new SpawnPoint(2489.5225,-1957.9258,13.5881,2.3440), // Hotel in willowfield - near cluckin bell
  44.             new SpawnPoint(2689.5203,-1695.9354,10.0517,39.5312), // Outside stadium - lots of cars
  45.             new SpawnPoint(2770.5393,-1628.3069,12.1775,4.9637), // South in east beach - north of stadium - carparks nearby
  46.             new SpawnPoint(2807.9282,-1176.8883,25.3805,173.6018), // North in east beach - near apartments
  47.             new SpawnPoint(2552.5417,-958.0850,82.6345,280.2542), // Random house north of Las Colinas
  48.             new SpawnPoint(2232.1309,-1159.5679,25.8906,103.2939), // Jefferson motel
  49.             new SpawnPoint(2388.1003,-1279.8933,25.1291,94.3321), // House south of pig pen
  50.             new SpawnPoint(2481.1885,-1536.7186,24.1467,273.4944), // East LS - near clucking bell and car wash
  51.             new SpawnPoint(2495.0720,-1687.5278,13.5150,359.6696), // Outside CJ's house - lots of cars nearby
  52.             new SpawnPoint(2306.8252,-1675.4340,13.9221,2.6271), // House in ganton - lots of cars nearby
  53.             new SpawnPoint(2191.8403,-1455.8251,25.5391,267.9925), // House in south jefferson - lots of cars nearby
  54.             new SpawnPoint(1830.1359,-1092.1849,23.8656,94.0113), // Mulholland intersection carpark
  55.             new SpawnPoint(2015.3630,-1717.2535,13.5547,93.3655), // Idlewood house
  56.             new SpawnPoint(1654.7091,-1656.8516,22.5156,177.9729), // Right next to PD
  57.             new SpawnPoint(1219.0851,-1812.8058,16.5938,190.0045), // Conference Center
  58.             new SpawnPoint(1508.6849,-1059.0846,25.0625,1.8058), // Across the street of BANK - lots of cars in intersection carpark
  59.             new SpawnPoint(1421.0819,-885.3383,50.6531,3.6516), // Outside house in vinewood
  60.             new SpawnPoint(1133.8237,-1272.1558,13.5469,192.4113), // Near hospital
  61.             new SpawnPoint(1235.2196,-1608.6111,13.5469,181.2655), // Backalley west of mainstreet
  62.             new SpawnPoint(590.4648,-1252.2269,18.2116,25.0473), // Outside "BAnk of San Andreas"
  63.             new SpawnPoint(842.5260,-1007.7679,28.4185,213.9953), // North of Graveyard
  64.             new SpawnPoint(911.9332,-1232.6490,16.9766,5.2999), // LS Film Studio
  65.             new SpawnPoint(477.6021,-1496.6207,20.4345,266.9252), // Rodeo Place
  66.             new SpawnPoint(255.4621,-1366.3256,53.1094,312.0852), // Outside propery in richman
  67.             new SpawnPoint(281.5446,-1261.4562,73.9319,305.0017), // Another richman property
  68.             new SpawnPoint(790.1918,-839.8533,60.6328,191.9514), // Mulholland house
  69.             new SpawnPoint(1299.1859,-801.4249,84.1406,269.5274), // Maddoggs
  70.             new SpawnPoint(1240.3170,-2036.6886,59.9575,276.4659), // Verdant Bluffs
  71.             new SpawnPoint(2215.5181,-2627.8174,13.5469,273.7786), // Ocean docks 1
  72.             new SpawnPoint(2509.4346,-2637.6543,13.6453,358.3565) // Ocean Docks spawn 2
  73.         };
  74.        
  75.         readonly SpawnPoint[] sanfierroSpawns = new[] {
  76.             new SpawnPoint(-2723.4639,-314.8138,7.1839,43.5562), // golf course spawn
  77.             new SpawnPoint(-2694.5344,64.5550,4.3359,95.0190), // in front of a house
  78.             new SpawnPoint(-2458.2000,134.5419,35.1719,303.9446), // hotel
  79.             new SpawnPoint(-2796.6589,219.5733,7.1875,88.8288), // house
  80.             new SpawnPoint(-2706.5261,397.7129,4.3672,179.8611), // park
  81.             new SpawnPoint(-2866.7683,691.9363,23.4989,286.3060), // house
  82.             new SpawnPoint(-2764.9543,785.6434,52.7813,357.6817), // donut shop
  83.             new SpawnPoint(-2660.9402,883.2115,79.7738,357.4440), // house
  84.             new SpawnPoint(-2861.0796,1047.7109,33.6068,188.2750), //  parking lot
  85.             new SpawnPoint(-2629.2009,1383.1367,7.1833,179.7006), // parking lot at the bridge
  86.             new SpawnPoint(-2079.6802,1430.0189,7.1016,177.6486), // pier
  87.             new SpawnPoint(-1660.2294,1382.6698,9.8047,136.2952), //  pier 69
  88.             new SpawnPoint(-1674.1964,430.3246,7.1797,226.1357), // gas station]
  89.             new SpawnPoint(-1954.9982,141.8080,27.1747,277.7342), // train station
  90.             new SpawnPoint(-1956.1447,287.1091,35.4688,90.4465), // car shop
  91.             new SpawnPoint(-1888.1117,615.7245,35.1719,128.4498), // random
  92.             new SpawnPoint(-1922.5566,886.8939,35.3359,272.1293), // random
  93.             new SpawnPoint(-1983.3458,1117.0645,53.1243,271.2390), // church
  94.             new SpawnPoint(-2417.6458,970.1491,45.2969,269.3676), // gas station
  95.             new SpawnPoint(-2108.0171,902.8030,76.5792,5.7139), // house
  96.             new SpawnPoint(-2097.5664,658.0771,52.3672,270.4487), // random
  97.             new SpawnPoint(-2263.6650,393.7423,34.7708,136.4152), // random
  98.             new SpawnPoint(-2287.5027,149.1875,35.3125,266.3989), // baseball parking lot
  99.             new SpawnPoint(-2039.3571,-97.7205,35.1641,7.4744), // driving school
  100.             new SpawnPoint(-1867.5022,-141.9203,11.8984,22.4499), // factory
  101.             new SpawnPoint(-1537.8992,116.0441,17.3226,120.8537), // docks ship
  102.             new SpawnPoint(-1708.4763,7.0187,3.5489,319.3260), // docks hangar
  103.             new SpawnPoint(-1427.0858,-288.9430,14.1484,137.0812), // airport
  104.             new SpawnPoint(-2173.0654,-392.7444,35.3359,237.0159), // stadium
  105.             new SpawnPoint(-2320.5286,-180.3870,35.3135,179.6980), // burger shot
  106.             new SpawnPoint(-2930.0049,487.2518,4.9141,3.8258)  // harbor
  107.         };
  108.        
  109.         readonly SpawnPoint[] lasventurasSpawns = new[] {
  110.             new SpawnPoint(1435.8024,2662.3647,11.3926,1.1650), //  Northern train station
  111.             new SpawnPoint(1457.4762,2773.4868,10.8203,272.2754), //  Northern golf club
  112.             new SpawnPoint(1739.6390,2803.0569,14.2735,285.3929), //  Northern housing estate 1
  113.             new SpawnPoint(1870.3096,2785.2471,14.2734,42.3102), //  Northern housing estate 2
  114.             new SpawnPoint(1959.7142,2754.6863,10.8203,181.4731), //  Northern house 1
  115.             new SpawnPoint(2314.2556,2759.4504,10.8203,93.2711), //  Northern industrial estate 1
  116.             new SpawnPoint(2216.5674,2715.0334,10.8130,267.6540), //  Northern industrial estate 2
  117.             new SpawnPoint(2101.4192,2678.7874,10.8130,92.0607), //  Northern near railway line
  118.             new SpawnPoint(1951.1090,2660.3877,10.8203,180.8461), //  Northern house 2
  119.             new SpawnPoint(1666.6949,2604.9861,10.8203,179.8495), //  Northern house 3
  120.             new SpawnPoint(2808.3367,2421.5107,11.0625,136.2060), //  Northern shopping centre
  121.             new SpawnPoint(2633.3203,2349.7061,10.6719,178.7175), //  V-Rock
  122.             new SpawnPoint(2606.6348,2161.7490,10.8203,88.7508), //  South V-Rock
  123.             new SpawnPoint(2616.5286,2100.6226,10.8158,177.7834), //  North Ammunation 1
  124.             new SpawnPoint(2491.8816,2397.9370,10.8203,266.6003), //  North carpark 1
  125.             new SpawnPoint(2531.7891,2530.3223,21.8750,91.6686), //  North carpark 2
  126.             new SpawnPoint(2340.6677,2530.4324,10.8203,177.8630), //  North Pizza Stack
  127.             new SpawnPoint(2097.6855,2491.3313,14.8390,181.8117), //  Emerald Isle
  128.             new SpawnPoint(1893.1000,2423.2412,11.1782,269.4385), //  Souvenir shop
  129.             new SpawnPoint(1698.9330,2241.8320,10.8203,357.8584), //  Northern casino
  130.             new SpawnPoint(1479.4559,2249.0769,11.0234,306.3790), //  Baseball stadium 1
  131.             new SpawnPoint(1298.1548,2083.4016,10.8127,256.7034), //  Baseball stadium 2
  132.             new SpawnPoint(1117.8785,2304.1514,10.8203,81.5490), //  North carparks
  133.             new SpawnPoint(1108.9878,1705.8639,10.8203,0.6785), //  Dirtring racing 1
  134.             new SpawnPoint(1423.9780,1034.4188,10.8203,90.9590), //  Sumo
  135.             new SpawnPoint(1537.4377,752.0641,11.0234,271.6893), //  Church
  136.             new SpawnPoint(1917.9590,702.6984,11.1328,359.2682), //  Southern housing estate
  137.             new SpawnPoint(2089.4785,658.0414,11.2707,357.3572), //  Southern house 1
  138.             new SpawnPoint(2489.8286,928.3251,10.8280,67.2245), //  Wedding chapel
  139.             new SpawnPoint(2697.4717,856.4916,9.8360,267.0983), //  Southern construction site
  140.             new SpawnPoint(2845.6104,1288.1444,11.3906,3.6506), //  Southern train station
  141.             new SpawnPoint(2437.9370,1293.1442,10.8203,86.3830), //  Wedding chapel (near Pyramid)
  142.             new SpawnPoint(2299.5430,1451.4177,10.8203,269.1287), //  Carpark (near Pyramid)
  143.             new SpawnPoint(2214.3008,2041.9165,10.8203,268.7626), //  Central parking lot
  144.             new SpawnPoint(2005.9174,2152.0835,10.8203,270.1372), //  Central motel
  145.             new SpawnPoint(2222.1042,1837.4220,10.8203,88.6461), //  Clowns Pocket
  146.             new SpawnPoint(2025.6753,1916.4363,12.3382,272.5852), //  The Visage
  147.             new SpawnPoint(2087.9902,1516.5336,10.8203,48.9300), //  Royal Casino
  148.             new SpawnPoint(2172.1624,1398.7496,11.0625,91.3783), //  Auto Bahn
  149.             new SpawnPoint(2139.1841,987.7975,10.8203,0.2315), //  Come-a-lot
  150.             new SpawnPoint(1860.9672,1030.2910,10.8203,271.6988), //  Behind 4 Dragons
  151.             new SpawnPoint(1673.2345,1316.1067,10.8203,177.7294), //  Airport carpark
  152.             new SpawnPoint(1412.6187,2000.0596,14.7396,271.3568) //  South baseball stadium houses
  153.         };
  154.  
  155.         TextDraw lossantosTD = null;
  156.         TextDraw sanfierroTD = null;
  157.         TextDraw lasventurasTD = null;
  158.         TextDraw classSelectionTD = null;
  159.  
  160.         int LoadStaticVehiclesFromFile(string fileName)
  161.         {
  162.             FileInfo file = new FileInfo(fileName);
  163.  
  164.             if(file.Exists == false)
  165.             {
  166.                 return 0;
  167.             }
  168.  
  169.             string[] lines = File.ReadAllLines(file.FullName);
  170.             int lineIdx = -1;
  171.             int vehicleCount = 0;
  172.             VehicleModelType model = 0;
  173.             Vector3 position = Vector3.Zero;
  174.             float angle = 0.0f;
  175.             int primaryColour = -1, secondaryColour = -1;
  176.             string description = string.Empty;
  177.  
  178.             foreach(string line in lines)
  179.             {
  180.                 lineIdx++;
  181.                 string[] token = line.Split(new[] { ' ', '\t', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
  182.  
  183.                 if(token.Length < 7) // model, x, y, z, angle, color1, color2 are required.
  184.                 {
  185.                     Console.WriteLine("FAILED to parse vehicle: not enough arguments (7) or invalid format. ('{0}':{1})", file.Name, lineIdx);
  186.                     continue;
  187.                 }
  188.  
  189.                 if(int.TryParse(token[0], out int modelId) == false)
  190.                 {
  191.                     Console.WriteLine("FAILED to parse vehicle: modelId (0) must be integer. ('{0}':{1})", file.Name, lineIdx);
  192.                     continue;
  193.                 }
  194.  
  195.                 model = (VehicleModelType) modelId;
  196.  
  197.                 if (float.TryParse(token[1], out float x) == false || float.TryParse(token[2], out float y) == false || float.TryParse(token[3], out float z) == false)
  198.                 {
  199.                     Console.WriteLine("FAILED to parse vehicle: x,y,z (1,2,3) must be float. ('{0}':{1})", file.Name, lineIdx);
  200.                     continue;
  201.                 }
  202.  
  203.                 position = new Vector3(x, y, z);
  204.  
  205.                 if(float.TryParse(token[4], out angle) == false)
  206.                 {
  207.                     Console.WriteLine("FAILED to parse vehicle: angle (4) must be float. ('{0}':{1})", file.Name, lineIdx);
  208.                     continue;
  209.                 }
  210.  
  211.                 if(int.TryParse(token[5], out primaryColour) == false || int.TryParse(token[6], out secondaryColour) == false)
  212.                 {
  213.                     Console.WriteLine("FAILED to parse vehicle: primaryColour,secondaryColour (5,6) must be float. ('{0}':{1})", file.Name, lineIdx);
  214.                     continue;
  215.                 }
  216.  
  217.                 if(token.Length > 7)
  218.                 {
  219.                     description = String.Join(" ", token, 7, (token.Length - 7));
  220.                 }
  221.                
  222.                 BaseVehicle vehicle = BaseVehicle.CreateStatic(model, position, angle, primaryColour, secondaryColour, (60 * 30)); // 30 minute respawn.
  223.  
  224.                 if(vehicle == null)
  225.                 {
  226.                     Console.WriteLine("FAILED to create vehicle: there may be too many on the server. ({0}/{1})", BaseVehicle.PoolSize, BaseVehicle.Max);
  227.                     continue;
  228.                 }
  229.  
  230.                 vehicle.SetNumberPlate("GRLC{44AA33}" + vehicle.Id);
  231.  
  232.                 vehicleCount++;
  233.  
  234.                 // Console.WriteLine("{0} = AddStaticVehicleEx({1}, {2}, {3}, {4}, {5}, {6}, {7}, (60 * 30)); // {8}", vehicle.Id, model, position.X, position.Y, position.Z, angle, primaryColour, secondaryColour, description);
  235.             }
  236.             return vehicleCount;
  237.         }
  238.  
  239.         protected override void OnPlayerConnected(BasePlayer sender, EventArgs e)
  240.         {
  241.             Player player = sender as Player;
  242.  
  243.             player.GameText("~w~Grand Larceny", 3000, 4);
  244.             player.SendClientMessage("Welcome to {88AA88}G{FFFFFF}rand {88AA88}L{FFFFFF}arceny");
  245.             player.Color = COLOR_NORMAL_PLAYER;
  246.  
  247.             /*
  248.             GlobalObject.Remove(player, 1302, Vector3.Zero, 6000.0f);
  249.             GlobalObject.Remove(player, 1209, Vector3.Zero, 6000.0f);
  250.             GlobalObject.Remove(player, 955,  Vector3.Zero, 6000.0f);
  251.             GlobalObject.Remove(player, 1775, Vector3.Zero, 6000.0f);
  252.             GlobalObject.Remove(player, 1776, Vector3.Zero, 6000.0f);
  253.             */
  254.  
  255.             Console.WriteLine("Player {0} reported client version '{1}'.", player.Id, player.Version);
  256.  
  257.             base.OnPlayerConnected(player, e);
  258.         }
  259.  
  260.         protected override void OnPlayerSpawned(BasePlayer sender, SpawnEventArgs e)
  261.         {
  262.             Player player = sender as Player;
  263.            
  264.             if (player.IsNPC == true)
  265.             {
  266.                 base.OnPlayerSpawned(player, e);
  267.                 return;
  268.             }
  269.            
  270.             player.Interior = 0;
  271.             player.ToggleClock(false);
  272.             player.ResetMoney();
  273.             player.Money += 30000;
  274.            
  275.             SpawnPoint spawn = new SpawnPoint(Vector3.Zero, 0.0f);
  276.  
  277.             if (player.citySelected == City.LosSantos)
  278.             {
  279.                 spawn = lossantosSpawns[new Random().Next(lossantosSpawns.Length)];
  280.             }
  281.             if (player.citySelected == City.SanFierro)
  282.             {
  283.                 spawn = sanfierroSpawns[new Random().Next(sanfierroSpawns.Length)];
  284.             }
  285.             if (player.citySelected == City.LasVenturas)
  286.             {
  287.                 spawn = lasventurasSpawns[new Random().Next(lasventurasSpawns.Length)];
  288.             }
  289.            
  290.             player.Position = spawn.position;
  291.             player.Angle = spawn.angle;
  292.             player.Color = COLOR_NORMAL_PLAYER;
  293.            
  294.             player.SetSkillLevel(WeaponSkill.Pistol, 200);
  295.             player.SetSkillLevel(WeaponSkill.PistolSilenced, 200);
  296.             player.SetSkillLevel(WeaponSkill.DesertEagle, 200);
  297.             player.SetSkillLevel(WeaponSkill.Shotgun, 200);
  298.             player.SetSkillLevel(WeaponSkill.SawnoffShotgun, 200);
  299.             player.SetSkillLevel(WeaponSkill.Spas12Shotgun, 200);
  300.             player.SetSkillLevel(WeaponSkill.MicroUzi, 200);
  301.             player.SetSkillLevel(WeaponSkill.MP5, 200);
  302.             player.SetSkillLevel(WeaponSkill.AK47, 200);
  303.             player.SetSkillLevel(WeaponSkill.M4, 200);
  304.             player.SetSkillLevel(WeaponSkill.SniperRifle, 200);
  305.            
  306.             player.GiveWeapon(Weapon.Colt45, 100);
  307.             player.GiveWeapon(Weapon.MP5, 100);
  308.  
  309.             player.ToggleClock(false);
  310.            
  311.             base.OnPlayerSpawned(player, e);
  312.         }
  313.  
  314.         protected override void OnPlayerDied(BasePlayer sender, DeathEventArgs e)
  315.         {
  316.             Player player = sender as Player;
  317.  
  318.             player.hasSelection = false;
  319.  
  320.             if(e.Killer != null)
  321.             {
  322.                 e.Killer.Money += player.Money;
  323.             }
  324.  
  325.             player.ResetMoney();
  326.  
  327.             base.OnPlayerDied(player, e);
  328.         }
  329.  
  330.         void SetupCharacterSelection(Player player)
  331.         {
  332.             if (player.citySelected == City.LosSantos)
  333.             {
  334.                 player.Interior = 11;
  335.                 player.Position = new Vector3(508.7362, -87.4335, 998.9609);
  336.                 player.Angle = 0.0f;
  337.                 player.CameraPosition = new Vector3(508.7362, -83.4335, 998.9609);
  338.                 player.SetCameraLookAt(new Vector3(508.7362, -87.4335, 998.9609));
  339.             }
  340.             if(player.citySelected == City.SanFierro)
  341.             {
  342.                 player.Interior = 3;
  343.                 player.Position = new Vector3(-2673.8381, 1399.7424, 918.3516);
  344.                 player.Angle = 181.0f;
  345.                 player.CameraPosition = new Vector3(-2673.2776, 1394.3859, 918.3516);
  346.                 player.SetCameraLookAt(new Vector3(-2673.8381, 1399.7424, 918.3516));
  347.             }
  348.             if(player.citySelected == City.LasVenturas)
  349.             {
  350.                 player.Interior = 3;
  351.                 player.Position = new Vector3(349.0453, 193.2271, 1014.1797);
  352.                 player.Angle = 286.25f;
  353.                 player.CameraPosition = new Vector3(352.9164, 194.5702, 1014.1875);
  354.                 player.SetCameraLookAt(new Vector3(349.0453, 193.2271, 1014.1797));
  355.             }
  356.         }
  357.  
  358.         TextDraw InitCityNameText(string name)
  359.         {
  360.             TextDraw textdraw = new TextDraw(new Vector2(10.0, 380.0), name);
  361.  
  362.             textdraw.UseBox = false;
  363.             textdraw.LetterSize = new Vector2(1.25, 3.0);
  364.             textdraw.Font = TextDrawFont.Diploma;
  365.             textdraw.Shadow = 0;
  366.             textdraw.Outline = 1;
  367.             textdraw.ForeColor = Color.FromInteger(0xEEEEEEFF, ColorFormat.RGBA);
  368.             textdraw.BackColor = Color.FromInteger(0x000000FF, ColorFormat.RGBA);
  369.             return textdraw;
  370.         }
  371.  
  372.         void InitTextDraws()
  373.         {
  374.             lossantosTD = InitCityNameText("Los Santos");
  375.             sanfierroTD = InitCityNameText("San Fierro");
  376.             lasventurasTD = InitCityNameText("Las Venturas");
  377.  
  378.             classSelectionTD = new TextDraw(new Vector2(10.0, 415.0),
  379.                 " Press ~b~~k~~GO_LEFT~ ~w~or ~b~~k~~GO_RIGHT~ ~w~to switch cities.~n~ Press ~r~~k~~PED_FIREWEAPON~ ~w~to select.");
  380.             classSelectionTD.UseBox = true;
  381.             classSelectionTD.BoxColor = Color.FromInteger(0x222222BB, ColorFormat.RGBA);
  382.             classSelectionTD.LetterSize = new Vector2(0.3, 1.0);
  383.             // classSelectionTD. = new Vector2(400.0, 40.0);
  384.             classSelectionTD.Font = TextDrawFont.Slim;
  385.             classSelectionTD.Shadow = 0;
  386.             classSelectionTD.Outline = 1;
  387.             classSelectionTD.BackColor = Color.FromInteger(0x000000FF, ColorFormat.RGBA);
  388.             classSelectionTD.ForeColor = Color.FromInteger(0xFFFFFFFF, ColorFormat.RGBA);
  389.         }
  390.  
  391.         void SetupSelectedCity(Player player)
  392.         {
  393.             if (player.citySelected == City.None)
  394.             {
  395.                 player.citySelected = City.LosSantos;
  396.             }
  397.  
  398.             lossantosTD.Hide(player);
  399.             sanfierroTD.Hide(player);
  400.             lasventurasTD.Hide(player);
  401.  
  402.             if (player.citySelected == City.LosSantos)
  403.             {
  404.                 player.Interior = 0;
  405.                 player.CameraPosition = new Vector3(1630.6136, -2286.0298, 110.0);
  406.                 player.SetCameraLookAt(new Vector3(1887.6034, -1682.1442, 47.6167));
  407.  
  408.                 lossantosTD.Show(player);
  409.             }
  410.             if(player.citySelected == City.SanFierro)
  411.             {
  412.                 player.Interior = 0;
  413.                 player.CameraPosition = new Vector3(-1300.8754, 68.0546, 129.4823);
  414.                 player.SetCameraLookAt(new Vector3(-1817.9412, 769.3878, 132.6589));
  415.  
  416.                 sanfierroTD.Show(player);
  417.             }
  418.             if(player.citySelected == City.LasVenturas)
  419.             {
  420.                 player.Interior = 0;
  421.                 player.CameraPosition = new Vector3(1310.6155, 1675.9182, 110.7390);
  422.                 player.SetCameraLookAt(new Vector3(2285.2944, 1919.3756, 68.2275));
  423.  
  424.                 lasventurasTD.Show(player);
  425.             }
  426.         }
  427.  
  428.         void SwitchToNextCity(Player player)
  429.         {
  430.             player.citySelected++;
  431.  
  432.             if(player.citySelected > City.LasVenturas)
  433.             {
  434.                 player.citySelected = City.LosSantos;
  435.             }
  436.  
  437.             player.PlaySound(1052);
  438.             player.lastSelection = DateTime.Now;
  439.  
  440.             SetupSelectedCity(player);
  441.         }
  442.  
  443.         void SwitchToPreviousCity(Player player)
  444.         {
  445.             player.citySelected--;
  446.  
  447.             if (player.citySelected <= City.None)
  448.             {
  449.                 player.citySelected = City.LasVenturas;
  450.             }
  451.  
  452.             player.PlaySound(1053);
  453.             player.lastSelection = DateTime.Now;
  454.  
  455.             SetupSelectedCity(player);
  456.         }
  457.  
  458.         void HandleCitySelection(Player player)
  459.         {
  460.             if (player.citySelected == City.None)
  461.             {
  462.                 SwitchToNextCity(player);
  463.                 return;
  464.             }
  465.            
  466.             if((DateTime.Now - player.lastSelection) < TimeSpan.FromMilliseconds(500))
  467.             {
  468.                 return;
  469.             }
  470.  
  471.             player.GetKeys(out Keys keys, out int upOrDown, out int leftOrRight);
  472.  
  473.             if(keys == Keys.Fire)
  474.             {
  475.                 player.ToggleSpectating(false);
  476.  
  477.                 lossantosTD.Hide(player);
  478.                 sanfierroTD.Hide(player);
  479.                 lasventurasTD.Hide(player);
  480.                 classSelectionTD.Hide(player);
  481.  
  482.                 player.hasSelection = true;
  483.                 return;
  484.             }
  485.  
  486.             if(leftOrRight > 0)
  487.             {
  488.                 SwitchToNextCity(player);
  489.             }
  490.             if(leftOrRight < 0)
  491.             {
  492.                 SwitchToPreviousCity(player);
  493.             }
  494.         }
  495.  
  496.         protected override void OnPlayerRequestClass(BasePlayer sender, RequestClassEventArgs e)
  497.         {
  498.             Player player = sender as Player;
  499.  
  500.             if(player.IsNPC == true)
  501.             {
  502.                 base.OnPlayerRequestClass(player, e);
  503.                 return;
  504.             }
  505.  
  506.             if(player.hasSelection == true)
  507.             {
  508.                 SetupCharacterSelection(player);
  509.             }
  510.             else
  511.             {
  512.                 if(player.State != PlayerState.Spectating)
  513.                 {
  514.                     player.citySelected = City.None;
  515.                     player.ToggleSpectating(true);
  516.  
  517.                     classSelectionTD.Show(player);
  518.                 }
  519.             }
  520.  
  521.             base.OnPlayerRequestClass(player, e);
  522.         }
  523.  
  524.         protected override void OnInitialized(EventArgs e)
  525.         {
  526.             Console.WriteLine();
  527.             Console.WriteLine("---------------------------------------");
  528.             Console.WriteLine("Running Grand Larceny - by the SA-MP team");
  529.             Console.WriteLine("---------------------------------------");
  530.             Console.WriteLine();
  531.  
  532.             SetGameModeText("Grand Larceny");
  533.             ShowPlayerMarkers(PlayerMarkersMode.Global);
  534.             ShowNameTags(true);
  535.             SetNameTagDrawDistance(40.0f);
  536.             EnableStuntBonusForAll(false);
  537.             DisableInteriorEnterExits();
  538.  
  539.             Server.SetWeather(2);
  540.             Server.SetWorldTime(11);
  541.  
  542.             InitTextDraws();
  543.  
  544.             // Player Class
  545.             AddPlayerClass(298, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  546.             AddPlayerClass(299, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  547.             AddPlayerClass(300, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  548.             AddPlayerClass(301, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  549.             AddPlayerClass(302, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  550.             AddPlayerClass(303, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  551.             AddPlayerClass(304, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  552.             AddPlayerClass(305, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  553.             AddPlayerClass(280, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  554.             AddPlayerClass(281, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  555.             AddPlayerClass(282, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  556.             AddPlayerClass(283, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  557.             AddPlayerClass(284, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  558.             AddPlayerClass(285, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  559.             AddPlayerClass(286, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  560.             AddPlayerClass(287, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  561.             AddPlayerClass(288, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  562.             AddPlayerClass(289, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  563.             AddPlayerClass(265, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  564.             AddPlayerClass(266, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  565.             AddPlayerClass(267, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  566.             AddPlayerClass(268, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  567.             AddPlayerClass(269, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  568.             AddPlayerClass(270, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  569.             AddPlayerClass(1, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  570.             AddPlayerClass(2, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  571.             AddPlayerClass(3, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  572.             AddPlayerClass(4, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  573.             AddPlayerClass(5, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  574.             AddPlayerClass(6, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  575.             AddPlayerClass(8, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  576.             AddPlayerClass(42, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  577.             AddPlayerClass(65, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  578.             //AddPlayerClass(74,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  579.             AddPlayerClass(86, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  580.             AddPlayerClass(119, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  581.             AddPlayerClass(149, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  582.             AddPlayerClass(208, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  583.             AddPlayerClass(273, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  584.             AddPlayerClass(289, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  585.  
  586.             AddPlayerClass(47, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  587.             AddPlayerClass(48, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  588.             AddPlayerClass(49, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  589.             AddPlayerClass(50, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  590.             AddPlayerClass(51, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  591.             AddPlayerClass(52, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  592.             AddPlayerClass(53, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  593.             AddPlayerClass(54, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  594.             AddPlayerClass(55, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  595.             AddPlayerClass(56, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  596.             AddPlayerClass(57, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  597.             AddPlayerClass(58, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  598.             AddPlayerClass(68, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  599.             AddPlayerClass(69, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  600.             AddPlayerClass(70, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  601.             AddPlayerClass(71, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  602.             AddPlayerClass(72, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  603.             AddPlayerClass(73, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  604.             AddPlayerClass(75, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  605.             AddPlayerClass(76, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  606.             AddPlayerClass(78, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  607.             AddPlayerClass(79, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  608.             AddPlayerClass(80, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  609.             AddPlayerClass(81, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  610.             AddPlayerClass(82, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  611.             AddPlayerClass(83, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  612.             AddPlayerClass(84, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  613.             AddPlayerClass(85, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  614.             AddPlayerClass(87, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  615.             AddPlayerClass(88, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  616.             AddPlayerClass(89, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  617.             AddPlayerClass(91, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  618.             AddPlayerClass(92, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  619.             AddPlayerClass(93, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  620.             AddPlayerClass(95, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  621.             AddPlayerClass(96, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  622.             AddPlayerClass(97, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  623.             AddPlayerClass(98, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  624.             AddPlayerClass(99, 1759.0189, -1898.1260, 13.5622, 266.4503, -1, -1, -1, -1, -1, -1);
  625.  
  626.             int totalVehiclesFromFiles = 0;
  627.  
  628.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/trains.txt");
  629.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/pilots.txt");
  630.  
  631.             // LAS VENTURAS
  632.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/lv_law.txt");
  633.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/lv_airport.txt");
  634.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/lv_gen.txt");
  635.  
  636.             // SAN FIERRO
  637.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/sf_law.txt");
  638.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/sf_airport.txt");
  639.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/sf_gen.txt");
  640.  
  641.             // LOS SANTOS
  642.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/ls_law.txt");
  643.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/ls_airport.txt");
  644.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/ls_gen_inner.txt");
  645.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/ls_gen_outer.txt");
  646.  
  647.             // OTHER AREAS
  648.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/whetstone.txt");
  649.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/bone.txt");
  650.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/flint.txt");
  651.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/tierra.txt");
  652.             totalVehiclesFromFiles += LoadStaticVehiclesFromFile("scriptfiles/vehicles/red_county.txt");
  653.  
  654.             Console.WriteLine("Total vehicles from files: {0}", totalVehiclesFromFiles);
  655.  
  656.             base.OnInitialized(e);
  657.         }
  658.  
  659.         protected override void OnPlayerUpdate(BasePlayer sender, PlayerUpdateEventArgs e)
  660.         {
  661.             Player player = sender as Player;
  662.  
  663.             if (player.IsConnected == false || player.IsNPC == true)
  664.             {
  665.                 base.OnPlayerUpdate(player, e);
  666.                 return;
  667.             }
  668.  
  669.             if(player.hasSelection == false && player.State == PlayerState.Spectating)
  670.             {
  671.                 HandleCitySelection(player);
  672.                 base.OnPlayerUpdate(player, e);
  673.                 return;
  674.             }
  675.  
  676.             if(player.Weapon == Weapon.Minigun)
  677.             {
  678.                 player.Kick();
  679.  
  680.                 e.PreventPropagation = true;
  681.  
  682.                 base.OnPlayerUpdate(player, e);
  683.                 return;
  684.             }
  685.  
  686.             if(player.SpecialAction == SpecialAction.Usejetpack)
  687.             {
  688.                 player.Kick();
  689.  
  690.                 e.PreventPropagation = true;
  691.  
  692.                 base.OnPlayerUpdate(player, e);
  693.                 return;
  694.             }
  695.  
  696.             base.OnPlayerUpdate(player, e);
  697.         }
  698.  
  699.         Vector3 GetXYInFrontOfPoint(Vector3 position, double angle, double distance)
  700.         {
  701.             double x = position.X, y = position.Y;
  702.  
  703.             angle *= (Math.PI / 180.0f);
  704.  
  705.             x += (distance * Math.Sin(-angle));
  706.             y += (distance * Math.Cos(-angle));
  707.             return new Vector3(x, y, position.Z);
  708.         }
  709.  
  710.         protected override void LoadControllers(ControllerCollection controllers)
  711.         {
  712.             base.LoadControllers(controllers);
  713.  
  714.             controllers.Override(new PlayerController());
  715.         }
  716.  
  717.         void AddPlayerClass(int modelId, double x, double y, double z, double angle, params object[] useless)
  718.         {
  719.             AddPlayerClass(modelId, new Vector3(x, y, z), (float) angle);
  720.         }
  721.     }
  722.  
  723.     public class Player : BasePlayer
  724.     {
  725.         public bool hasSelection = false;
  726.         public City citySelected = City.None;
  727.         public DateTime lastSelection = DateTime.MinValue;
  728.     }
  729.  
  730.     public class PlayerController : BasePlayerController
  731.     {
  732.         public override void RegisterTypes()
  733.         {
  734.             Player.Register<Player>();
  735.         }
  736.     }
  737.  
  738.     public enum City
  739.     {
  740.         None,
  741.         LosSantos,
  742.         SanFierro,
  743.         LasVenturas
  744.     }
  745.  
  746.     public class SpawnPoint
  747.     {
  748.         public Vector3 position = Vector3.Zero;
  749.         public float angle = 0.0f;
  750.  
  751.         public SpawnPoint(Vector3 position, float angle)
  752.         {
  753.             this.position = position;
  754.             this.angle = angle;
  755.         }
  756.  
  757.         public SpawnPoint(Vector3 position, double angle)
  758.         {
  759.             this.position = position;
  760.             this.angle = (float)angle;
  761.         }
  762.  
  763.         public SpawnPoint(float x, float y, float z, float angle)
  764.         {
  765.             this.position = new Vector3(x, y, z);
  766.             this.angle = angle;
  767.         }
  768.  
  769.         public SpawnPoint(double x, double y, double z, double angle)
  770.         {
  771.             this.position = new Vector3(x, y, z);
  772.             this.angle = (float)angle;
  773.         }
  774.     }
  775. }
Advertisement
Add Comment
Please, Sign In to add comment