public void OnClientEventTrigger(Client client, string eventName, params object[] args)
 {
     if (eventName == "player_entered_blip")
     {
         DMVTest d = GetTestInstanceByPlayer(Player.PlayerData[client]);
         if (d.IsPlayerInTestVehicle())
         {
             d.PlayerEnteredCheckpoint();
         }
         else
         {
             API.sendChatMessageToPlayer(client, "Get back in your car!");
         }
     }
     else if (eventName == "player_found_speeding")
     {
         DMVTest d = GetTestInstanceByPlayer(Player.PlayerData[client]);
         d.AddSpeedFlag(Convert.ToInt32(args[0]));
     }
     else if (eventName == "request_test_results")
     {
         DMVTest d = GetTestInstanceByPlayer(Player.PlayerData[client]);
         d.HandleTestResults(Convert.ToInt32(args[0]));
     }
 }
 public void OnClientEventTrigger(Client client, string eventName, params object[] args)
 {
     if (eventName == "player_entered_blip")
     {
         DMVTest d = GetTestInstanceByPlayer(Player.PlayerData[client]);
         if (d.IsPlayerInTestVehicle())
         {
             d.PlayerEnteredCheckpoint();
         }
         else
         {
             API.sendChatMessageToPlayer(client, "Get back in your car!");
         }
     }
     else if (eventName == "player_found_speeding")
     {
         DMVTest d = GetTestInstanceByPlayer(Player.PlayerData[client]);
         d.AddSpeedFlag(Convert.ToInt32(args[0]));
     }
     else if (eventName == "request_test_results")
     {
         DMVTest d = GetTestInstanceByPlayer(Player.PlayerData[client]);
         d.HandleTestResults(Convert.ToInt32(args[0]));
     }
     else if (eventName == "launch_test_type")
     {
         API.sendChatMessageToPlayer(client, "Test type recieved: " + args[0].ToString());
         if ((int)args[0] == 1 || (int)args[0] == 2 || (int)args[0] == 3)
         {
             LaunchTest(client, Convert.ToInt32(args[0]));
         }
         else if ((int)args[0] == 6)
         {
             API.sendChatMessageToPlayer(client, "Triggering Client Event");
             API.triggerClientEvent(client, "show_boattest_marker");
         }
         else if ((int)args[0] == 5)
         {
             API.triggerClientEvent(client, "show_planetest_marker");
         }
         else if ((int)args[0] == 4)
         {
             API.triggerClientEvent(client, "show_helitest_marker");
         }
     }
     else if (eventName == "start_boat_test")
     {
         LaunchTest(client, 6);
     }
     else if (eventName == "start_plane_test")
     {
         LaunchTest(client, 5);
     }
     else if (eventName == "start_heli_test")
     {
         LaunchTest(client, 4);
     }
 }
        public void EndTest(Client player)
        {
            SendTestEndMessage(Player.PlayerData[player], false);
            DMVTest test = GetTestInstanceByPlayer(Player.PlayerData[player]);

            API.deleteEntity(test.testVehicle.Entity);
            activeTests.Remove(test);
            API.SendErrorNotification(player, "You have cancelled your driving test.");
        }
 public static void DisplayTestResults(DMVTest test, Player player, string vehClass, int speeding, double damage, bool result)
 {
     if (test.testType == 6)
     {
         player.Client.position = new Vector3(-1610.545, 5258.955, 3.974101);
     }
     API.shared.triggerClientEvent(player.Client, "show_test_result", DateTime.Today.ToShortDateString(), player.Client.name.Split(' ')[1], player.Client.name.Split(' ')[0], vehClass, speeding, damage, result);
     API.shared.deleteEntity(test.testVehicle.Entity);
     activeTests.Remove(test);
 }
        public void dtest(Client player)
        {
            DMVTest test = new DMVTest(Player.PlayerData[player]);

            API.triggerClientEvent(player, "load_test_interface");
            test.testVehicle = API.createVehicle(VehicleHash.Elegy, new Vector3(-315.8801, 6249.22, 30.89409), new Vector3(2.262521, 2.527319, 56.63427), 0, 0);
            API.setPlayerIntoVehicle(player, test.testVehicle, -1);
            test.testType    = (int)DrivingTestTypes.Car;
            test.checkpoints = carTestTestCheckpoints;
            test.speedLimits = carTestTestSpeeds;
            activeTests.Add(test);
            test.BeginTest();
        }
 public void DisplayTestResults(DMVTest test, Player player, string vehClass, int speeding, double damage, string result)
 {
     API.triggerClientEvent(player.Client, "show_test_result", vehClass, speeding, damage, result);
     API.deleteEntity(test.testVehicle);
     activeTests.Remove(test);
 }
        public void InitTest(Client player, int type)
        {
            DMVTest test = new DMVTest(Player.PlayerData[player])
            {
                testType = type
            };

            if (test.testType == 1 || test.testType == 2 || test.testType == 3)
            {
                API.triggerClientEvent(player, "load_test_interface");
            }

            VehicleHash?model    = null;
            Vector3     spawnLoc = null;

            if (type == 1)
            {
                Random rand = new Random();
                int    r    = rand.Next(testCars.Count);
                model    = testCars[r];
                spawnLoc = new Vector3(-342.2152, 6245.498, 30.98962);
            }
            else if (type == 2)
            {
                model    = VehicleHash.Sanchez;
                spawnLoc = new Vector3(-342.2152, 6245.498, 30.98962);
            }
            else if (type == 3)
            {
                model    = VehicleHash.Boxville;
                spawnLoc = new Vector3(-342.2152, 6245.498, 30.98962);
            }
            else if (type == 4)
            {
                model    = VehicleHash.Maverick;
                spawnLoc = new Vector3(1725.108, 3260.298, 41.77298);
            }
            else if (type == 5)
            {
                model    = VehicleHash.Vestra;
                spawnLoc = new Vector3(1725.108, 3260.298, 41.77298);
            }
            else if (type == 6)
            {
                model    = VehicleHash.Dinghy;
                spawnLoc = new Vector3(-1601.602, 5259.89, 0.1100717);
            }

            Vehicle testVeh = new Vehicle()
            {
                Model  = (int)model,
                Color1 = "1",
                Color2 = "1",
                Entity = API.createVehicle((VehicleHash)model, spawnLoc, new Vector3(0, 0, 0), 0, 0)
            };

            test.testVehicle = testVeh;
            Vehicle.VehicleData.Add(testVeh.Entity, testVeh);

            if (type == 1 || type == 2 || type == 3)
            {
                test.checkpoints = carTestCheckpoints;
                test.speedLimits = carTestSpeeds;
            }
            else if (type == 4)
            {
                test.checkpoints = heliCheckpoints;
                test.speedLimits = null;
            }
            else if (type == 5)
            {
                test.checkpoints = planeCheckpoints;
                test.speedLimits = null;
            }
            else if (type == 6)
            {
                test.checkpoints = boatCheckpoints;
                test.speedLimits = null;
            }

            activeTests.Add(test);
            API.setPlayerIntoVehicle(player, test.testVehicle.Entity, -1);
            test.BeginTest();
        }