コード例 #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}");
            }
        }