예제 #1
0
        public static void LoginMenu(Client player)
        {
            API.shared.triggerClientEvent(player, "interpolateCamera", 2000, StartCamPos, StopCamPos, new Vector3(0.0, 0.0, -80.0), new Vector3(0.0, 0.0, -115.0));
            player.position = StartPos;
            player.rotation = StartRot;
            player.freeze(true);
            player.transparency = 0;

            var character = ContextFactory.Instance.Character.FirstOrDefault(x => x.SocialClub == player.socialClubName);

            if (character == null)
            {
                CharacterController.CreateCharacter(player);
            }
            else
            {
                var face = ContextFactory.Instance.Faces.FirstOrDefault(x => x.CharacterId == character.Id);
                if (face != null)
                {
                    SpawnManager.SetCharacterFace(player, character);
                    ClothesManager.SetPlayerSkinClothes(player, 0, character, false);
                    player.transparency = 255;
                    API.shared.triggerClientEvent(player, "login_char_menu", character.Language);
                }
                else
                {
                    CharacterController.InitializePedFace(player.handle);
                    API.shared.triggerClientEvent(player, "face_custom");
                }
            }
        }
예제 #2
0
        public static void SpawnCharacter(Client player, CharacterController characterController)
        {
            API.shared.triggerClientEvent(player, "destroyCamera");
            API.shared.resetPlayerNametagColor(player);

            if (characterController.Character.RegistrationStep == 0)
            {
                var face = ContextFactory.Instance.Faces.FirstOrDefault(x => x.CharacterId == characterController.Character.Id);
                if (face == null)
                {
                    CharacterController.InitializePedFace(player.handle);
                    API.shared.triggerClientEvent(player, "face_custom");
                    return;
                }
                SetCharacterFace(player, characterController.Character);
                ClothesManager.SetPlayerSkinClothes(player, 0, characterController.Character, true);
                ClothesManager.WardrobeInit(characterController.Character);
                WeaponManager.SetPlayerWeapon(player, characterController.Character, 0);
                API.shared.setEntityPosition(player, FirstPlayerPosition);
                API.shared.setEntityRotation(player, FirstPlayerRotation);
                characterController.Character.RegistrationStep = -1; // 'Tutorial Done'
            }
            else
            {
                SetCharacterFace(player, characterController.Character);
                ClothesManager.SetPlayerSkinClothes(player, 0, characterController.Character, false);
                WeaponManager.SetPlayerWeapon(player, characterController.Character, 1);
                API.shared.setEntityPosition(player, NewPlayerPosition);
                API.shared.setEntityRotation(player, NewPlayerRotation);
            }

            if (CharacterController.IsCharacterArmySoldier(characterController))
            {
                var placeArmy = characterController.Character.ActiveGroupID < 2003 ?
                                ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 2000)
                    : ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 2100);

                if (placeArmy != null)
                {
                    API.shared.setEntityPosition(player, new Vector3(placeArmy.ExtPosX, placeArmy.ExtPosY, placeArmy.ExtPosZ));
                    API.shared.setEntityRotation(player, NewPlayerRotation);
                }
            }
            if (CharacterController.IsCharacterInGang(characterController))
            {
                var placeGangs = new Data.Property();

                if (characterController.Character.ActiveGroupID > 1300 &&
                    characterController.Character.ActiveGroupID <= 1310)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1300);
                }
                if (characterController.Character.ActiveGroupID > 1400 &&
                    characterController.Character.ActiveGroupID <= 1410)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1400);
                }
                if (characterController.Character.ActiveGroupID > 1500 &&
                    characterController.Character.ActiveGroupID <= 1510)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1500);
                }
                if (characterController.Character.ActiveGroupID > 1600 &&
                    characterController.Character.ActiveGroupID <= 1610)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1600);
                }
                if (characterController.Character.ActiveGroupID > 1700 &&
                    characterController.Character.ActiveGroupID <= 1710)
                {
                    placeGangs = ContextFactory.Instance.Property.FirstOrDefault(x => x.GroupId == 1700);
                }

                if (placeGangs != null)
                {
                    API.shared.setEntityPosition(player, new Vector3(placeGangs.ExtPosX, placeGangs.ExtPosY, placeGangs.ExtPosZ));
                    API.shared.setEntityRotation(player, NewPlayerRotation);
                }
            }
            var userHouse = ContextFactory.Instance.Property.FirstOrDefault(x => x.CharacterId == characterController.Character.Id);

            if (userHouse != null)
            {
                API.shared.setEntityPosition(player, new Vector3(userHouse.IntPosX, userHouse.IntPosY, userHouse.IntPosZ));
                API.shared.setEntityRotation(player, NewPlayerRotation);
            }
            if (player.getData("ISDYED") == true && !CharacterController.IsCharacterInGang(characterController))
            {
                API.shared.setEntityPosition(player, new Vector3(260.26f, -1357.64f, 24.54f));
                player.setData("ISDYED", false);
                player.health = 20;
            }
            ContextFactory.Instance.SaveChanges();
        }
예제 #3
0
        private void OnPlayerDeath(Client player, NetHandle entityKiller, int weapon)
        {
            CharacterController characterController = player.getData("CHARACTER");
            var diedCharacter = characterController?.Character;

            if (diedCharacter == null)
            {
                return;
            }
            var killer = API.getPlayerFromHandle(entityKiller);
            var isMale = diedCharacter.Model == 1885233650;

            if (killer != null)
            {
                API.sendNotificationToAll(killer.name + Localize.Lang(2, "killed") + player.name);
                var killerCharacter = ContextFactory.Instance.Character.FirstOrDefault(x => x.SocialClub == killer.socialClubName);
                if (killerCharacter == null)
                {
                    return;
                }

                // CAPTION GANGS:
                var caption = ContextFactory.Instance.Caption.First(x => x.Id == 1);
                if (caption.Sector != "0;0")
                {
                    if (CharacterController.InWhichSectorOfGhetto(player) == caption.Sector &&
                        CharacterController.InWhichSectorOfGhetto(killer) == caption.Sector)
                    {
                        var getAttackGroup = ContextFactory.Instance.Group.FirstOrDefault(x => x.Id == caption.GangAttack * 100);
                        if (getAttackGroup == null)
                        {
                            return;
                        }
                        var groupAttackType = (GroupType)Enum.Parse(typeof(GroupType), getAttackGroup.Type.ToString());
                        var getDefendGroup  = ContextFactory.Instance.Group.FirstOrDefault(x => x.Id == caption.GangDefend * 100);
                        if (getDefendGroup == null)
                        {
                            return;
                        }
                        var groupDefendType = (GroupType)Enum.Parse(typeof(GroupType), getDefendGroup.Type.ToString());

                        if (killerCharacter.GroupType == caption.GangAttack && diedCharacter.GroupType == caption.GangDefend)
                        {
                            caption.FragsAttack += 1;
                        }
                        if (killerCharacter.GroupType == caption.GangDefend && diedCharacter.GroupType == caption.GangAttack)
                        {
                            caption.FragsDefend += 1;
                        }

                        var fragsMessage = "~s~Фрагов у банды ~r~" + EntityManager.GetDisplayName(groupAttackType) + " ~s~: ~r~" + caption.FragsAttack +
                                           "\n~s~Фрагов у банды ~g~" + EntityManager.GetDisplayName(groupDefendType) + " ~s~: ~g~" + caption.FragsDefend;
                        ChatController.SendMessageInGroup(caption.GangAttack, fragsMessage);
                        ChatController.SendMessageInGroup(caption.GangDefend, fragsMessage);
                        ContextFactory.Instance.SaveChanges();
                    }
                    else
                    {
                        API.sendChatMessageToPlayer(killer, "Вы вне сектора капта. ~r~Фраг незасчитан!");
                    }
                }

                // Army change cloth after death algorithm
                if (CharacterController.IsCharacterInArmy(diedCharacter) &&
                    CharacterController.IsCharacterInGhetto(killer))
                {
                    switch (diedCharacter.ActiveClothes)
                    {
                    case 201:
                        if (killerCharacter.ClothesTypes == 201)
                        {
                            API.sendNotificationToPlayer(killer, Localize.Lang(killerCharacter.Language, "kill_cloth_soldier_have"));
                            break;
                        }
                        killerCharacter.ClothesTypes = 201;
                        API.sendNotificationToPlayer(killer, Localize.Lang(killerCharacter.Language, "kill_cloth_soldier")); break;

                    case 2010:
                        if (killerCharacter.ClothesTypes == 2010)
                        {
                            API.sendNotificationToPlayer(killer, Localize.Lang(killerCharacter.Language, "kill_cloth_soldier_have"));
                            break;
                        }
                        killerCharacter.ClothesTypes = 2010;
                        API.sendNotificationToPlayer(killer, Localize.Lang(killerCharacter.Language, "kill_cloth_soldier")); break;

                    case 202:
                        if (killerCharacter.ClothesTypes == 202)
                        {
                            API.sendNotificationToPlayer(killer, Localize.Lang(killerCharacter.Language, "kill_cloth_officer_have"));
                            break;
                        }
                        killerCharacter.ClothesTypes = 202;
                        API.sendNotificationToPlayer(killer, Localize.Lang(killerCharacter.Language, "kill_cloth_officer")); break;

                    case 2020:
                        if (killerCharacter.ClothesTypes == 2020)
                        {
                            API.sendNotificationToPlayer(killer, Localize.Lang(killerCharacter.Language, "kill_cloth_officer_have"));
                            break;
                        }
                        killerCharacter.ClothesTypes = 2020;
                        API.sendNotificationToPlayer(killer, Localize.Lang(killerCharacter.Language, "kill_cloth_officer")); break;

                    case 203:
                        if (killerCharacter.ClothesTypes == 203)
                        {
                            API.sendNotificationToPlayer(killer, Localize.Lang(killerCharacter.Language, "kill_cloth_general_have"));
                            break;
                        }
                        killerCharacter.ClothesTypes = 203;
                        API.sendNotificationToPlayer(killer, Localize.Lang(killerCharacter.Language, "kill_cloth_general")); break;

                    case 2030:
                        if (killerCharacter.ClothesTypes == 2030)
                        {
                            API.sendNotificationToPlayer(killer, Localize.Lang(killerCharacter.Language, "kill_cloth_general_have"));
                            break;
                        }
                        killerCharacter.ClothesTypes = 2030;
                        API.sendNotificationToPlayer(killer, Localize.Lang(killerCharacter.Language, "kill_cloth_general")); break;
                    }
                    ClothesManager.SetPlayerSkinClothesToDb(player, isMale ? 999 : 9990, diedCharacter, false);
                }

                // TO PRISON IF STARS:
                if (CharacterController.IsCharacterInPolice(killerCharacter) ||
                    CharacterController.IsCharacterInFbi(killerCharacter))
                {
                    if (API.getPlayerWantedLevel(player) > 0)
                    {
                        diedCharacter.PrisonTime = 10;
                        diedCharacter.IsPrisoned = true;
                        API.setEntityPosition(player, new Vector3(458.81, -1001.43, 24.91));
                        API.shared.freezePlayer(player, true);
                        API.shared.setPlayerWantedLevel(player, 0);
                        API.sendNotificationToPlayer(player, "~r~Вас посадили в тюрьму!");
                    }
                }

                // STARS FOR KILL
            }
            else
            {
                API.sendNotificationToAll(player.name + Localize.Lang(2, "death"));
            }
            WeaponManager.SetPlayerWeapon(player, characterController.Character, 2);

            // Gang change clothes after death

            if (CharacterController.IsCharacterInGang(diedCharacter) &&
                CharacterController.IsCharacterInActiveArmyCloth(diedCharacter))
            {
                diedCharacter.ClothesTypes = 0;
            }
            if (CharacterController.IsCharacterArmyHighOfficer(diedCharacter) ||
                CharacterController.IsCharacterArmyGeneral(diedCharacter))
            {
                ClothesManager.SetPlayerSkinClothesToDb(player, isMale ? 999 : 9990, diedCharacter, false);
            }
            ContextFactory.Instance.SaveChanges();

            if (!CharacterController.IsCharacterInGang(diedCharacter))
            {
                player.setData("ISDYED", true);
                player.setData("NEEDHEAL", true);
            }
        }