private async Task <CallbackDelegate> OnVehTyreSmokeColour(IDictionary <string, object> data, CallbackDelegate callback)
        {
            var vehicle = Game.PlayerPed.CurrentVehicle;

            callback("ok");

            if (vehicle == null)
            {
                Trainer.AddNotification("~r~Not in a vehicle!");
            }
            else
            {
                var action = (string)data["action"];
                var mods   = vehicle.Mods;

                if (action == "input")
                {
                    mods.TireSmokeColor = await GetInputColour();

                    Trainer.AddNotification("~g~Tyre smoke colour changed.");
                }
                else if (action.IndexOf(',') != -1)
                {
                    var colour = Trainer.CommaSeparatedStringToColor(action);
                    mods.TireSmokeColor = colour;
                    Trainer.AddNotification("~g~Tyre smoke colour changed.");
                }
                else
                {
                    Trainer.AddNotification("~r~Invalid tyre smoke colour instruction!");
                }
            }

            return(callback);
        }
        private CallbackDelegate OnVehRoofLivery(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Vehicle vehicle = Game.PlayerPed.CurrentVehicle;

            if (vehicle == null)
            {
                Trainer.AddNotification("~r~Not in a vehicle!");
                callback("ok");
                return(callback);
            }

            int    handle  = vehicle.Handle;
            string livery  = (string)data["action"];
            bool   success = int.TryParse(livery, out int iLivery);

            if (!success)
            {
                Trainer.AddNotification($"~r~Invalid livery number: {livery}!");
                callback("ok");
                return(callback);
            }

            API.SetVehicleRoofLivery(handle, iLivery);

            Trainer.AddNotification($"~y~Note that very few vehicles support roof livery.");
            Trainer.AddNotification($"~g~Set {vehicle.LocalizedName} roof livery to {iLivery}!");

            callback("ok");
            return(callback);
        }
        private async Task <CallbackDelegate> OnVehPlateText(IDictionary <string, object> data, CallbackDelegate callback)
        {
            var vehicle = Game.PlayerPed.CurrentVehicle;

            if (vehicle == null)
            {
                Trainer.AddNotification("~r~Not in a vehicle!");
                callback("ok");
                return(callback);
            }

            callback("ok");
            Trainer.BlockInput = true;

            string plateText = await Game.GetUserInput(
                WindowTitle.FMMC_KEY_TIP8,
                7 // Numberplates max out at 8 chars but this seems to be off by one
                );

            vehicle.Mods.LicensePlate = plateText;

            // Wait a few frames so that the messagebox doesn't start again immediately
            await BaseScript.Delay(10);

            Trainer.BlockInput = false;

            Trainer.AddNotification($"~g~Set number plate to '{vehicle.Mods.LicensePlate}'.");

            return(callback);
        }
        private CallbackDelegate OnVehColourCombo(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Vehicle vehicle = Game.PlayerPed.CurrentVehicle;

            if (vehicle == null)
            {
                Trainer.AddNotification("~r~Not in a vehicle!");
                callback("ok");
                return(callback);
            }

            string combo   = (string)data["action"];
            bool   success = int.TryParse(combo, out int iCombo);

            if (!success)
            {
                Trainer.AddNotification($"~r~Invalid colour combination: {combo}!");
                callback("ok");
                return(callback);
            }

            var mods = vehicle.Mods;

            mods.ColorCombination = iCombo;

            Trainer.AddNotification($"~g~Set {vehicle.LocalizedName} colour combination to combination {combo}!");

            callback("ok");
            return(callback);
        }
        private CallbackDelegate OnSaveDefaultSkin(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Config["DefaultSkin"] = Config["CurrentSkin"];

            Trainer.AddNotification($"~g~Saved {Config["DefaultSkin"]} as your default skin.");

            callback("ok");
            return(callback);
        }
        private CallbackDelegate OnBoostPower(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Config["BoostPower"] = (string)data["action"];

            Trainer.AddNotification($"~g~Boost power set to {Config["BoostPower"]}");

            callback("ok");
            return(callback);
        }
Example #7
0
        private void OnSetTime(int h, int m, int s, string name)
        {
            API.NetworkOverrideClockTime(h, m, s);
            World.CurrentDayTime = new TimeSpan(h, m, s);

            if (!string.IsNullOrWhiteSpace(name))
            {
                Trainer.AddNotification($"~g~Time changed to {h:00}:{m:00} by {name}.");
            }
        }
Example #8
0
        private CallbackDelegate DisplayCoords(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Vector3 location = Game.PlayerPed.Position;
            string  coords   = $"{location.X:#.##}, {location.Y:#.##}, {location.Z:#.##}";

            Trainer.AddNotification($"~g~{coords}");
            BaseScript.TriggerServerEvent("_chat:messageEntered", Game.Player.Name, new[] { 255, 255, 255 }, coords);

            callback("ok");
            return(callback);
        }
Example #9
0
        private CallbackDelegate SetWantedLevel(IDictionary <string, object> data, CallbackDelegate callback)
        {
            int level = int.Parse((string)data["action"]);

            Game.Player.WantedLevel = level;

            Trainer.AddNotification($"~g~Changed wanted level to {level}.");

            callback("ok");
            return(callback);
        }
Example #10
0
        private void OnSetWeather(int weather, string name)
        {
            if (weather < 0)
            {
                return;
            }

            ChangeWeather((Weather)weather);

            if (!string.IsNullOrWhiteSpace(name))
            {
                Trainer.AddNotification($"~g~Weather changed to {WeatherList.GetNiceName(weather)} by {name}.");
            }
        }
        private CallbackDelegate OnLoadDefaultSkin(IDictionary <string, object> data, CallbackDelegate callback)
        {
            if (Config.ContainsKey("DefaultSkin"))
            {
                LoadDefaultSkin();
                Trainer.AddNotification($"~g~Switched back to {Config["DefaultSkin"]}.");
            }
            else
            {
                Trainer.AddNotification($"~r~You don't have a default skin saved.");
            }

            callback("ok");
            return(callback);
        }
        private CallbackDelegate OnVehPlateStyle(IDictionary <string, object> data, CallbackDelegate callback)
        {
            var vehicle = Game.PlayerPed.CurrentVehicle;

            if (vehicle == null)
            {
                Trainer.AddNotification("~r~Not in a vehicle!");
            }
            else
            {
                var style = int.Parse((string)data["action"]);
                vehicle.Mods.LicensePlateStyle = (LicensePlateStyle)style;
            }

            callback("ok");
            return(callback);
        }
        private async Task <CallbackDelegate> OnVehLoad(IDictionary <string, object> data, CallbackDelegate callback)
        {
            var slot = (string)data["action"];

            callback("ok");

            if (Garage.HasSavedVehicle(slot))
            {
                await Garage.LoadVehicle(slot);
            }
            else
            {
                Trainer.AddNotification($"~r~No vehicle saved in slot {slot}!");
            }

            return(callback);
        }
Example #14
0
        private async Task <CallbackDelegate> TeleportToWaypoint(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Blip waypoint = World.GetWaypointBlip();

            callback("ok");

            if (waypoint != null && waypoint.Exists())
            {
                Ped     playerPed = Game.PlayerPed;
                Entity  entity    = playerPed;
                Vector3 position  = waypoint.Position;

                // If the player is driving a vehicle, take it with them
                if (playerPed.IsInVehicle() && playerPed.CurrentVehicle.Driver == playerPed)
                {
                    entity = playerPed.CurrentVehicle;
                }

                entity.Position = position;
                await BaseScript.Delay(0);

                // Make sure position is above ground
                float zCoords = 0f;

                while (zCoords == 0f)
                {
                    await BaseScript.Delay(40);

                    zCoords = World.GetGroundHeight(entity.Position);
                }

                zCoords += 2.5f;

                entity.Position = new Vector3(entity.Position.X, entity.Position.Y, zCoords);
                await BaseScript.Delay(0);

                Trainer.DebugLine($"Telported to {position.X},{position.Y},{position.Z} ({zCoords})");
                Trainer.AddNotification("~g~Teleported to waypoint");
            }
            else
            {
                Trainer.AddNotification("~r~No waypoint is set!");
            }

            return(callback);
        }
        private async Task <bool> ChangePlayerSkin(Ped playerPed, Model model)
        {
            Vehicle     vehicle    = playerPed.CurrentVehicle;
            VehicleSeat playerSeat = VehicleSeat.None;

            // If in a vehicle, remember their seat so we can put them back in it
            if (vehicle != null)
            {
                int seatCount = API.GetVehicleModelNumberOfSeats((uint)vehicle.Model.Hash);

                for (var i = -1; i < seatCount; i++)
                {
                    VehicleSeat iSeat = (VehicleSeat)i;

                    if (vehicle.GetPedOnSeat(iSeat) == playerPed)
                    {
                        playerSeat = iSeat;
                        break;
                    }
                }
            }

            bool success = await Game.Player.ChangeModel(model);

            if (!success)
            {
                Trainer.AddNotification($"~r~Failed to load skin '{model}'!");
                return(false);
            }

            UpdateRecentSkinsList(model);

            BaseScript.TriggerEvent("playerSpawned");
            BaseScript.TriggerEvent("virakal:skinChange", model.GetHashCode());

            if (playerSeat != VehicleSeat.None)
            {
                playerPed = Game.Player.Character;
                playerPed.SetIntoVehicle(vehicle, playerSeat);
            }

            Trainer.AddNotification($"~g~Changed player skin to '{model}'.");

            return(true);
        }
Example #16
0
        private CallbackDelegate TeleportToLastCar(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Player  player      = Game.Player;
            Ped     playerPed   = player.Character;
            Vehicle lastVehicle = player.LastVehicle;

            if (playerPed.IsInVehicle())
            {
                Trainer.AddNotification("~r~Can't teleport to last vehicle whilst already in a vehicle.");
                callback("ok");
                return(callback);
            }

            if (lastVehicle != null && !lastVehicle.IsDead)
            {
                if (API.AreAnyVehicleSeatsFree(lastVehicle.Handle))
                {
                    lastVehicle.PlaceOnGround();

                    Trainer.DebugLine("Trying to drive");
                    // Attempt to drive
                    playerPed.SetIntoVehicle(lastVehicle, VehicleSeat.Driver);

                    Trainer.DebugLine("Trying to passenger");
                    if (!playerPed.IsInVehicle(lastVehicle))
                    {
                        // If that didn't work, try any seat
                        playerPed.SetIntoVehicle(lastVehicle, VehicleSeat.Any);
                    }
                }
                else
                {
                    Trainer.DebugLine("No seats free, moving to location");
                    // No seats free, just teleport to the vehicle
                    playerPed.Position = lastVehicle.Position;
                }
            }
            else
            {
                Trainer.AddNotification("~r~Could not find your last vehicle.");
            }

            callback("ok");
            return(callback);
        }
        private CallbackDelegate OnVehCustomSecondary(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Vehicle vehicle = Game.PlayerPed.CurrentVehicle;

            if (vehicle == null)
            {
                Trainer.AddNotification("~r~Not in a vehicle!");
                callback("ok");
                return(callback);
            }

            var action = (string)data["action"];

            callback("ok");
            ChangeCustomColours(vehicle, action, false, true);

            return(callback);
        }
Example #18
0
        private CallbackDelegate TeleportToPlayer(IDictionary <string, object> data, CallbackDelegate callback)
        {
            int    otherPlayerId = Convert.ToInt32(data["action"]);
            var    playerList    = new PlayerList();
            Player otherPlayer   = playerList[otherPlayerId];

            if (otherPlayer == null)
            {
                Trainer.AddNotification($"~r~Player {otherPlayerId} is not in the game.");
                callback("ok");
                return(callback);
            }

            if (otherPlayer == Game.Player)
            {
                Trainer.AddNotification($"~r~Player {otherPlayerId} is you!");
                callback("ok");
                return(callback);
            }

            Ped     playerPed = Game.Player.Character;
            Ped     otherPed  = otherPlayer.Character;
            Vector3 otherPos  = otherPed.Position;

            // Request a collision to try to load the area
            API.RequestCollisionAtCoord(otherPos.X, otherPos.Y, otherPos.Z);

            Trainer.AddNotification($"Teleporting to {otherPlayer.Name} (Player {otherPlayerId})...");

            // Put them on the ground
            Vector3 newPosition = new Vector3(otherPos.X, otherPos.Y, otherPos.Z + 2.5f);

            playerPed.Position = newPosition;

            Vehicle otherVehicle = otherPed.CurrentVehicle;

            if (otherVehicle != null && API.AreAnyVehicleSeatsFree(otherVehicle.Handle))
            {
                playerPed.SetIntoVehicle(otherVehicle, VehicleSeat.Passenger);
            }

            callback("ok");
            return(callback);
        }
        private async Task <Color> GetInputColour()
        {
            Trainer.BlockInput = true;

            string colourText = await Game.GetUserInput(
                WindowTitle.FMMC_KEY_TIP8,
                64
                );

            Color colour;

            try
            {
                if (colourText.Contains(','))
                {
                    // Assume it's a comma-separated colour
                    // Remove any whitespace
                    colourText = colourText.Replace(" ", "");
                    colour     = Trainer.CommaSeparatedStringToColor(colourText);
                }
                else if (colourText.StartsWith("#") || colourText.StartsWith("0x") || colourText.Length == 6)
                {
                    // HTML-style hex colour?
                    colourText = colourText.Substring(colourText.Length - 6);
                    colour     = Trainer.HexToColor(colourText);
                }
                else
                {
                    throw new Exception("Invalid colour fallthrough");
                }
            }
            catch (Exception)
            {
                Trainer.AddNotification($"~r~Invalid colour {colourText}");
                colour = Color.FromArgb(0);
            }

            // Wait a few frames so that the messagebox doesn't start again immediately
            await BaseScript.Delay(10);

            Trainer.BlockInput = false;

            return(colour);
        }
        private CallbackDelegate OnVehSave(IDictionary <string, object> data, CallbackDelegate callback)
        {
            var slot = (string)data["action"];

            Vehicle vehicle = Game.PlayerPed.CurrentVehicle;

            if (vehicle == null)
            {
                Trainer.AddNotification("~r~Not in a vehicle!");
            }
            else
            {
                Garage.SaveVehicle(slot, vehicle);
                Trainer.AddNotification($"~g~Saved {vehicle.LocalizedName} to slot {slot}!");
            }

            callback("ok");
            return(callback);
        }
        private CallbackDelegate OnVehSeat(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Ped     playerPed = Game.PlayerPed;
            Vehicle vehicle   = playerPed.CurrentVehicle;
            var     action    = (string)data["action"];
            var     actionInt = int.Parse(action);

            if (vehicle == null)
            {
                Trainer.AddNotification("~r~Not in a vehicle!");
                callback("ok");
                return(callback);
            }

            playerPed.SetIntoVehicle(vehicle, (VehicleSeat)actionInt);

            callback("ok");
            return(callback);
        }
        private CallbackDelegate OnVehRim(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Vehicle vehicle = Game.PlayerPed.CurrentVehicle;
            int     iColour = Convert.ToInt32(data["action"]);
            var     colour  = (VehicleColor)iColour;

            if (vehicle == null)
            {
                Trainer.AddNotification("~r~Not in a vehicle!");
            }
            else
            {
                VehicleModCollection mods = vehicle.Mods;
                mods.RimColor = colour;
            }

            callback("ok");
            return(callback);
        }
        private CallbackDelegate OnWeaponConfig(IDictionary <string, object> data, CallbackDelegate callback)
        {
            string action         = (string)data["action"];
            bool   newState       = (bool)data["newstate"];
            string newStateString = newState ? "true" : "false";

            switch (action)
            {
            case "ammo":
                Config["InfiniteAmmo"] = newStateString;

                SetInfiniteAmmo(newState);

                if (newState)
                {
                    Trainer.AddNotification("~g~Infinite ammo enabled.");
                }
                else
                {
                    Trainer.AddNotification("~g~Infinite ammo disabled.");
                }
                break;

            case "clip":
                Config["InfiniteClip"] = newStateString;

                SetInfiniteClip(newState);

                if (newState)
                {
                    Trainer.AddNotification("~g~Infinite clip enabled.");
                }
                else
                {
                    Trainer.AddNotification("~g~Infinite clip disabled.");
                }
                break;
            }

            callback("ok");
            return(callback);
        }
        private CallbackDelegate OnRainbowSpeed(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Config["RainbowSpeed"] = (string)data["action"];

            var success = double.TryParse(Config["RainbowSpeed"], out double rainbowSpeed);

            if (success)
            {
                RainbowSpeed = rainbowSpeed;
                Trainer.AddNotification($"~g~Rainbow speed set to {RainbowSpeed * 100}%");
            }
            else
            {
                RainbowSpeed = 0.5;
                Trainer.AddNotification($"~r~Failed to set rainbow speed! Set to {RainbowSpeed * 100}%");
            }

            callback("ok");
            return(callback);
        }
        private CallbackDelegate OnVehTint(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Vehicle vehicle = Game.PlayerPed.CurrentVehicle;
            int     iTint   = Convert.ToInt32(data["action"]);
            var     tint    = (VehicleWindowTint)iTint;

            if (vehicle == null)
            {
                Trainer.AddNotification("~r~Not in a vehicle!");
            }
            else
            {
                Trainer.DebugLine($"Setting tint to {tint} / {iTint}");
                VehicleModCollection mods = vehicle.Mods;
                mods.InstallModKit();
                mods.WindowTint = tint;
            }

            callback("ok");
            return(callback);
        }
        private CallbackDelegate OnVeh(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Ped     ped   = Game.PlayerPed;
            Vehicle veh   = ped.CurrentVehicle;
            bool    state = (bool)data["newstate"];

            switch ((string)data["action"])
            {
            case "fix":
                if (veh == null)
                {
                    Trainer.AddNotification("~r~Not in a vehicle!");
                    break;
                }

                veh.HealthFloat = 1.0f;
                API.SetVehicleFixed(veh.Handle);
                Trainer.AddNotification("~g~Vehicle repaired.");
                break;

            case "clean":
                if (veh == null)
                {
                    Trainer.AddNotification("~r~Not in a vehicle!");
                    break;
                }

                veh.DirtLevel = 0f;
                Trainer.AddNotification("~g~Vehicle cleaned.");
                break;

            case "flip":
                if (veh == null)
                {
                    Trainer.AddNotification("~r~Not in a vehicle!");
                    break;
                }

                veh.PlaceOnGround();
                Trainer.AddNotification("~g~Vehicle placed on ground.");
                break;

            case "boosthorn":
                Config["BoostOnHorn"] = state ? "true" : "false";

                if (state)
                {
                    Trainer.AddNotification("~g~Boost on horn enabled.");
                }
                else
                {
                    Trainer.AddNotification("~g~Boost on horn disabled.");
                }

                break;

            case "rainbowcar":
                Config["RainbowPaint"] = state ? "true" : "false";

                if (state)
                {
                    Trainer.AddNotification("~g~Rainbow paint enabled.");
                }
                else
                {
                    Trainer.AddNotification("~g~Rainbow paint disabled.");
                }

                break;

            case "rainbowchrome":
                Config["RainbowChrome"] = state ? "true" : "false";

                SetChrome(veh);

                if (state)
                {
                    Trainer.AddNotification("~g~Rainbow chrome enabled.");
                }
                else
                {
                    Trainer.AddNotification("~g~Rainbow chrome disabled.");
                }

                break;

            case "rainbowneon":
                Config["RainbowNeon"] = state ? "true" : "false";

                if (state)
                {
                    Trainer.AddNotification("~g~Rainbow neon enabled.");
                }
                else
                {
                    Trainer.AddNotification("~g~Rainbow neon disabled.");
                }

                break;

            case "rainbowneoninverse":
                Config["RainbowNeonInverse"] = state ? "true" : "false";

                if (state)
                {
                    Trainer.AddNotification("~g~Rainbow neon (inverse colours) enabled.");
                }
                else
                {
                    Trainer.AddNotification("~g~Rainbow neon (inverse colours) disabled.");
                }

                break;

            case "invincible":
                Config["InvincibleVehicle"] = state ? "true" : "false";

                if (state)
                {
                    Trainer.AddNotification("~g~Invincible vehicle enabled.");
                }
                else
                {
                    Trainer.AddNotification("~g~Invincible vehicle disabled.");
                }

                break;
            }

            callback("ok");
            return(callback);
        }
        private async Task <CallbackDelegate> OnVehLivery(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Vehicle vehicle = Game.PlayerPed.CurrentVehicle;

            if (vehicle == null)
            {
                Trainer.AddNotification("~r~Not in a vehicle!");
                callback("ok");
                return(callback);
            }

            int    handle  = vehicle.Handle;
            string livery  = (string)data["action"];
            bool   success = int.TryParse(livery, out int iLivery);

            if (!success)
            {
                Trainer.AddNotification($"~r~Invalid livery number: {livery}!");
                callback("ok");
                return(callback);
            }

            VehicleModCollection mods = vehicle.Mods;
            var maxLivery             = mods.LiveryCount;

            callback("ok");

            if (maxLivery == -1)
            {
                Trainer.DebugLine($"No basic liveries supported, {mods[VehicleModType.Livery].ModCount} mod liveries instead.");
                mods.InstallModKit();

                if (mods[VehicleModType.Livery].ModCount > 0)
                {
                    mods[VehicleModType.Livery].Index = iLivery;
                }
                else
                {
                    Trainer.AddNotification($"~r~{vehicle.LocalizedName} does not support liveries!");
                }
            }
            else if (iLivery >= maxLivery)
            {
                Trainer.AddNotification($"~r~{vehicle.LocalizedName} does not have enough liveries to set to {iLivery}!");
            }
            else
            {
                mods.Livery = iLivery;

                await mods.RequestAdditionTextFile();

                if (mods.LocalizedLiveryName != "")
                {
                    Trainer.AddNotification($"~g~Set {vehicle.LocalizedName} livery to {mods.LocalizedLiveryName} ({iLivery}/{maxLivery - 1})!");
                }
                else
                {
                    Trainer.AddNotification($"~g~Set {vehicle.LocalizedName} livery to {iLivery}/{maxLivery - 1}!");
                }
            }

            return(callback);
        }
        private async Task <CallbackDelegate> OnVehNeon(IDictionary <string, object> data, CallbackDelegate callback)
        {
            var vehicle = Game.PlayerPed.CurrentVehicle;

            callback("ok");

            if (vehicle == null)
            {
                Trainer.AddNotification("~r~Not in a vehicle!");
            }
            else
            {
                var action = (string)data["action"];
                var mods   = vehicle.Mods;

                if (action == "allon")
                {
                    for (var i = 0; i < 4; i++)
                    {
                        mods.SetNeonLightsOn((VehicleNeonLight)i, true);
                    }

                    Trainer.AddNotification("~g~Neons on.");
                }
                else if (action == "alloff")
                {
                    for (var i = 0; i < 4; i++)
                    {
                        mods.SetNeonLightsOn((VehicleNeonLight)i, false);
                    }

                    Trainer.AddNotification("~g~Neons off.");
                }
                else if (action == "input")
                {
                    mods.NeonLightsColor = await GetInputColour();

                    Trainer.AddNotification("~g~Neon colour changed.");
                }
                else if (action.StartsWith("on") && action.Length == 3)
                {
                    var i     = int.Parse(action.Substring(2, 1));
                    var light = (VehicleNeonLight)i;
                    mods.SetNeonLightsOn(light, true);
                    Trainer.AddNotification($"~g~Enabled {light} neon.");
                }
                else if (action.StartsWith("off") && action.Length == 4)
                {
                    var i     = int.Parse(action.Substring(3, 1));
                    var light = (VehicleNeonLight)i;
                    mods.SetNeonLightsOn(light, false);
                    Trainer.AddNotification($"~g~Disabled {light} neon.");
                }
                else if (action.IndexOf(',') != -1)
                {
                    var colour = Trainer.CommaSeparatedStringToColor(action);
                    mods.NeonLightsColor = colour;
                }
                else
                {
                    Trainer.AddNotification("~r~Invalid neon instruction!");
                }
            }

            return(callback);
        }
        private CallbackDelegate OnPlayer(IDictionary <string, object> data, CallbackDelegate callback)
        {
            Ped    playerPed      = Game.PlayerPed;
            string action         = (string)data["action"];
            bool   newState       = (bool)data["newstate"];
            string newStateString = newState ? "true" : "false";

            switch (action)
            {
            case "heal":
                playerPed.Health = 200;
                Trainer.AddNotification("~g~Player healed.");
                break;

            case "armor":
                playerPed.Armor = 100;
                Trainer.AddNotification("~g~Player given armour.");
                break;

            case "suicide":
                playerPed.Kill();
                Trainer.AddNotification("~g~Committed suicide.");
                break;

            case "god":
                Config["GodMode"] = newStateString;

                if (newState)
                {
                    Trainer.AddNotification("~g~God mode enabled.");
                }
                else
                {
                    Trainer.AddNotification("~g~God mode disabled.");
                }
                break;

            case "stamina":
                Config["InfiniteStamina"] = newStateString;

                if (newState)
                {
                    Trainer.AddNotification("~g~Infinite stamina enabled.");
                }
                else
                {
                    Trainer.AddNotification("~g~Infinite stamina disabled.");
                }
                break;

            case "autochute":
                Config["AutoParachute"] = newStateString;

                API.SetAutoGiveParachuteWhenEnterPlane(playerPed.Handle, newState);

                if (newState)
                {
                    Trainer.AddNotification("~g~Auto parachute enabled.");
                }
                else
                {
                    Trainer.AddNotification("~g~Auto parachute disabled.");
                }
                break;
            }

            callback("ok");
            return(callback);
        }
        private CallbackDelegate OnVehMod(IDictionary <string, object> data, CallbackDelegate callback)
        {
            var vehicle = Game.PlayerPed.CurrentVehicle;

            callback("ok");

            if (vehicle == null)
            {
                Trainer.AddNotification("~r~Not in a vehicle!");
            }
            else
            {
                var action = (string)data["action"];
                var mods   = vehicle.Mods;

                if (action == "quickupgrade")
                {
                    mods.InstallModKit();
                    mods[VehicleToggleModType.Turbo].IsInstalled           = true;
                    mods[VehicleToggleModType.XenonHeadlights].IsInstalled = true;
                    mods[VehicleToggleModType.TireSmoke].IsInstalled       = true;
                    mods[VehicleModType.Suspension].Index   = 3;
                    mods[VehicleModType.Transmission].Index = 2;
                    mods[VehicleModType.Armor].Index        = 4;
                    mods[VehicleModType.Brakes].Index       = 2;
                    mods[VehicleModType.Engine].Index       = 2;
                    mods.TireSmokeColor = Color.FromArgb(0, 0, 0);

                    Trainer.AddNotification("~g~Quick upgrade complete!");
                }
                else if (action == "turboon")
                {
                    mods[VehicleToggleModType.Turbo].IsInstalled = true;
                    Trainer.AddNotification("~g~Enabled turbo.");
                }
                else if (action == "turbooff")
                {
                    mods[VehicleToggleModType.Turbo].IsInstalled = false;
                    Trainer.AddNotification("~g~Disabled turbo.");
                }
                else if (action == "xenonon")
                {
                    mods[VehicleToggleModType.XenonHeadlights].IsInstalled = true;
                    Trainer.AddNotification("~g~Enabled Xenon headlights.");
                }
                else if (action == "xenonoff")
                {
                    mods[VehicleToggleModType.XenonHeadlights].IsInstalled = false;
                    Trainer.AddNotification("~g~Disabled Xenon headlights.");
                }
                else if (action == "tyresmokeon")
                {
                    mods[VehicleToggleModType.TireSmoke].IsInstalled = true;
                    Trainer.AddNotification("~g~Enabled tyre smoke.");
                }
                else if (action == "tyresmokeoff")
                {
                    mods[VehicleToggleModType.TireSmoke].IsInstalled = false;
                    Trainer.AddNotification("~g~Disabled tyre smoke.");
                }
            }

            return(callback);
        }