コード例 #1
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
        public static async Task RequestLSPDIntranet(ClassicPlayer player)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0)
                {
                    return;
                }
                if (!ServerFactions.IsCharacterInAnyFaction(player.CharacterId) || (ServerFactions.GetCharacterFactionId(player.CharacterId) != 2 && ServerFactions.GetCharacterFactionId(player.CharacterId) != 12) || !ServerFactions.IsCharacterInFactionDuty(player.CharacterId))
                {
                    player.EmitLocked("Client:Smartphone:ShowLSPDIntranetApp", false, "[]");
                    return;
                }

                string serverWanteds = JsonConvert.SerializeObject(CharactersWanteds.ServerWanteds_.Select(x => new
                {
                    x.wantedId,
                    x.wantedName,
                    x.paragraph,
                    x.category,
                    x.jailtime,
                    x.ticketfine,
                }).OrderBy(x => x.paragraph).ToList());
                player.EmitLocked("Client:Smartphone:ShowLSPDIntranetApp", true, serverWanteds);
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #2
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
 public async Task requestPhoneContacts(ClassicPlayer player)
 {
     try
     {
         if (player == null || !player.Exists || player.CharacterId <= 0)
         {
             return;
         }
         int phoneNumber = Characters.GetCharacterPhonenumber(player.CharacterId);
         var contacts    = CharactersPhone.CharactersPhoneContacts_.ToList().Where(x => x.phoneNumber == phoneNumber).Select(x => new
         {
             x.contactId,
             x.contactName,
             x.contactNumber,
         }).OrderBy(x => x.contactName).ToList();
         var itemCount  = (int)contacts.Count;
         var iterations = Math.Floor((decimal)(itemCount / 10));
         var rest       = itemCount % 10;
         for (var i = 0; i < iterations; i++)
         {
             var skip = i * 10;
             player.EmitLocked("Client:Smartphone:addContactJSON", JsonConvert.SerializeObject(contacts.Skip(skip).Take(10).ToList()));
         }
         if (rest != 0)
         {
             player.EmitLocked("Client:Smartphone:addContactJSON", JsonConvert.SerializeObject(contacts.Skip((int)iterations * 10).ToList()));
         }
         player.EmitLocked("Client:Smartphone:setAllContacts");
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
コード例 #3
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
        public async Task joinRadioFrequence(ClassicPlayer player, string radioFrequence)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0 || string.IsNullOrWhiteSpace(radioFrequence))
                {
                    return;
                }
                if (Characters.GetCharacterCurrentFunkFrequence(player.CharacterId) != null)
                {
                    //ToDo: aus alten entfernen
                    string currentFrequence = Characters.GetCharacterCurrentFunkFrequence(player.CharacterId);
                    Alt.Emit("Server:SaltyChat:leaveRadioFrequence", player, currentFrequence);
                    player.EmitLocked("Client:Smartphone:setCurrentFunkFrequence", null);
                }

                Characters.SetCharacterCurrentFunkFrequence(player.CharacterId, radioFrequence);
                player.EmitLocked("Client:Smartphone:setCurrentFunkFrequence", radioFrequence);
                Alt.Emit("Server:SaltyChat:joinRadio", player, radioFrequence);
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #4
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
        public async Task acceptCall(ClassicPlayer player)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0)
                {
                    return;
                }
                if (Characters.GetCharacterCurrentlyRecieveCaller(player.CharacterId) <= 0)
                {
                    return;
                }
                var           callerId = Characters.GetCharacterCurrentlyRecieveCaller(player.CharacterId);
                ClassicPlayer caller   = (ClassicPlayer)Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x != null && x.Exists && ((ClassicPlayer)x).CharacterId == callerId);
                if (caller == null || !caller.Exists)
                {
                    return;
                }
                Characters.SetCharacterCurrentlyRecieveCallState(caller.CharacterId, 0);
                Characters.SetCharacterCurrentlyRecieveCallState(player.CharacterId, 0);
                Characters.SetCharacterTargetPhoneNumber(caller.CharacterId, Characters.GetCharacterPhonenumber(player.CharacterId));
                Characters.SetCharacterTargetPhoneNumber(player.CharacterId, Characters.GetCharacterPhonenumber(caller.CharacterId));
                caller.EmitLocked("Client:Smartphone:showPhoneCallActive", Characters.GetCharacterPhonenumber(player.CharacterId));
                player.EmitLocked("Client:Smartphone:showPhoneCallActive", Characters.GetCharacterPhonenumber(caller.CharacterId));

                player.EmitLocked("SaltyChat_EstablishedCall", caller);
                caller.EmitLocked("SaltyChat_EstablishedCall", player);
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #5
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
        public async Task denyCall(ClassicPlayer player)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0)
                {
                    return;
                }
                if (Characters.GetCharacterCurrentlyRecieveCaller(player.CharacterId) != 0)
                {
                    var           callerId     = Characters.GetCharacterCurrentlyRecieveCaller(player.CharacterId); //ID vom Spieler der Anruft
                    ClassicPlayer targetPlayer = (ClassicPlayer)Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x != null && x.Exists && ((ClassicPlayer)x).CharacterId == callerId);
                    if (targetPlayer != null && targetPlayer.Exists && targetPlayer.CharacterId > 0)
                    {
                        Characters.SetCharacterTargetPhoneNumber(targetPlayer.CharacterId, 0);
                        Characters.SetCharacterCurrentlyRecieveCallState(targetPlayer.CharacterId, 0);
                        targetPlayer.EmitLocked("Client:Smartphone:ShowPhoneCallError", 4);
                        //HUDHandler.SendNotification(targetPlayer, 3, 2000, "AnrufTry beendet");
                    }

                    Characters.SetCharacterCurrentlyRecieveCallState(player.CharacterId, 0);
                    Characters.SetCharacterTargetPhoneNumber(player.CharacterId, 0);
                    player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 4);
                    //HUDHandler.SendNotification(player, 3, 2000, "AnrufTry beendet");
                    return;
                }

                if (Characters.GetCharacterPhoneTargetNumber(player.CharacterId) != 0)
                {
                    var phoneNumber = Characters.GetCharacterPhoneTargetNumber(player.CharacterId);
                    if (!Characters.ExistPhoneNumber(phoneNumber))
                    {
                        return;
                    }
                    ClassicPlayer targetPlayer = (ClassicPlayer)Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x != null && x.Exists && ((ClassicPlayer)x).CharacterId > 0 && Characters.GetCharacterPhonenumber(((ClassicPlayer)x).CharacterId) == phoneNumber && Characters.GetCharacterPhoneTargetNumber(((ClassicPlayer)x).CharacterId) == Characters.GetCharacterPhonenumber(player.CharacterId));
                    if (targetPlayer != null && targetPlayer.Exists && targetPlayer.CharacterId > 0)
                    {
                        Characters.SetCharacterTargetPhoneNumber(targetPlayer.CharacterId, 0);
                        Characters.SetCharacterCurrentlyRecieveCallState(targetPlayer.CharacterId, 0);
                        targetPlayer.EmitLocked("SaltyChat_EndCall", player);
                        targetPlayer.EmitLocked("Client:Smartphone:ShowPhoneCallError", 4);
                        HUDHandler.SendNotification(targetPlayer, 3, 2000, "Anruf beendet");
                    }

                    Characters.SetCharacterTargetPhoneNumber(player.CharacterId, 0);
                    Characters.SetCharacterCurrentlyRecieveCallState(player.CharacterId, 0);
                    player.EmitLocked("SaltyChat_EndCall", targetPlayer);
                    player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 4);
                    HUDHandler.SendNotification(player, 3, 2000, "Anruf beendet");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #6
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
 public async Task addNewContact(ClassicPlayer player, string name, int contactNumber)
 {
     try
     {
         if (player == null || !player.Exists || contactNumber <= 0 || name == "" || player.CharacterId <= 0)
         {
             return;
         }
         int phoneNumber = Characters.GetCharacterPhonenumber(player.CharacterId);
         if (phoneNumber <= 0)
         {
             return;
         }
         if (CharactersPhone.ExistContactByName(phoneNumber, name) || CharactersPhone.ExistContactByNumber(phoneNumber, contactNumber))
         {
             player.EmitLocked("Client:Smartphone:showNotification", "Kontakt konnte nicht gespeichert werden.", "error", null, "error");
             return;
         }
         CharactersPhone.CreatePhoneContact(phoneNumber, name, contactNumber);
         requestPhoneContacts(player);
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
コード例 #7
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
 public async Task requestPoliceAppMostWanteds(ClassicPlayer player)
 {
     try
     {
         if (player == null || !player.Exists || player.CharacterId <= 0 || !ServerFactions.IsCharacterInAnyFaction(player.CharacterId) || !ServerFactions.IsCharacterInFactionDuty(player.CharacterId) || (ServerFactions.GetCharacterFactionId(player.CharacterId) != 2 && ServerFactions.GetCharacterFactionId(player.CharacterId) != 12))
         {
             return;
         }
         if (ServerFactions.GetCharacterFactionId(player.CharacterId) == 2 && ServerFactions.GetCharacterFactionRank(player.CharacterId) < 6)
         {
             HUDHandler.SendNotification(player, 3, 2500, "Keine Berechtigung: ab Rang 6."); return;
         }
         string mostWantedList = JsonConvert.SerializeObject(Characters.PlayerCharacters.ToList().Where(x => User.IsCharacterOnline(x.charId) && CharactersWanteds.HasCharacterWanteds(x.charId) && Characters.IsCharacterPhoneEquipped(x.charId)).Select(x => new
         {
             description = $"{x.charname} - {CharactersWanteds.GetCharacterWantedFinalJailTime(x.charId)} Hafteinheiten",
             posX        = $"{Characters.GetCharacterLastPosition(x.charId).X}",
             posY        = $"{Characters.GetCharacterLastPosition(x.charId).Y}",
         }).OrderBy(x => x.description).ToList());
         player.EmitLocked("Client:Smartphone:setPoliceAppMostWanteds", mostWantedList);
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
コード例 #8
0
 public async Task requestATMBankData(ClassicPlayer player, int accountNumber)
 {
     if (player == null || !player.Exists || player.CharacterId <= 0)
     {
         return;
     }
     player.EmitLocked("Client:ATM:BankATMSetRequestedData", CharactersBank.GetBankAccountMoney(accountNumber), ServerBankPapers.GetBankAccountBankPaper(player, accountNumber));
 }
コード例 #9
0
ファイル: CharactersPhone.cs プロジェクト: h04X-2K/ValeaRP
        public static void RequestChatJSON(ClassicPlayer player, int playerNumber)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0 || playerNumber <= 0)
                {
                    return;
                }
                var chats = CharactersPhoneChats_.ToList().Where(x => x.phoneNumber == playerNumber || x.anotherNumber == playerNumber).Select(x => new
                {
                    x.chatId,
                    from = x.phoneNumber,
                    to   = x.anotherNumber,
                    unix = GetLastMessageUnix(x.chatId),
                    text = GetLastMessageText(x.chatId),
                }).OrderByDescending(x => x.unix).ToList();

                var itemCount  = (int)chats.Count;
                var iterations = Math.Floor((decimal)(itemCount / 5));
                var rest       = itemCount % 5;

                for (var i = 0; i < iterations; i++)
                {
                    var skip = i * 5;
                    player.EmitLocked("Client:Smartphone:addChatJSON", JsonConvert.SerializeObject(chats.Skip(skip).Take(5).ToList()));
                }
                if (rest != 0)
                {
                    player.EmitLocked("Client:Smartphone:addChatJSON", JsonConvert.SerializeObject(chats.Skip((int)iterations * 5).ToList()));
                }
                player.EmitLocked("Client:Smartphone:setAllChats");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #10
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
        public static async Task requestChatMessages(ClassicPlayer player, int chatId)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0 || chatId <= 0)
                {
                    return;
                }
                var messages = CharactersPhone.CharactersPhoneChatMessages_.ToList().Where(x => x.chatId == chatId).Select(x => new
                {
                    x.id,
                    x.chatId,
                    from = x.fromNumber,
                    to   = x.toNumber,
                    x.unix,
                    text = x.message,
                }).OrderBy(x => x.unix).TakeLast(50).ToList();

                var itemCount  = (int)messages.Count;
                var iterations = Math.Floor((decimal)(itemCount / 5));
                var rest       = itemCount % 5;
                for (var i = 0; i < iterations; i++)
                {
                    var skip = i * 5;
                    player.EmitLocked("Client:Smartphone:addMessageJSON", JsonConvert.SerializeObject(messages.Skip(skip).Take(5).ToList()));
                }
                if (rest != 0)
                {
                    player.EmitLocked("Client:Smartphone:addMessageJSON", JsonConvert.SerializeObject(messages.Skip((int)iterations * 5).ToList()));
                }
                player.EmitLocked("Client:Smartphone:setAllMessages");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #11
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
 public async Task leaveRadioFrequence(ClassicPlayer player)
 {
     try
     {
         if (player == null || !player.Exists || player.CharacterId <= 0 || Characters.GetCharacterCurrentFunkFrequence(player.CharacterId) == null)
         {
             return;
         }
         string currentFrequence = Characters.GetCharacterCurrentFunkFrequence(player.CharacterId);
         Characters.SetCharacterCurrentFunkFrequence(player.CharacterId, null);
         player.EmitLocked("Client:Smartphone:setCurrentFunkFrequence", "null");
         Alt.Emit("Server:SaltyChat:leaveRadioFrequence", player, currentFrequence);
     }
     catch (Exception e)
     {
         Console.WriteLine($"{e}");
     }
 }
コード例 #12
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
        public async Task editContact(ClassicPlayer player, int contactId, string name, int contactNumber)
        {
            if (player == null || !player.Exists || player.CharacterId <= 0 || contactId <= 0 || name == "" || contactNumber <= 0)
            {
                return;
            }
            int phoneNumber = Characters.GetCharacterPhonenumber(player.CharacterId);

            if (phoneNumber <= 0)
            {
                return;
            }
            if (!CharactersPhone.ExistContactById(contactId, phoneNumber))
            {
                player.EmitLocked("Client:Smartphone:showNotification", "Kontakt konnte nicht bearbeitet werden.", "error", null, "error");
                return;
            }
            CharactersPhone.EditContact(contactId, contactNumber, name);
            requestPhoneContacts(player);
        }
コード例 #13
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
        public async Task SearchLSPDIntranetPeople(ClassicPlayer player, string name)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0 || string.IsNullOrWhiteSpace(name) || !ServerFactions.IsCharacterInAnyFaction(player.CharacterId) || !ServerFactions.IsCharacterInFactionDuty(player.CharacterId) || (ServerFactions.GetCharacterFactionId(player.CharacterId) != 2 && ServerFactions.GetCharacterFactionId(player.CharacterId) != 12))
                {
                    return;
                }
                var containedPlayers = Characters.PlayerCharacters.ToList().Where(x => x.charname.ToLower().Contains(name.ToLower()) && User.IsCharacterOnline(x.charId)).Select(x => new
                {
                    x.charId,
                    x.charname,
                }).OrderBy(x => x.charname).Take(15).ToList();

                player.EmitLocked("Client:Smartphone:SetLSPDIntranetSearchedPeople", JsonConvert.SerializeObject(containedPlayers));
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #14
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
        public static async Task requestLSPDIntranetPersonWanteds(ClassicPlayer player, int selectedCharId)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0 || selectedCharId <= 0 || !ServerFactions.IsCharacterInAnyFaction(player.CharacterId) || !ServerFactions.IsCharacterInFactionDuty(player.CharacterId) || (ServerFactions.GetCharacterFactionId(player.CharacterId) != 2 && ServerFactions.GetCharacterFactionId(player.CharacterId) != 12))
                {
                    return;
                }
                string wantedList = JsonConvert.SerializeObject(CharactersWanteds.CharactersWanteds_.Where(x => x.charId == selectedCharId).Select(x => new
                {
                    x.id,
                    x.wantedId,
                    x.givenString,
                }).ToList());

                player.EmitLocked("Client:Smartphone:setLSPDIntranetPersonWanteds", wantedList);
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #15
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
        public async Task sendChatMessage(ClassicPlayer player, int chatId, int phoneNumber, int targetPhoneNumber, int unix, string message)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0 || chatId <= 0 || phoneNumber <= 0 || targetPhoneNumber <= 0 || phoneNumber != Characters.GetCharacterPhonenumber(player.CharacterId) || !Characters.ExistPhoneNumber(targetPhoneNumber) || !CharactersPhone.ExistChatByNumbers(phoneNumber, targetPhoneNumber))
                {
                    return;
                }
                CharactersPhone.CreatePhoneChatMessage(chatId, phoneNumber, targetPhoneNumber, unix, message);
                requestChatMessages(player, chatId);

                ClassicPlayer targetPlayer = (ClassicPlayer)Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x != null && x.Exists && ((ClassicPlayer)x).CharacterId > 0 && Characters.GetCharacterPhonenumber(((ClassicPlayer)x).CharacterId) == targetPhoneNumber);
                if (targetPlayer == null || !targetPlayer.Exists)
                {
                    return;
                }
                targetPlayer.EmitLocked("Client:Smartphone:recieveNewMessage", chatId, phoneNumber, message);
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #16
0
ファイル: LoginHandler.cs プロジェクト: h04X-2K/ValeaRP
 public async Task OnPlayerConnect_Handler(ClassicPlayer player, string reason)
 {
     if (player == null || !player.Exists)
     {
         return;
     }
     AltAsync.Do(() =>
     {
         player.SetSyncedMetaData("PLAYER_SPAWNED", false);
         player.SetSyncedMetaData("ADMINLEVEL", 0);
         player.SetPlayerIsCuffed("handcuffs", false);
         player.SetPlayerIsCuffed("ropecuffs", false);
         setCefStatus(player, false);
     });
     player.SetPlayerCurrentMinijob("None");
     player.SetPlayerCurrentMinijobRouteId(0);
     player.SetPlayerCurrentMinijobStep("None");
     player.SetPlayerCurrentMinijobActionCount(0);
     player.SetPlayerFarmingActionMeta("None");
     User.SetPlayerOnline(player, 0);
     player.EmitLocked("Client:Pedcreator:spawnPed", ServerPeds.GetAllServerPeds());
     CreateLoginBrowser(player);
 }
コード例 #17
0
ファイル: LoginHandler.cs プロジェクト: h04X-2K/ValeaRP
        public async Task CharacterSelectedSpawnPlace(ClassicPlayer client, string spawnstr, string charcid)
        {
            if (client == null || !client.Exists || spawnstr == null || charcid == null)
            {
                return;
            }
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            int charid = Convert.ToInt32(charcid);

            if (charid <= 0)
            {
                return;
            }
            string charName = Characters.GetCharacterName(charid);
            await User.SetPlayerOnline(client, charid); //Online Feld = CharakterID

            client.CharacterId = charid;

            if (Characters.GetCharacterFirstJoin(charid) && Characters.GetCharacterFirstSpawnPlace(client, charid) == "unset")
            {
                Characters.SetCharacterFirstSpawnPlace(client, charid, spawnstr);
                CharactersInventory.AddCharacterItem(charid, "Bargeld", 10000, "inventory");
                CharactersInventory.AddCharacterItem(charid, "Tasche", 1, "inventory");
                Characters.SetCharacterBackpack(client, "Tasche");
                CharactersInventory.AddCharacterItem(charid, "Sandwich", 3, "backpack"); //ToDo: Trinken hinzufuegen
                CharactersInventory.AddCharacterItem(charid, "Tablet", 1, "inventory");
                CharactersInventory.AddCharacterItem(charid, "Smartphone", 1, "inventory");

                switch (spawnstr)
                {
                case "lsairport":
                    Characters.CreateCharacterLastPos(charid, Constants.Positions.SpawnPos_Airport, 0);
                    break;

                case "beach":
                    Characters.CreateCharacterLastPos(charid, Constants.Positions.SpawnPos_Beach, 0);
                    break;

                case "sandyshores":
                    Characters.CreateCharacterLastPos(charid, Constants.Positions.SpawnPos_SandyShores, 0);
                    break;

                case "paletobay":
                    Characters.CreateCharacterLastPos(charid, Constants.Positions.SpawnPos_PaletoBay, 0);
                    break;

                case null:
                    Characters.CreateCharacterLastPos(charid, Constants.Positions.SpawnPos_Airport, 0);
                    break;
                }
            }


            if (Characters.GetCharacterGender(charid))
            {
                client.Model = 0x9C9EFFD8;
            }
            else
            {
                client.Model = 0x705E61F2;
            }

            client.EmitLocked("Client:ServerBlips:LoadAllBlips", ServerBlips.GetAllServerBlips());
            client.EmitLocked("Client:ServerMarkers:LoadAllMarkers", ServerBlips.GetAllServerMarkers());
            client.EmitLocked("Client:SpawnArea:setCharSkin", Characters.GetCharacterSkin("facefeatures", charid), Characters.GetCharacterSkin("headblendsdata", charid), Characters.GetCharacterSkin("headoverlays", charid));
            Position dbPos = Characters.GetCharacterLastPosition(charid);

            client.Position = dbPos;
            client.Spawn(dbPos, 0);
            client.Dimension = Characters.GetCharacterLastDimension(charid);
            client.Health    = (ushort)(Characters.GetCharacterHealth(charid) + 100);
            client.Armor     = (ushort)Characters.GetCharacterArmor(charid);
            HUDHandler.CreateHUDBrowser(client); //HUD erstellen
            WeatherHandler.SetRealTime(client);  //Echtzeit setzen
            Characters.SetCharacterCorrectClothes(client);
            Characters.SetCharacterLastLogin(charid, DateTime.Now);
            Characters.SetCharacterCurrentFunkFrequence(charid, null);
            Alt.Log($"Eingeloggt {client.Name}");
            Alt.Emit("PlayerLoggedIn", client);
            client.EmitLocked("SaltyChat_OnConnected");
            if (Characters.IsCharacterUnconscious(charid))
            {
                DeathHandler.openDeathscreen(client);
            }
            if (Characters.IsCharacterFastFarm(charid))
            {
                var fastFarmTime = Characters.GetCharacterFastFarmTime(charid) * 60000;
                client.EmitLocked("Client:Inventory:PlayEffect", "DrugsMichaelAliensFight", fastFarmTime);
                HUDHandler.SendNotification(client, 2, 2000, $"Du bist durch dein Koks noch {fastFarmTime} Minuten effektiver.");
            }
            ServerAnimations.RequestAnimationMenuContent(client);
            if (Characters.IsCharacterPhoneEquipped(charid) && CharactersInventory.ExistCharacterItem(charid, "Smartphone", "inventory") && CharactersInventory.GetCharacterItemAmount(charid, "Smartphone", "inventory") > 0)
            {
                client.EmitLocked("Client:Smartphone:equipPhone", true, Characters.GetCharacterPhonenumber(charid), Characters.IsCharacterPhoneFlyModeEnabled(charid));
                Characters.SetCharacterPhoneEquipped(charid, true);
            }
            else if (!Characters.IsCharacterPhoneEquipped(charid) || !CharactersInventory.ExistCharacterItem(charid, "Smartphone", "inventory") || CharactersInventory.GetCharacterItemAmount(charid, "Smartphone", "inventory") <= 0)
            {
                client.EmitLocked("Client:Smartphone:equipPhone", false, Characters.GetCharacterPhonenumber(charid), Characters.IsCharacterPhoneFlyModeEnabled(charid));
                Characters.SetCharacterPhoneEquipped(charid, false);
            }
            SmartphoneHandler.RequestLSPDIntranet(client);
            await setCefStatus(client, false);

            AltAsync.Do(() => {
                client.SetStreamSyncedMetaData("sharedUsername", $"{charName} ({Characters.GetCharacterAccountId(charid)})");
                client.SetSyncedMetaData("ADMINLEVEL", client.AdminLevel());
                client.SetSyncedMetaData("PLAYER_SPAWNED", true);
            });

            if (Characters.IsCharacterInJail(charid))
            {
                HUDHandler.SendNotification(client, 1, 2500, $"Du befindest dich noch {Characters.GetCharacterJailTime(charid)} Minuten im Gefängnis.", 8000);
                client.Position = new Position(1691.4594f, 2565.7056f, 45.556763f);
                if (Characters.GetCharacterGender(charid) == false)
                {
                    client.EmitLocked("Client:SpawnArea:setCharClothes", 11, 5, 0);
                    client.EmitLocked("Client:SpawnArea:setCharClothes", 3, 5, 0);
                    client.EmitLocked("Client:SpawnArea:setCharClothes", 4, 7, 15);
                    client.EmitLocked("Client:SpawnArea:setCharClothes", 6, 7, 0);
                    client.EmitLocked("Client:SpawnArea:setCharClothes", 8, 1, 88);
                }
                else
                {
                }
            }
            client.updateTattoos();
            stopwatch.Stop();
            if (stopwatch.Elapsed.Milliseconds > 30)
            {
                Alt.Log($"{charid} - CharacterSelectedSpawnPlace benötigte {stopwatch.Elapsed.Milliseconds}ms");
            }
            await Task.Delay(5000);

            Model.ServerTattoos.GetAllTattoos(client);
        }
コード例 #18
0
        public static void openClothesShop(ClassicPlayer player, int id)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0 || !ServerClothesShops.ExistClothesShop(id))
                {
                    return;
                }
                int gender    = Convert.ToInt32(Characters.GetCharacterGender(player.CharacterId));
                var shopItems = ServerClothesShops.ServerClothesShopsItems_.ToList().Where(x => x.shopId == id && (ServerClothes.GetClothesGender(x.clothesName) == gender || ServerClothes.GetClothesGender(x.clothesName) == 2)).Select(x => new
                {
                    itemName = x.clothesName,
                    x.itemPrice,
                    clothesType = ServerClothes.GetClothesType(x.clothesName),
                    clothesDraw = ServerClothes.GetClothesDraw(x.clothesName),
                    clothesTex  = ServerClothes.GetClothesTexture(x.clothesName),
                }).ToList();

                var itemCount  = (int)shopItems.Count;
                var iterations = Math.Floor((decimal)(itemCount / 30));
                var rest       = itemCount % 30;
                for (var i = 0; i < iterations; i++)
                {
                    var skip = i * 30;
                    player.EmitLocked("Client:ClothesShop:sendItemsToClient", JsonConvert.SerializeObject(shopItems.Skip(skip).Take(30).ToList()));
                }
                if (rest != 0)
                {
                    player.EmitLocked("Client:ClothesShop:sendItemsToClient", JsonConvert.SerializeObject(shopItems.Skip((int)iterations * 30).ToList()));
                }

                var torsoItems = ServerClothes.ServerClothes_.ToList().Where(x => x.faction == 0 && x.gender == gender && (x.type == "Torso" || x.type == "Undershirt")).Select(x => new
                {
                    itemName    = x.clothesName,
                    itemPrice   = 0,
                    clothesType = x.type,
                    clothesDraw = x.draw,
                    clothesTex  = x.texture,
                }).ToList();

                var torsoCount      = (int)torsoItems.Count;
                var torsoIterations = Math.Floor((decimal)(torsoCount / 30));
                var torsoRest       = torsoCount % 30;
                for (var i = 0; i < torsoIterations; i++)
                {
                    var torsoSkip = i * 30;
                    player.EmitLocked("Client:ClothesShop:sendItemsToClient", JsonConvert.SerializeObject(torsoItems.Skip(torsoSkip).Take(30).ToList()));
                }
                if (rest != 0)
                {
                    player.EmitLocked("Client:ClothesShop:sendItemsToClient", JsonConvert.SerializeObject(torsoItems.Skip((int)torsoIterations * 30).ToList()));
                }


                player.EmitLocked("Client:ClothesShop:createCEF", id);
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #19
0
        public static void RequestClothesStorage(ClassicPlayer player, int storageId)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0 || storageId <= 0)
                {
                    return;
                }
                int storageFaction = GetStorageFaction(storageId);
                int gender         = Convert.ToInt32(Characters.GetCharacterGender(player.CharacterId));
                if (storageFaction > 0 && (!ServerFactions.IsCharacterInAnyFaction(player.CharacterId) || ServerFactions.GetCharacterFactionId(player.CharacterId) != storageFaction))
                {
                    return;
                }
                var userClothes = CharactersClothes.CharactersOwnedClothes_.ToList().Where(x => x.charId == player.CharacterId).Select(x => new
                {
                    x.clothesName,
                    clothesType = ServerClothes.GetClothesType(x.clothesName),
                    clothesDraw = ServerClothes.GetClothesDraw(x.clothesName),
                    clothesTex  = ServerClothes.GetClothesTexture(x.clothesName),
                }).ToList();

                var userCount  = (int)userClothes.Count;
                var iterations = Math.Floor((decimal)(userCount / 25));
                var rest       = userCount % 25;
                for (var i = 0; i < iterations; i++)
                {
                    var skip = i * 25;
                    player.EmitLocked("Client:ClothesStorage:sendItemsToClient", JsonConvert.SerializeObject(userClothes.Skip(skip).Take(25).ToList()));
                }
                if (rest != 0)
                {
                    player.EmitLocked("Client:ClothesStorage:sendItemsToClient", JsonConvert.SerializeObject(userClothes.Skip((int)iterations * 25).ToList()));
                }

                if (storageFaction > 0)
                {
                    var factionClothes = ServerFactionClothes_.ToList().Where(x => x.faction == storageFaction).Select(x => new
                    {
                        x.clothesName,
                        clothesType = ServerClothes.GetClothesType(x.clothesName),
                        clothesDraw = ServerClothes.GetClothesDraw(x.clothesName),
                        clothesTex  = ServerClothes.GetClothesTexture(x.clothesName),
                    }).ToList();
                    var factionCount      = (int)factionClothes.Count;
                    var factioniterations = Math.Floor((decimal)(factionCount / 25));
                    var factionrest       = factionCount % 25;
                    for (var i = 0; i < factioniterations; i++)
                    {
                        var factionskip = i * 25;
                        player.EmitLocked("Client:ClothesStorage:sendItemsToClient", JsonConvert.SerializeObject(factionClothes.Skip(factionskip).Take(25).ToList()));
                    }
                    if (factionrest != 0)
                    {
                        player.EmitLocked("Client:ClothesStorage:sendItemsToClient", JsonConvert.SerializeObject(factionClothes.Skip((int)factioniterations * 25).ToList()));
                    }
                }

                var availableClothes = ServerClothes.ServerClothes_.ToList().Where(x => x.type == "Torso" && x.gender == gender).Select(x => new
                {
                    x.clothesName,
                    clothesType = x.type,
                    clothesDraw = x.draw,
                    clothesTex  = x.texture,
                }).ToList();

                var torsoCount      = (int)availableClothes.Count;
                var torsoIterations = Math.Floor((decimal)(torsoCount / 25));
                var torsoRest       = torsoCount % 25;
                for (var i = 0; i < torsoIterations; i++)
                {
                    var torsoskip = i * 25;
                    player.EmitLocked("Client:ClothesStorage:sendItemsToClient", JsonConvert.SerializeObject(availableClothes.Skip(torsoskip).Take(25).ToList()));
                }
                if (torsoRest != 0)
                {
                    player.EmitLocked("Client:ClothesStorage:sendItemsToClient", JsonConvert.SerializeObject(availableClothes.Skip((int)torsoIterations * 25).ToList()));
                }

                player.EmitLocked("Client:ClothesStorage:createCEF");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #20
0
ファイル: InventoryHandler.cs プロジェクト: h04X-2K/ValeaRP
        public async Task UseItem(ClassicPlayer player, string itemname, int itemAmount, string fromContainer)
        {
            try
            {
                string ECData     = null,
                       CarKeyData = null;
                if (player == null || !player.Exists || itemname == "" || itemAmount <= 0 || fromContainer == "" || User.GetPlayerOnline(player) == 0)
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                if (ServerItems.IsItemUseable(ServerItems.ReturnNormalItemName(itemname)) == false)
                {
                    HUDHandler.SendNotification(player, 4, 5000, $"Dieser Gegenstand ist nicht benutzbar ({itemname})!"); return;
                }
                int charId = player.CharacterId;
                if (charId <= 0 || CharactersInventory.ExistCharacterItem(charId, itemname, fromContainer) == false)
                {
                    return;
                }
                if (CharactersInventory.GetCharacterItemAmount(charId, itemname, fromContainer) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 4, 5000, $"Die angegeben zu nutzende Anzahl ist nicht vorhanden ({itemname})!"); return;
                }
                if (itemname.Contains("EC Karte"))
                {
                    string[] SplittedItemName = itemname.Split(' '); ECData = itemname.Replace("EC Karte ", ""); itemname = "EC Karte";
                }
                else if (itemname.Contains("Fahrzeugschluessel"))
                {
                    string[] SplittedItemName = itemname.Split(' '); CarKeyData = itemname.Replace("Fahrzeugschluessel ", ""); itemname = "Autoschluessel";
                }

                if (ServerItems.IsItemDesire(itemname))
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                    Characters.SetCharacterHunger(charId, Characters.GetCharacterHunger(charId) + ServerItems.GetItemDesireFood(itemname) * itemAmount);
                    Characters.SetCharacterThirst(charId, Characters.GetCharacterThirst(charId) + ServerItems.GetItemDesireDrink(itemname) * itemAmount);
                    player.EmitLocked("Client:HUD:UpdateDesire", Characters.GetCharacterHunger(charId), Characters.GetCharacterThirst(charId)); //HUD updaten
                }
                else if (itemname == "Beamtenschutzweste")
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Beamtenschutzweste", 1, fromContainer);
                    Characters.SetCharacterArmor(charId, 100);
                    player.Armor = 100;
                }
                if (itemname == "Rucksack" || itemname == "Tasche")
                {
                    if (fromContainer == "backpack")
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Kleidungen & Taschen können nicht aus dem Rucksack aus benutzt werden."); return;
                    }
                    if (Characters.GetCharacterBackpack(charId) == "Rucksack")
                    {
                        if (itemname == "Rucksack")
                        {
                            if (CharactersInventory.GetCharacterBackpackItemCount(charId) == 0)
                            {
                                Characters.SetCharacterBackpack(player, "None");
                                HUDHandler.SendNotification(player, 2, 5000, "Du hast deinen Rucksack ausgezogen.");
                            }
                            else
                            {
                                HUDHandler.SendNotification(player, 4, 5000, "Du hast zuviele Sachen im Rucksack, du kannst deinen Rucksack nicht ablegen.");
                            }
                        }
                        else
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Du hast bereits eine Tasche angelegt, lege diese vorher ab um deinen Rucksack anzulegen.");
                        }
                    }
                    else if (Characters.GetCharacterBackpack(charId) == "Tasche")
                    {
                        if (itemname == "Tasche")
                        {
                            if (CharactersInventory.GetCharacterBackpackItemCount(charId) == 0)
                            {
                                Characters.SetCharacterBackpack(player, "None");
                                HUDHandler.SendNotification(player, 2, 5000, "Du hast deine Tasche ausgezogen.");
                            }
                            else
                            {
                                HUDHandler.SendNotification(player, 4, 5000, "Du hast zuviele Sachen in deiner Tasche, du kannst deine Tasche nicht ablegen.");
                            }
                        }
                        else
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Du hast bereits einen Rucksack angelegt, lege diesen vorher ab um deine Tasche anzulegen.");
                        }
                    }
                    else if (Characters.GetCharacterBackpack(charId) == "None")
                    {
                        Characters.SetCharacterBackpack(player, itemname);
                        HUDHandler.SendNotification(player, 2, 5000, "Du hast deine Tasche / deinen Rucksack angezogen.");
                    }
                }
                else if (itemname == "EC Karte")
                {
                    var atmPos = ServerATM.ServerATM_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 1f));
                    if (atmPos == null || player.IsInVehicle)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Du bist an keinem ATM oder sitzt in einem Auto."); return;
                    }
                    int usingAccountNumber = Convert.ToInt32(ECData);
                    if (CharactersBank.GetBankAccountLockStatus(usingAccountNumber))
                    {
                        if (CharactersInventory.ExistCharacterItem(charId, "EC Karte " + usingAccountNumber, "inventory"))
                        {
                            CharactersInventory.RemoveCharacterItemAmount(charId, "EC Karte " + usingAccountNumber, 1, "inventory");
                        }
                        HUDHandler.SendNotification(player, 3, 5000, $"Ihre EC Karte wurde einzogen da diese gesperrt ist."); return;
                    }
                    player.EmitLocked("Client:ATM:BankATMcreateCEF", CharactersBank.GetBankAccountPIN(usingAccountNumber), usingAccountNumber, atmPos.zoneName);
                }
                else if (ServerItems.GetItemType(itemname) == "weapon")
                {
                    if (itemname.Contains("Munitionsbox"))
                    {
                        string wName = itemname.Replace(" Munitionsbox", "");
                        CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                        CharactersInventory.AddCharacterItem(charId, $"{wName} Munition", 30 * itemAmount, fromContainer);
                    }
                    else if (itemname.Contains("Munition"))
                    {
                        WeaponHandler.EquipCharacterWeapon(player, "Ammo", itemname, itemAmount, fromContainer);
                    }
                    else
                    {
                        WeaponHandler.EquipCharacterWeapon(player, "Weapon", itemname, 0, fromContainer);
                    }
                }
                else if (itemname == "Brecheisen")
                {
                    var house = ServerHouses.ServerHouses_.FirstOrDefault(x => x.ownerId > 0 && x.isLocked && ((ClassicColshape)x.entranceShape).IsInRange((ClassicPlayer)player));
                    if (house != null)
                    {
                        HouseHandler.BreakIntoHouse(player, house.id);
                        return;
                    }
                }
                else if (itemname == "Verbandskasten")
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Verbandskasten", 1, fromContainer);
                    Characters.SetCharacterHealth(charId, 200);
                    player.Health = 200;
                }
                else if (itemname == "Benzinkanister" && player.IsInVehicle && player.Vehicle.Exists)
                {
                    if (ServerVehicles.GetVehicleFuel(player.Vehicle) >= ServerVehicles.GetVehicleFuelLimitOnHash(player.Vehicle.Model))
                    {
                        HUDHandler.SendNotification(player, 4, 2000, "Der Tank ist bereits voll."); return;
                    }
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Benzinkanister", 1, fromContainer);
                    ServerVehicles.SetVehicleFuel(player.Vehicle, ServerVehicles.GetVehicleFuel(player.Vehicle) + 15.0f);
                    HUDHandler.SendNotification(player, 2, 2000, "Du hast das Fahrzeug erfolgreich aufgetankt.");
                }
                else if (itemname == "Weste")
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Weste", 1, fromContainer);
                    Characters.SetCharacterArmor(charId, 100);
                    player.Armor = 100;
                    if (Characters.GetCharacterGender(charId))
                    {
                        player.EmitLocked("Client:SpawnArea:setCharClothes", 9, 17, 2);
                    }
                    else
                    {
                        player.EmitLocked("Client:SpawnArea:setCharClothes", 9, 15, 2);
                    }
                }
                else if (itemname == "Pedalo")
                {
                    HUDHandler.SendNotification(player, 1, 3500, "Bruder muss los..");
                    player.EmitLocked("Client:Ragdoll:SetPedToRagdoll", true, 0);  //Ragdoll setzen
                    player.EmitLocked("Client:Ragdoll:SetPedToRagdoll", false, 0); //Ragdoll setzen
                }
                else if (itemname == "Kokain")
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Kokain", 1, fromContainer);
                    HUDHandler.SendNotification(player, 2, 2000, "Du hast Koks gezogen du bist nun 15 Minuten effektiver.");
                    player.EmitLocked("Client:Inventory:PlayEffect", "DrugsMichaelAliensFight", 900000);
                    Characters.SetCharacterFastFarm(charId, true, 15);
                }
                else if (itemname == "Joint")
                {
                    if (player.Armor >= 60)
                    {
                        HUDHandler.SendNotification(player, 3, 2000, "Weiter kannst du dich nicht selbst heilen."); return;
                    }
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Joint", 1, fromContainer);
                    Characters.SetCharacterArmor(charId, 15);
                    player.Armor = +15;
                }
                else if (itemname == "Smartphone")
                {
                    Alt.Log("Phone benutzt.");
                    if (Characters.IsCharacterPhoneEquipped(charId))
                    {
                        Alt.Log("Phone benutzt2.");
                        player.EmitLocked("Client:Smartphone:equipPhone", false, Characters.GetCharacterPhonenumber(charId), Characters.IsCharacterPhoneFlyModeEnabled(charId));
                        HUDHandler.SendNotification(player, 2, 1500, "Smartphone ausgeschaltet.");
                    }
                    else
                    {
                        Alt.Log("Phone benutzt3.");
                        player.EmitLocked("Client:Smartphone:equipPhone", true, Characters.GetCharacterPhonenumber(charId), Characters.IsCharacterPhoneFlyModeEnabled(charId));
                        HUDHandler.SendNotification(player, 2, 1500, "Smartphone eingeschaltet.");
                    }
                    Characters.SetCharacterPhoneEquipped(charId, !Characters.IsCharacterPhoneEquipped(charId));
                    SmartphoneHandler.RequestLSPDIntranet((ClassicPlayer)player);
                }

                if (ServerItems.hasItemAnimation(ServerItems.ReturnNormalItemName(itemname)))
                {
                    InventoryAnimation(player, ServerItems.GetItemAnimationName(ServerItems.ReturnNormalItemName(itemname)), 0);
                }

                RequestInventoryItems(player);
                //HUDHandler.SendNotification(player, 2, 5000, $"DEBUG: Der Gegenstand {itemname} ({itemAmount}) wurde erfolgreich aus ({fromContainer}) benutzt.");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #21
0
ファイル: SmartphoneHandler.cs プロジェクト: h04X-2K/ValeaRP
        public async Task tryCall(ClassicPlayer player, int targetPhoneNumber)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0 || targetPhoneNumber <= 0 || !CharactersInventory.ExistCharacterItem(player.CharacterId, "Smartphone", "inventory") || CharactersInventory.GetCharacterItemAmount(player.CharacterId, "Smartphone", "inventory") <= 0 || !Characters.IsCharacterPhoneEquipped(player.CharacterId) || Characters.IsCharacterPhoneFlyModeEnabled(player.CharacterId) || Characters.GetCharacterPhonenumber(player.CharacterId) <= 0 || Characters.IsCharacterUnconscious(player.CharacterId) || player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs() || Characters.GetCharacterCurrentlyRecieveCaller(player.CharacterId) != 0 || Characters.GetCharacterPhoneTargetNumber(player.CharacterId) != 0)
                {
                    return;
                }
                if (ServerFactions.IsNumberAFactionNumber(targetPhoneNumber))
                {
                    int factionId = ServerFactions.GetFactionIdByServiceNumber(targetPhoneNumber);
                    if (factionId <= 0)
                    {
                        player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 1); return;
                    }
                    int currentOwnerId = ServerFactions.GetCurrentServicePhoneOwner(factionId);
                    if (currentOwnerId <= 0)
                    {
                        player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 2); return;
                    }

                    ClassicPlayer targetServicePlayer = (ClassicPlayer)Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x != null && x.Exists && ((ClassicPlayer)x).CharacterId == currentOwnerId);
                    if (targetServicePlayer == null || !targetServicePlayer.Exists || !Characters.IsCharacterPhoneEquipped(currentOwnerId) || Characters.IsCharacterPhoneFlyModeEnabled(currentOwnerId))
                    {
                        ServerFactions.sendMsg(factionId, "Da die Leitstelle nicht erreichbar war, wurde die Nummer zurückgesetzt. Jemand anderes sollte die Leitstelle nun übernehmen.");
                        ServerFactions.UpdateCurrentServicePhoneOwner(factionId, 0);
                        player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 2);
                        return;
                    }
                    targetPhoneNumber = Characters.GetCharacterPhonenumber(currentOwnerId);
                    if (!Characters.ExistPhoneNumber(targetPhoneNumber))
                    {
                        ServerFactions.sendMsg(factionId, "Da die Leitstelle nicht erreichbar war, wurde die Nummer zurückgesetzt. Jemand anderes sollte die Leitstelle nun übernehmen."); ServerFactions.UpdateCurrentServicePhoneOwner(factionId, 0); player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 2); return;
                    }
                    if (Characters.GetCharacterPhoneTargetNumber(currentOwnerId) != 0 || Characters.GetCharacterCurrentlyRecieveCaller(currentOwnerId) != 0)
                    {
                        player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 3);
                        return;
                    }
                    Characters.SetCharacterCurrentlyRecieveCallState(currentOwnerId, player.CharacterId);
                    Characters.SetCharacterCurrentlyRecieveCallState(player.CharacterId, currentOwnerId);
                    targetServicePlayer.EmitLocked("Client:Smartphone:showPhoneReceiveCall", Characters.GetCharacterPhonenumber(player.CharacterId));
                    return;
                }

                if (!Characters.ExistPhoneNumber(targetPhoneNumber))
                {
                    player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 1);
                    //HUDHandler.SendNotification(player, 4, 2500, "Kein Anschluss unter dieser Nummer..");
                    return;
                }

                ClassicPlayer targetPlayer = (ClassicPlayer)Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x != null && x.Exists && ((ClassicPlayer)x).CharacterId > 0 && Characters.GetCharacterPhonenumber(((ClassicPlayer)x).CharacterId) == targetPhoneNumber);
                if (targetPlayer == null || !targetPlayer.Exists || !Characters.IsCharacterPhoneEquipped(targetPlayer.CharacterId) || Characters.IsCharacterPhoneFlyModeEnabled(targetPlayer.CharacterId))
                {
                    player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 2);
                    //HUDHandler.SendNotification(player, 4, 2500, "Der angerufene Teilnehmer ist nicht erreichbar..");
                    return;
                }

                if (Characters.GetCharacterPhoneTargetNumber(targetPlayer.CharacterId) != 0 || Characters.GetCharacterCurrentlyRecieveCaller(targetPlayer.CharacterId) != 0)
                {
                    player.EmitLocked("Client:Smartphone:ShowPhoneCallError", 3);
                    //HUDHandler.SendNotification(player, 4, 2500, "Der angegebene Anschluss ist besetzt..");
                    return;
                }

                //Characters.SetCharacterTargetPhoneNumber(player.CharacterId, targetPhoneNumber);
                Characters.SetCharacterCurrentlyRecieveCallState(targetPlayer.CharacterId, player.CharacterId);
                Characters.SetCharacterCurrentlyRecieveCallState(player.CharacterId, targetPlayer.CharacterId);
                targetPlayer.EmitLocked("Client:Smartphone:showPhoneReceiveCall", Characters.GetCharacterPhonenumber(player.CharacterId));
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
コード例 #22
0
ファイル: InventoryHandler.cs プロジェクト: h04X-2K/ValeaRP
        public async Task GiveItem(ClassicPlayer player, string itemname, int itemAmount, string fromContainer, int targetPlayerId)
        {
            try
            {
                if (player == null || !player.Exists || itemname == "" || itemAmount <= 0 || fromContainer == "" || targetPlayerId == 0)
                {
                    return;
                }
                player.EmitLocked("Client:Inventory:closeCEF");
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                if (!ServerItems.IsItemGiveable(itemname))
                {
                    HUDHandler.SendNotification(player, 4, 5000, $"Diesen Gegenstand kannst du nicht weggeben ({itemname})."); return;
                }
                int charId = player.CharacterId;
                if (charId <= 0 || !CharactersInventory.ExistCharacterItem(charId, itemname, fromContainer))
                {
                    return;
                }
                if (CharactersInventory.GetCharacterItemAmount(charId, itemname, fromContainer) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 4, 5000, $"Die angegebene Anzahl ist nicht vorhanden ({itemname})."); return;
                }
                if (CharactersInventory.IsItemActive(player, itemname))
                {
                    HUDHandler.SendNotification(player, 4, 5000, $"Ausgerüstete Gegenstände können nicht abgegeben werden."); return;
                }
                float itemWeight     = ServerItems.GetItemWeight(itemname) * itemAmount;
                float invWeight      = CharactersInventory.GetCharacterItemWeight(targetPlayerId, "inventory");
                float backpackWeight = CharactersInventory.GetCharacterItemWeight(targetPlayerId, "backpack");
                var   targetPlayer   = Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x.GetCharacterMetaId() == (ulong)targetPlayerId);
                if (targetPlayer == null)
                {
                    return;
                }
                if (!player.Position.IsInRange(targetPlayer.Position, 5f))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Die Person ist zu weit entfernt."); return;
                }
                if (invWeight + itemWeight > 15f && backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(targetPlayerId)))
                {
                    HUDHandler.SendNotification(player, 3, 5000, $"Der Spieler hat nicht genug Platz in seinen Taschen."); return;
                }
                if (invWeight + itemWeight <= 15f)
                {
                    HUDHandler.SendNotification(targetPlayer, 1, 5000, $"Eine Person hat dir den Gegenstand {itemname} ({itemAmount}x) gegeben.");
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast einem Spieler den Gegenstand {itemname} ({itemAmount}x) gegeben.");
                    CharactersInventory.AddCharacterItem(targetPlayerId, itemname, itemAmount, "inventory");
                    CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                    InventoryAnimation(player, "give", 0);
                    return;
                }

                if (Characters.GetCharacterBackpack(targetPlayerId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(targetPlayerId)))
                {
                    HUDHandler.SendNotification(targetPlayer, 1, 5000, $"Eine Person hat dir den Gegenstand {itemname} ({itemAmount}x) gegeben.");
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast einem Spieler den Gegenstand {itemname} ({itemAmount}x) gegeben.");
                    CharactersInventory.AddCharacterItem(targetPlayerId, itemname, itemAmount, "backpack");
                    CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                    InventoryAnimation(player, "give", 0);
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }