예제 #1
0
        private async Task Draw3DMarkers()
        {
            if (Game.PlayerPed.IsAlive && Game.PlayerPed.IsVisible)
            {
                foreach (Marker m in MarkerList)
                {
                    if (World.GetDistance(Game.PlayerPed.Position, m.MarkerPos) < 25.0f)
                    {
                        Helpers.Draw3DText(m.MarkerPos, Color.FromArgb(255, 255, 255), m.MarkerName, CitizenFX.Core.UI.Font.ChaletComprimeCologne, 1);

                        World.DrawMarker(MarkerType.VerticalCylinder, m.MarkerPos, Vector3.Zero, Vector3.Zero, new Vector3(1.5f, 1.5f, 1.5f), Color.FromArgb(255, 200, 200, 200), false, true);
                    }

                    if (World.GetDistance(Game.PlayerPed.Position, m.MarkerPos) < 2.0f)
                    {
                        if (API.IsControlJustReleased(0, 46))
                        {
                            Action <Marker> markerAction = GetMarkerAction(m.MarkerAction);

                            markerAction(m);

                            await MainClient.Delay(500);
                        }
                    }
                }
            }
        }
예제 #2
0
        private static async void NUIDisconnect(dynamic _data, CallbackDelegate _callback)
        {
            await MainClient.Delay(500);

            UnregisterCharacterNUICallbacks();
            _ = _callback(new { ok = true });
        }
예제 #3
0
        private async void AdminSpawnVehicle(string _seshKey, string _vehicleModel)
        {
            if (!Helpers.CheckSessionKey(_seshKey))
            {
                MainClient.TriggerServerEvent("Laced:SessionKeyError"); return;
            }
            uint vehicleHash = Helpers.GetVehicleHashFromString(_vehicleModel);

            Utils.WriteLine(vehicleHash.ToString());
            if (!API.IsModelInCdimage(vehicleHash) || !API.IsModelAVehicle(vehicleHash))
            {
                Utils.WriteLine("Model doesn't exist!");
                return;
            }

            API.RequestModel(vehicleHash);

            while (!API.HasModelLoaded(vehicleHash))
            {
                Utils.DebugLine("Waiting for model to load!", "CCommandManager");
                await MainClient.Delay(500);
            }

            int     playerPedID = API.PlayerPedId();
            Vector3 plyPos      = Game.PlayerPed.Position;

            int vehicle = API.CreateVehicle(vehicleHash, plyPos.X, plyPos.Y, plyPos.Z, API.GetEntityHeading(playerPedID), true, false);
            await MainClient.Delay(50);

            API.SetPedIntoVehicle(playerPedID, vehicle, -1);

            API.SetEntityAsNoLongerNeeded(ref vehicle);

            API.SetModelAsNoLongerNeeded(vehicleHash);
        }
예제 #4
0
        private static async void DeleteCharacter(dynamic _data, CallbackDelegate _callback)
        {
            await MainClient.Delay(500);

            MainClient.TriggerServerEvent("Laced:DeleteCharacter", _data.id);

            _ = _callback(new { ok = true });
        }
예제 #5
0
        private static async void CreateCharacter(dynamic _data, CallbackDelegate _callback)
        {
            await MainClient.Delay(50);

            MainClient.TriggerServerEvent("Laced:CreateCharacter", _data.firstName, _data.lastName, _data.gender);

            _ = _callback(new { ok = true });
        }
예제 #6
0
        private async void AdminGiveWeapon(string _seshKey, string _vehicleModel)
        {
            if (!Helpers.CheckSessionKey(_seshKey))
            {
                MainClient.TriggerServerEvent("Laced:SessionKeyError"); return;
            }

            await MainClient.Delay(0);
        }
예제 #7
0
        private static async void SelectCharacter(dynamic _data, CallbackDelegate _callback)
        {
            await MainClient.Delay(500);

            MainClient.GetInstance().SetNUIFocus(false, false);
            MainClient.TriggerServerEvent("Laced:SelectCharacter", _data.id);

            UnregisterCharacterNUICallbacks();
            _ = _callback(new { ok = true });
        }
예제 #8
0
        private async void OnClientResourceStop(string _resourceName)
        {
            if (_resourceName != MainClient.ResourceName())
            {
                return;
            }
            MainClient.TriggerServerEvent("Laced:Disconnect");
            await MainClient.Delay(500);

            PlayerSession = null;
        }
예제 #9
0
        public static async void EnableModifier(Character _character, string _sessionKey)
        {
            Utils.DebugLine("Enabling character modifier!", "CCharacterModifier");
            //Set session key
            sessionKey = _sessionKey;
            // Character Setup
            CurrentCharacter = _character;
            //Find a place to create a character, top of a mountain or something
            World.RenderingCamera = World.CreateCamera(Game.Player.Character.Position, new Vector3(0f, 0f, 180f), 30f);
            await MainClient.Delay(50);

            World.RenderingCamera.AttachTo(Game.Player.Character.Bones[Bone.SKEL_Head], new Vector3(0f, 2f, 0.5f));
            SetPedBlendData();
            CreateMenu();
        }
예제 #10
0
        public async static void DisableCharacterModifier()
        {
            MainClient.GetInstance().UnregisterTickHandler(KeepMenuEnabled);

            World.RenderingCamera = null;

            await MainClient.Delay(50);

            MenuController.Menus.Remove(MainMenu);

            FaceShapeMenu.ClearMenuItems();
            AppearanceMenu.ClearMenuItems();
            ParentsMenu.ClearMenuItems();
            MainMenu.ClearMenuItems();

            MainMenu.CloseMenu();
            MenuController.Menus.Clear();
            MenuController.CloseAllMenus();
        }
예제 #11
0
        private async void UseItem(dynamic _data, CallbackDelegate _callback)
        {
            await MainClient.Delay(500);

            MainClient.GetInstance().SetNUIFocus(false, false);
            foreach (var v in _data)
            {
                Utils.WriteLine(v);
            }
            if (_data.slotid == null)
            {
                return;
            }
            //InventoryItem inventoryItem = PlayerCharacter.Inventory.InventoryItems[_data.ItemID];
            Utils.WriteLine("Triggering server event!");
            //Send invetory id over to server and the server will use the item
            MainClient.TriggerServerEvent("Laced:UseInventoryItem", SessionManager.PlayerSession.getSessionKey(), _data.slotid, new Action <string>(UseItemCallback));
            Utils.WriteLine("Triggering callback!");
            _ = _callback(new { ok = true });
        }
예제 #12
0
        /// <summary>
        /// Spawn vehicle using vehicle hash, a number plate, and a spawn position. If none is set will use the players position
        /// </summary>
        /// <param name="_vehicleHash"></param>
        /// <param name="_spawnPos"></param>
        /// <returns></returns>
        public async static Task <int> SpawnVehicle(uint _vehicleHash, string _numberPlate, Vector3 _spawnPos = new Vector3())
        {
            if (!API.IsModelInCdimage(_vehicleHash) || !API.IsModelAVehicle(_vehicleHash))
            {
                Utils.WriteLine("Model doesn't exist!");
                return(-1);
            }

            API.RequestModel(_vehicleHash);

            while (!API.HasModelLoaded(_vehicleHash))
            {
                Utils.DebugLine("Waiting for model to load!", "CCommandManager");
                await MainClient.Delay(500);
            }

            //If spawn pos is equal to a new vector then we use the players ped position to spawn the vehicle
            Vector3 spawnPos = _spawnPos;

            if (spawnPos == new Vector3())
            {
                spawnPos = Game.PlayerPed.Position;
            }

            int playerPedID = API.PlayerPedId();
            int vehicle     = API.CreateVehicle(_vehicleHash, spawnPos.X, spawnPos.Y, spawnPos.Z, API.GetEntityHeading(playerPedID), true, false);
            await MainClient.Delay(50);

            API.SetVehicleNumberPlateText(vehicle, _numberPlate);
            API.SetPedIntoVehicle(playerPedID, vehicle, -1);

            //API.SetEntityAsNoLongerNeeded(ref vehicle);

            API.SetModelAsNoLongerNeeded(_vehicleHash);

            return(vehicle);
        }
예제 #13
0
        private async void SpawnPlayerCharacter(string _sessionKey, string _character)
        {
            if (_sessionKey == null)
            {
                MainClient.TriggerServerEvent("Laced:SessionKeyMissing", "Spawning");
                return;
            }

            Character _spawnedCharacter = JsonConvert.DeserializeObject <Character>(_character);

            var model = new Model(_spawnedCharacter.Model);

            API.RequestModel((uint)model.Hash);
            while (!API.HasModelLoaded((uint)model.Hash))
            {
                Utils.DebugLine("Player Model Loading!", "CSpawnManager");
                await Game.Player.ChangeModel(model);

                await MainClient.Delay(1);
            }
            Utils.DebugLine($"Changed Player Model!", "CSpawnManager");

            //Get's the first spawn pos, aka the fresh spawn
            Vector3 SpawnPos     = new Vector3(ConfigManager.SpawningConfig[0].X, ConfigManager.SpawningConfig[0].Y, ConfigManager.SpawningConfig[0].Z);
            float   SpawnHeading = ConfigManager.SpawningConfig[0].H;

            //Setting players ped to look like the character
            Game.Player.Character.Style[PedComponents.Hair].SetVariation(_spawnedCharacter.Appearance.HairStyle, 0);
            Game.Player.Character.Style[PedComponents.Torso].SetVariation(_spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Torso)][0], _spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Torso)][1]);
            Game.Player.Character.Style[PedComponents.Legs].SetVariation(_spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Legs)][0], _spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Legs)][1]);
            Game.Player.Character.Style[PedComponents.Hands].SetVariation(_spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Hands)][0], _spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Hands)][1]);
            Game.Player.Character.Style[PedComponents.Shoes].SetVariation(_spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Shoes)][0], _spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Shoes)][1]);
            Game.Player.Character.Style[PedComponents.Special1].SetVariation(_spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Special1)][0], _spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Special1)][1]);
            Game.Player.Character.Style[PedComponents.Special2].SetVariation(_spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Special2)][0], _spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Special2)][1]);
            Game.Player.Character.Style[PedComponents.Special3].SetVariation(_spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Special3)][0], _spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Special3)][1]);
            Game.Player.Character.Style[PedComponents.Textures].SetVariation(_spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Textures)][0], _spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Textures)][1]);
            Game.Player.Character.Style[PedComponents.Torso2].SetVariation(_spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Torso2)][0], _spawnedCharacter.Clothing[Convert.ToInt32(PedComponents.Torso2)][1]);

            API.SetPedHeadBlendData(Game.Player.Character.Handle, _spawnedCharacter.Parents.Father, _spawnedCharacter.Parents.Mother, 0, _spawnedCharacter.Parents.Father, _spawnedCharacter.Parents.Mother, 0, _spawnedCharacter.Parents.Mix, _spawnedCharacter.Parents.Mix, -1, false);

            for (int i = 0; i < _spawnedCharacter.FaceFeatures.Count - 1; i++)
            {
                API.SetPedFaceFeature(Game.Player.Character.Handle, i, _spawnedCharacter.FaceFeatures[i]);
            }

            for (int i = 0; i < _spawnedCharacter.Appearance.Overlays.Count - 1; i++)
            {
                API.SetPedHeadOverlay(Game.Player.Character.Handle, i, _spawnedCharacter.Appearance.Overlays[i].Index, _spawnedCharacter.Appearance.Overlays[i].Opacity);

                if (_spawnedCharacter.Appearance.Overlays[i].IsHair)
                {
                    API.SetPedHeadOverlayColor(Game.Player.Character.Handle, i, 1, _spawnedCharacter.Appearance.HairColor, _spawnedCharacter.Appearance.HairHighlightColor);
                }
            }

            API.SetPedHairColor(Game.Player.Character.Handle, _spawnedCharacter.Appearance.HairColor, _spawnedCharacter.Appearance.HairHighlightColor);
            //Finished setting players ped looks
            if (_spawnedCharacter.IsNew)
            {
                Utils.DebugLine("Character is new!", "CSpawnManager");
                API.RequestCollisionAtCoord(SpawnPos.X, SpawnPos.Y, SpawnPos.Z);
                await MainClient.Delay(50);

                Game.Player.Character.Position = SpawnPos;
                Game.Player.Character.Heading  = SpawnHeading;

                CharacterModifier.EnableModifier(_spawnedCharacter, _sessionKey);

                return;
            }
            else
            {
                if (_spawnedCharacter.IsDead)
                {
                    SpawnHeading = new Random().Next(0, 359);

                    SessionManager.PlayerSession = new Session(_sessionKey).InitializeSession(_spawnedCharacter);
                }
                else
                {
                    if (_spawnedCharacter.LastPos != null)
                    {
                        SpawnPos.X = _spawnedCharacter.LastPos[0];
                        SpawnPos.Y = _spawnedCharacter.LastPos[1];
                        SpawnPos.Z = _spawnedCharacter.LastPos[2];
                    }

                    SpawnHeading = new Random().Next(0, 359);
                    SessionManager.PlayerSession = new Session(_sessionKey).InitializeSession(_spawnedCharacter);
                }
            }

            if (World.RenderingCamera != null)
            {
                World.RenderingCamera = null;
            }


            API.RequestCollisionAtCoord(SpawnPos.X, SpawnPos.Y, SpawnPos.Z);
            API.ClearPedTasksImmediately(API.PlayerPedId());

            API.FreezeEntityPosition(API.PlayerPedId(), false);

            Game.Player.Character.Position = SpawnPos;
            Game.Player.Character.Heading  = SpawnHeading;
            Utils.DebugLine("Spawned Players Character!", "CSpawnManager");

            //MainClient.TriggerEvent("playerSpawned", SpawnPos);
        }