Exemplo n.º 1
0
        public async Task robShop(ClassicPlayer player, int shopId)
        {
            try
            {
                if (player == null || !player.Exists || player.CharacterId <= 0 || shopId <= 0)
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                if (!player.Position.IsInRange(ServerShops.GetShopPosition(shopId), 3f))
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Du bist zu weit entfernt."); return;
                }
                if (player.isRobbingAShop)
                {
                    HUDHandler.SendNotification(player, 4, 2500, "Du raubst bereits einen Shop aus.");
                    return;
                }

                if (ServerShops.IsShopRobbedNow(shopId))
                {
                    HUDHandler.SendNotification(player, 3, 2500, "Dieser Shop wird bereits ausgeraubt.");
                    return;
                }

                ServerFactions.AddNewFactionDispatch(0, 2, $"Aktiver Shopraub", player.Position);
                ServerFactions.AddNewFactionDispatch(0, 12, $"Aktiver Shopraub", player.Position);

                ServerShops.SetShopRobbedNow(shopId, true);
                player.isRobbingAShop = true;
                //HUDHandler.SendNotification(player, 1, 2500, "Du raubst den Laden nun aus - warte 8 Minuten um das Geld zu erhalten.");
                HUDHandler.SendNotification(player, 1, 2500, "Du raubst den Laden nun aus - warte 30 Sekunden um das Geld zu erhalten.");
                //await Task.Delay(480000);
                await Task.Delay(30000);

                ServerShops.SetShopRobbedNow(shopId, false);
                if (player == null || !player.Exists)
                {
                    return;
                }
                player.isRobbingAShop = false;
                if (!player.Position.IsInRange(ServerShops.GetShopPosition(shopId), 12f))
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Du bist zu weit entfernt, der Raub wurde abgebrochen.");
                    return;
                }

                int amount = new Random().Next(6000, 9000);
                HUDHandler.SendNotification(player, 2, 2500, $"Shop ausgeraubt - du erhälst {amount}$.");
                CharactersInventory.AddCharacterItem(player.CharacterId, "Bargeld", amount, "inventory");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Exemplo n.º 2
0
        public async Task switchItemToDifferentInv(ClassicPlayer player, string itemname, int itemAmount, string fromContainer, string toContainer)
        {
            try
            {
                if (player == null || !player.Exists || itemname == "" || itemAmount <= 0 || fromContainer == "" || toContainer == "" || User.GetPlayerOnline(player) == 0)
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                int    charId         = player.CharacterId;
                string normalName     = ServerItems.ReturnNormalItemName(itemname);
                float  itemWeight     = ServerItems.GetItemWeight(itemname) * itemAmount;
                float  invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
                float  backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                if (!CharactersInventory.ExistCharacterItem(charId, itemname, fromContainer))
                {
                    return;
                }

                if (toContainer == "inventory")
                {
                    if (invWeight + itemWeight > 15f)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, $"Soviel Platz hast du im Inventar nicht."); return;
                    }
                }
                else if (toContainer == "backpack")
                {
                    if (backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                    {
                        HUDHandler.SendNotification(player, 3, 5000, $"Soviel Platz hast du in deinen Taschen / deinem Rucksack nicht."); return;
                    }
                }

                if (CharactersInventory.GetCharacterItemAmount(charId, itemname, fromContainer) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Die angegebene Item-Anzahl ist größer als die Anzahl der Items die du mit dir trägst."); return;
                }
                if (itemname == "Rucksack" || itemname == "Tasche" || normalName == "Ausweis" || normalName == "Bargeld" || normalName == "Smartphone" || normalName == "EC Karte" || normalName == "Fahrzeugschluessel")
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Diesen Gegenstand kannst du nicht in deinen Rucksack / deine Tache legen."); return;
                }
                CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                CharactersInventory.AddCharacterItem(charId, itemname, itemAmount, toContainer);
                HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand {itemname} ({itemAmount}x) wurde erfolgreich vom ({fromContainer}) in ({toContainer}) verschoben.");
                RequestInventoryItems(player);
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Exemplo n.º 3
0
 public async Task requestSmartphoneChats(ClassicPlayer player)
 {
     try
     {
         if (player == null || !player.Exists || player.CharacterId <= 0 || Characters.IsCharacterPhoneFlyModeEnabled(player.CharacterId) || Characters.IsCharacterUnconscious(player.CharacterId) || player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
         {
             return;
         }
         int playerNumber = Characters.GetCharacterPhonenumber(player.CharacterId);
         if (!Characters.ExistPhoneNumber(playerNumber))
         {
             return;
         }
         CharactersPhone.RequestChatJSON(player, playerNumber);
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Exemplo n.º 4
0
        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}");
            }
        }
Exemplo n.º 5
0
        public async Task PlayerSearchTakeItem(ClassicPlayer player, int givenTargetCharId, string itemName, string itemLocation, int itemAmount)
        {
            try
            {
                if (player == null || !player.Exists || givenTargetCharId <= 0 || itemName == "" || itemAmount <= 0 || itemLocation == "")
                {
                    return;
                }
                int charId = player.CharacterId;
                if (charId <= 0)
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                var targetPlayer = Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x.GetCharacterMetaId() == (ulong)givenTargetCharId);
                int targetCharId = (int)targetPlayer.GetCharacterMetaId();
                if (targetCharId != givenTargetCharId)
                {
                    return;
                }
                if (targetPlayer == null || !targetPlayer.Exists)
                {
                    return;
                }
                if (!player.Position.IsInRange(targetPlayer.Position, 3f))
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Fehler: Du bist zuweit vom Spieler entfernt."); return;
                }
                if (!targetPlayer.HasPlayerHandcuffs() && !targetPlayer.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Der Spieler ist nicht gefesselt."); return;
                }
                if (!ServerItems.IsItemDroppable(itemName) || !ServerItems.IsItemGiveable(itemName))
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Fehler: Diesen Gegenstand kannst du nicht entfernen."); return;
                }
                if (!CharactersInventory.ExistCharacterItem(targetCharId, itemName, itemLocation))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Dieser Gegenstand existiert nicht mehr."); return;
                }
                if (CharactersInventory.IsItemActive(targetPlayer, itemName))
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Ausgerüstete Gegenstände können nicht entwendet werden."); return;
                }
                if (CharactersInventory.GetCharacterItemAmount(targetCharId, itemName, itemLocation) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Fehler: Soviele Gegenstände hat der Spieler davon nicht."); return;
                }
                float itemWeight     = ServerItems.GetItemWeight(itemName) * itemAmount;
                float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
                float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                if (invWeight + itemWeight > 15f && backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                {
                    HUDHandler.SendNotification(player, 3, 5000, $"Du hast nicht genug Platz in deinen Taschen."); return;
                }
                CharactersInventory.RemoveCharacterItemAmount(targetCharId, itemName, itemAmount, itemLocation);
                if (invWeight + itemWeight <= 15f || itemName == "Bargeld" || itemWeight == 0f)
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast der Person {itemName} ({itemAmount}x) entwendet. (Lagerort: Inventar).");
                    HUDHandler.SendNotification(targetPlayer, 2, 5000, $"Dir wurde der Gegenstand {itemName} ({itemAmount}x) aus dem Inventar entwendet.");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "inventory");
                    return;
                }

                if (Characters.GetCharacterBackpack(charId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast der Person {itemName} ({itemAmount}x) entwendet. (Lagerort: Rucksack/Tasche).");
                    HUDHandler.SendNotification(targetPlayer, 2, 5000, $"Dir wurde der Gegenstand {itemName} ({itemAmount}x) aus dem Rucksack entwendet.");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "backpack");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Exemplo n.º 6
0
        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}");
            }
        }
Exemplo n.º 7
0
 public async Task DropItem(ClassicPlayer player, string itemname, int itemAmount, string fromContainer)
 {
     try
     {
         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;
         }
         string normalItemName = ServerItems.ReturnNormalItemName(itemname);
         if (ServerItems.IsItemDroppable(itemname) == false)
         {
             HUDHandler.SendNotification(player, 4, 5000, $"Diesen Gegenstand kannst du nicht wegwerfen ({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 angegebene wegzuwerfende Anzahl ist nicht vorhanden ({itemname})."); return;
         }
         if (itemname == "Smartphone")
         {
             if (Characters.IsCharacterPhoneEquipped(charId))
             {
                 HUDHandler.SendNotification(player, 3, 2500, "Du musst dein Handy erst ausschalten / ablegen."); return;
             }
         }
         else if (itemname == "Rucksack")
         {
             if (Characters.GetCharacterBackpack(charId) == "Rucksack")
             {
                 if (CharactersInventory.GetCharacterItemAmount(charId, "Rucksack", "inventory") == itemAmount)
                 {
                     HUDHandler.SendNotification(player, 3, 5000, "Du musst deinen Rucksack erst ablegen, bevor du diesen wegwerfen kannst.");
                     return;
                 }
                 else
                 {
                     CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                     InventoryAnimation(player, "drop", 0);
                     HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand {itemname} ({itemAmount}) wurde erfolgreich weggeworfen ({fromContainer}).");
                     return;
                 }
             }
             else
             {
                 CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                 InventoryAnimation(player, "drop", 0);
                 HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand {itemname} ({itemAmount}) wurde erfolgreich weggeworfen ({fromContainer}).");
                 return;
             }
         }
         else if (itemname == "Tasche")
         {
             if (Characters.GetCharacterBackpack(charId) == "Tasche")
             {
                 if (CharactersInventory.GetCharacterItemAmount(charId, "Tasche", "inventory") == itemAmount)
                 {
                     HUDHandler.SendNotification(player, 3, 5000, "Du musst zuerst deine Tasche ablegen, bevor du diese wegwerfen kannst.");
                     return;
                 }
                 else
                 {
                     CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                     InventoryAnimation(player, "drop", 0);
                     HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand {itemname} ({itemAmount}) wurde erfolgreich weggeworfen ({fromContainer}).");
                     RequestInventoryItems(player);
                     return;
                 }
             }
             else
             {
                 CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                 InventoryAnimation(player, "drop", 0);
                 HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand {itemname} ({itemAmount}) wurde erfolgreich weggeworfen ({fromContainer}).");
                 RequestInventoryItems(player);
                 return;
             }
         }
         else if (ServerItems.GetItemType(itemname) == "weapon")
         {
             if ((string)Characters.GetCharacterWeapon(player, "PrimaryWeapon") == normalItemName || (string)Characters.GetCharacterWeapon(player, "SecondaryWeapon") == normalItemName || (string)Characters.GetCharacterWeapon(player, "SecondaryWeapon2") == normalItemName || (string)Characters.GetCharacterWeapon(player, "FistWeapon") == normalItemName)
             {
                 if (CharactersInventory.GetCharacterItemAmount(charId, normalItemName, fromContainer) == itemAmount)
                 {
                     HUDHandler.SendNotification(player, 3, 5000, "Du musst zuerst deine Waffe ablegen."); return;
                 }
             }
         }
         CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
         InventoryAnimation(player, "drop", 0);
         HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand {itemname} ({itemAmount}) wurde erfolgreich weggeworfen ({fromContainer}).");
         RequestInventoryItems(player);
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Exemplo n.º 8
0
        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}");
            }
        }
Exemplo n.º 9
0
        public async Task VehicleTrunkStorageItem(ClassicPlayer player, int vehId, int charId, string itemName, int itemAmount, string fromContainer, string type)
        {
            try
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                if (player == null || !player.Exists || vehId <= 0 || charId <= 0 || itemName == "" || itemAmount <= 0 || fromContainer == "none" || fromContainer == "")
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                if (type != "trunk" && type != "glovebox")
                {
                    return;
                }
                int cCharId = player.CharacterId;
                if (cCharId != charId)
                {
                    return;
                }
                var targetVehicle = Alt.Server.GetVehicles().ToList().FirstOrDefault(x => x.GetVehicleId() == (ulong)vehId);
                if (targetVehicle == null || !targetVehicle.Exists)
                {
                    return;
                }
                if (!player.Position.IsInRange(targetVehicle.Position, 5f))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist zu weit entfernt."); return;
                }
                if (type == "trunk")
                {
                    if (player.IsInVehicle)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Wie willst du von Innen an den Kofferraum kommen?"); return;
                    }
                    if (!targetVehicle.GetVehicleTrunkState())
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Der Kofferraum ist nicht geöffnet."); return;
                    }
                }
                else if (type == "glovebox")
                {
                    if (!player.IsInVehicle)
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist in keinem Fahrzeug."); return;
                    }
                }
                if (!CharactersInventory.ExistCharacterItem(charId, itemName, fromContainer))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Diesen Gegenstand besitzt du nicht."); return;
                }
                if (CharactersInventory.GetCharacterItemAmount(charId, itemName, fromContainer) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du hast nicht genügend Gegenstände davon dabei."); return;
                }
                if (CharactersInventory.IsItemActive(player, itemName))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Ausgerüstete Gegenstände können nicht umgelagert werden."); return;
                }
                float itemWeight   = ServerItems.GetItemWeight(itemName) * itemAmount;
                float curVehWeight = 0f;
                float maxVehWeight = 0f;

                if (type == "trunk")
                {
                    curVehWeight = ServerVehicles.GetVehicleVehicleTrunkWeight(vehId, false);
                    maxVehWeight = ServerVehicles.GetVehicleTrunkCapacityOnHash(targetVehicle.Model);
                }
                else if (type == "glovebox")
                {
                    curVehWeight = ServerVehicles.GetVehicleVehicleTrunkWeight(vehId, true);
                    maxVehWeight = 5f;
                }

                if (curVehWeight + itemWeight > maxVehWeight)
                {
                    HUDHandler.SendNotification(player, 3, 5000, $"Fehler: Soviel passt hier nicht rein (Aktuell: {curVehWeight} |  Maximum: {maxVehWeight})."); return;
                }
                CharactersInventory.RemoveCharacterItemAmount(charId, itemName, itemAmount, fromContainer);

                if (type == "trunk")
                {
                    ServerVehicles.AddVehicleTrunkItem(vehId, itemName, itemAmount, false);
                    HUDHandler.SendNotification(player, 2, 2500, $"Du hast den Gegenstand '{itemName} ({itemAmount}x)' in den Kofferraum gelegt.");
                    stopwatch.Stop();
                    Alt.Log($"{charId} - VehicleTrunkStorageItem benötigte {stopwatch.Elapsed.Milliseconds}ms");
                    return;
                }
                else if (type == "glovebox")
                {
                    ServerVehicles.AddVehicleTrunkItem(vehId, itemName, itemAmount, true);
                    HUDHandler.SendNotification(player, 2, 2500, $"Du hast den Gegenstand '{itemName} ({itemAmount}x)' in das Handschuhfach gelegt.");
                    stopwatch.Stop();
                    Alt.Log($"{charId} - VehicleTrunkStorageItem benötigte {stopwatch.Elapsed.Milliseconds}ms");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Exemplo n.º 10
0
        public async Task VehicleTrunkTakeItem(ClassicPlayer player, int vehId, int charId, string itemName, int itemAmount, string type)
        {
            try
            {
                if (player == null || !player.Exists || vehId <= 0 || charId <= 0 || itemName == "" || itemAmount <= 0)
                {
                    return;
                }
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                if (type != "trunk" && type != "glovebox")
                {
                    return;
                }
                int cCharId = player.CharacterId;
                if (cCharId != charId)
                {
                    return;
                }
                var targetVehicle = Alt.Server.GetVehicles().ToList().FirstOrDefault(x => x.GetVehicleId() == (ulong)vehId);
                if (targetVehicle == null || !targetVehicle.Exists)
                {
                    return;
                }
                if (!player.Position.IsInRange(targetVehicle.Position, 5f))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist zu weit entfernt."); return;
                }
                if (type == "trunk")
                {
                    if (player.IsInVehicle)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Wie willst du von Innen an den Kofferraum kommen?"); return;
                    }
                    if (!targetVehicle.GetVehicleTrunkState())
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Der Kofferraum ist nicht geöffnet."); return;
                    }
                    if (!ServerVehicles.ExistVehicleTrunkItem(vehId, itemName, false))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Der Gegenstand existiert hier nicht."); return;
                    }
                    if (ServerVehicles.GetVehicleTrunkItemAmount(vehId, itemName, false) < itemAmount)
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Soviele Gegenstände sind nicht im Fahrzeug."); return;
                    }
                }
                else if (type == "glovebox")
                {
                    if (!player.IsInVehicle)
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist in keinem Fahrzeug."); return;
                    }
                    if (!ServerVehicles.ExistVehicleTrunkItem(vehId, itemName, true))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Der Gegenstand existiert hier nicht."); return;
                    }
                    if (ServerVehicles.GetVehicleTrunkItemAmount(vehId, itemName, true) < itemAmount)
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Soviele Gegenstände sind nicht im Fahrzeug."); return;
                    }
                }
                float itemWeight     = ServerItems.GetItemWeight(itemName) * itemAmount;
                float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
                float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                if (invWeight + itemWeight > 15f && backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                {
                    HUDHandler.SendNotification(player, 3, 5000, $"Du hast nicht genug Platz in deinen Taschen."); return;
                }

                if (type == "trunk")
                {
                    ServerVehicles.RemoveVehicleTrunkItemAmount(vehId, itemName, itemAmount, false);
                }
                else if (type == "glovebox")
                {
                    ServerVehicles.RemoveVehicleTrunkItemAmount(vehId, itemName, itemAmount, true);
                }

                if (invWeight + itemWeight <= 15f)
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({itemAmount}x) aus dem Fahrzeug genommen (Lagerort: Inventar).");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "inventory");
                    stopwatch.Stop();
                    Alt.Log($"{charId} - VehicleTrunkTakeItem benötigte {stopwatch.Elapsed.Milliseconds}ms");
                    return;
                }

                if (Characters.GetCharacterBackpack(charId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({itemAmount}x) aus dem Fahrzeug genommen (Lagerort: Rucksack / Tasche).");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "backpack");
                    stopwatch.Stop();
                    Alt.Log($"{charId} - VehicleTrunkTakeItem benötigte {stopwatch.Elapsed.Milliseconds}ms");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }