private void ShopRobFinished(object sender, ElapsedEventArgs e)
 {
     NotifyHandler.SendNotification(player, "Ammunationraub erfolgreich!");
     Utils.Serverglobals.IsShopRobActive = false;
     ShopRobTimer.Dispose();
     CheckRangeTimer.Dispose();
 }
 public async Task removeItem(User player, string str_id, string str_amount)
 {
     if (!await player.removeItem(int.Parse(str_id), int.Parse(str_amount)))
     {
         await NotifyHandler.SendNotification(player, "Fehler beim Entfernen!");
     }
 }
        public async Task tanken(User player, string str_carId, string str_fuelAmount)
        {
            int carId      = int.Parse(str_carId);
            int fuelAmount = int.Parse(str_fuelAmount);


            //Auto in DB finden
            var dbCar = Main.database.CarCollection.AsQueryable().FirstOrDefault(c => c.carId == carId);

            //Sprit setzen
            dbCar.fuel += fuelAmount;
            if (dbCar.fuel > 100.00)
            {
                dbCar.fuel = 100.00;
            }
            //Auto updaten in DB
            await Main.database.CarCollection.ReplaceOneAsync(c => c.carId == carId, dbCar);

            //Auto auf Server finden
            foreach (Car car in Alt.GetAllVehicles())
            {
                if (car.carId == carId)
                {
                    car.fuel += fuelAmount;
                    break;
                }
            }
            await NotifyHandler.SendNotification(player, "Fahrzeug getankt! Tankfüllung: " + dbCar.fuel + "l", 3000);
        }
        public async Task Heal_Player(User player, User otherPlayer)
        {
            await NotifyHandler.SendNotification(otherPlayer, "Du wurdest behandelt!", 3000);

            otherPlayer.Health += 40;
            return;
        }
 private static void ProducerTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     foreach (User player in Alt.GetAllPlayers())
     {
         var dbChar = Utils.Utils.GetDatabaseCharacter(player);
         if (dbChar == null || dbChar.ItemVerarbeiter.VerarbeiterId == 0)
         {
             return;
         }
         var dbVerarbeiter = Main.database.ItemProductionCollection.AsQueryable().FirstOrDefault(ip => ip.Id == dbChar.ItemVerarbeiter.VerarbeiterId);
         if (dbVerarbeiter == null)
         {
             return;
         }
         dbChar.ItemVerarbeiter.CurrentIn  -= dbVerarbeiter.NeededItemAmount;
         dbChar.ItemVerarbeiter.CurrentOut += dbVerarbeiter.OutComeAmount;
         if (dbChar.ItemVerarbeiter.CurrentIn == 0)
         {
             if (dbChar.ItemVerarbeiter.VerarbeiterId == 0)
             {
                 return;
             }
             dbChar.ItemVerarbeiter.VerarbeiterId = 0;
             Main.database.CharacterCollection.ReplaceOne(c => c.playerId == player.playerId, dbChar);
             NotifyHandler.SendNotification(player, "Der Verarbeitungsprozess ist beendet!", 30000);
             return;
         }
         if (dbChar.ItemVerarbeiter.CurrentIn < 0 || dbChar.ItemVerarbeiter.CurrentOut >= 1000)
         {
             return;
         }
         Main.database.CharacterCollection.ReplaceOne(c => c.playerId == player.playerId, dbChar);
         Main.database.ItemProductionCollection.ReplaceOne(ip => ip.Id == dbChar.ItemVerarbeiter.VerarbeiterId, dbVerarbeiter);
     }
 }
        public async Task jail_Player(User player, User otherPlayer)
        {
            var targetChar = IMongoCollectionExtensions.AsQueryable(Main.database.CharacterCollection)
                             .FirstOrDefault(c => c.playerId == otherPlayer.playerId);

            var targetJailTime = 0;
            var targetFine     = 0;

            foreach (var akte in targetChar.Akten)
            {
                var dbAkte = Main.database.FileCollection.AsQueryable().FirstOrDefault(x => x.Akten.Any(y => y.AktenId == akte)).Akten.FirstOrDefault(a => a.AktenId == akte);
                targetJailTime += dbAkte.JailTime;
                targetFine     += dbAkte.Fine;
            }

            targetChar.Akten     = new List <int>();
            otherPlayer.Position = new Position(1729.25f, 2563.642578125f, 45.56489944458008f);
            otherPlayer.Rotation = new Rotation(0, 0, 174.47164916992188f);

            targetChar.jailTime = targetJailTime;
            NotifyHandler.SendNotification(otherPlayer,
                                           $"Du befindest dich nun für {targetChar.jailTime} Hafteinheiten im Gefängnis!");
            Main.database.CharacterCollection.ReplaceOne(c => c.playerId == otherPlayer.playerId, targetChar);

            return;
        }
 private void ShopRobFinished(object sender, ElapsedEventArgs e)
 {
     Console.WriteLine("Shoprob finished!");
     NotifyHandler.SendNotification(player, "Ladenraub erfolgreich!");
     Utils.Serverglobals.IsShopRobActive = false;
     ShopRobTimer.Dispose();
     CheckRangeTimer.Dispose();
 }
        public async Task Reanimate_Player(User player, User otherPlayer)
        {
            player.Emit("client:playAnimation", "missheistfbi3b_ig8_2", "cpr_loop_paramedic", 12000, 1);
            await Task.Delay(5000);

            await NotifyHandler.SendNotification(otherPlayer, "Du wurdest wiederbelebt!", 3000);

            otherPlayer.Spawn(otherPlayer.Position, 0);
            otherPlayer.Health = 110;
            return;
        }
Exemple #9
0
        public Task BuyCar(User player, int dealerId, string carId)
        {
            var nextCarId      = Main.database.CarCollection.AsQueryable().ToList().Count + 1;
            var dbDealer       = Main.database.VehShopCollection.AsQueryable().FirstOrDefault(v => v.Id == dealerId);
            var dbDealerCar    = dbDealer.Cars.ToList().ElementAt(Int32.Parse(carId));
            var numPlate       = "";
            var numPlateExists = false;

            var isPunktBlocked = Alt.GetAllVehicles().ToList().FirstOrDefault(v => v.Position.IsInRange(dbDealer.SpawnPosition.ToAltPos(), 1.5f));

            if (isPunktBlocked != null)
            {
                NotifyHandler.SendNotification(player, "Der Ausparkpunkt ist zurzeit blockiert!");
                return(Task.CompletedTask);
            }

            do
            {
                var random       = new Random();
                var randomNumber = random.Next(10000, 99999);

                numPlate = "CAR" + randomNumber;

                var dbNumPlate = Main.database.CarCollection.AsQueryable().FirstOrDefault(c => c.numPlate == numPlate);

                if (dbNumPlate != null)
                {
                    numPlateExists = true;
                }
            } while (numPlateExists);

            var newCar = new Carcollection()
            {
                allowedIds = new List <int>(), parkedIn = false, carId = nextCarId, carmodel = dbDealerCar.Model,
                fuel       = 100, fuelType = 1, garageId = 1, kilometer = 0, numPlate = numPlate, ownerId = player.playerId
            };

            Main.database.CarCollection.InsertOne(newCar);
            var spawnVeh = (Car)Alt.CreateVehicle(dbDealerCar.Model, dbDealer.SpawnPosition.ToAltPos(), dbDealer.SpawnRotation.ToAltPos());

            spawnVeh.numPlate            = newCar.numPlate;
            spawnVeh.carmodel            = newCar.carmodel;
            spawnVeh.ownerId             = newCar.ownerId;
            spawnVeh.NumberplateText     = numPlate;
            spawnVeh.allowedIds          = new List <int>();
            spawnVeh.fuel                = 100f;
            spawnVeh.kilometer           = 0;
            spawnVeh.carId               = newCar.carId;
            spawnVeh.ManualEngineControl = true;
            spawnVeh.EngineOn            = false;
            spawnVeh.LockState           = VehicleLockState.Locked;

            return(Task.CompletedTask);
        }
Exemple #10
0
        public async Task invite_CMD(User player, string str_playerId)
        {
            int playerId = int.Parse(str_playerId);
            var dbChar   = Main.database.CharacterCollection.AsQueryable().FirstOrDefault(c => c.playerId == playerId);
            var dbFrak   = Main.database.FractionCollection.AsQueryable().FirstOrDefault(f => f.frakId == player.frakId);

            if (dbFrak == null)
            {
                return;
            }
            if (dbFrak.frakMember.FirstOrDefault(f => f.playerid == player.playerId).rank < 11)
            {
                await NotifyHandler.SendNotification(player, "Du bist nicht berechtigt Leute einzuladen!");

                return;
            }
            if (dbChar == null)
            {
                await NotifyHandler.SendNotification(player, "Dieser Spieler existiert nicht!");

                return;
            }
            if (!dbChar.isOnline)
            {
                await NotifyHandler.SendNotification(player, "Dieser Spieler ist nicht online!");

                return;
            }
            if (dbChar.frakId != null)
            {
                await NotifyHandler.SendNotification(player, "Dieser Spieler ist bereits in einer Fraktion!");

                return;
            }
            foreach (User p in Alt.GetAllPlayers())
            {
                if (p.playerId == playerId)
                {
                    await NotifyHandler.SendNotification(player, $"Du hast {dbChar.firstName} {dbChar.lastName} ({dbChar.playerId}) zu {dbFrak.frakName} eingeladen!");

                    dbChar.frakId = dbFrak.frakId;
                    p.frakId      = dbFrak.frakId;
                    dbFrak.frakMember.Add(new FrakMember()
                    {
                        playerid = playerId, joinDate = DateTime.Now.ToLocalTime(), rank = 0
                    });
                    break;
                }
            }

            await Main.database.CharacterCollection.ReplaceOneAsync(c => c.playerId == playerId, dbChar);

            await Main.database.FractionCollection.ReplaceOneAsync(f => f.frakId == player.frakId, dbFrak);
        }
Exemple #11
0
        public async Task Farmhandler(User player, long feldId)
        {
            var dbFeld     = Main.database.FeldCollection.AsQueryable().FirstOrDefault(f => f.id == feldId);
            var dbItem     = Main.database.ItemCollection.AsQueryable().FirstOrDefault(i => i.itemId == dbFeld.itemId);
            var random     = new Random();
            var itemAmount = random.Next(dbFeld.itemMin, dbFeld.itemMax + 1);

            await NotifyHandler.SendNotification(player, $"Du hast {dbItem.name} ({itemAmount}x) gesammelt!");

            player.addItem(dbFeld.itemId, itemAmount);
        }
Exemple #12
0
        public async Task buyShopItems(User player, string str_itemId, string str_amount)
        {
            int itemId = int.Parse(str_itemId);
            int amount = int.Parse(str_amount);
            var price  = Main.database.ItemCollection.AsQueryable().ToList().FirstOrDefault(i => i.itemId == itemId).price;

            if (price != null && await player.removeMoneyAsync(price.Value * amount))
            {
                player.addItem(itemId, amount);
                await NotifyHandler.SendNotification(player, $"{amount}x gekauft!", 1000);
            }
        }
        public async Task Producer_Empty(User player, string producerId)
        {
            var dbProducer = Main.database.ItemProductionCollection.AsQueryable().FirstOrDefault(ip => ip.Id == int.Parse(producerId));
            await player.addItem(dbProducer.OutComeItemId, Main.database.CharacterCollection.AsQueryable().FirstOrDefault(c => c.playerId == player.playerId).ItemVerarbeiter.CurrentOut);

            var dbChar = Utils.Utils.GetDatabaseCharacter(player);
            await NotifyHandler.SendNotification(player, $"Du hast {dbChar.ItemVerarbeiter.CurrentOut} Items herausgenommen!");

            dbChar.ItemVerarbeiter.CurrentOut = 0;
            Main.database.CharacterCollection.ReplaceOne(c => c.playerId == player.playerId, dbChar);
            return;
        }
        public async Task Producer_Fill(User player, string producerId)
        {
            var dbChar     = Utils.Utils.GetDatabaseCharacter(player);
            var dbProducer = Main.database.ItemProductionCollection.AsQueryable().FirstOrDefault(p => p.Id == int.Parse(producerId));

            if (int.Parse(producerId) != dbChar.ItemVerarbeiter.VerarbeiterId && dbChar.ItemVerarbeiter.VerarbeiterId != 0)
            {
                NotifyHandler.SendNotification(player, "Du verarbeitest bereits an einem anderen Ort!");
            }
            var limit    = 1000 - dbChar.ItemVerarbeiter.CurrentIn;
            var addLimit = (limit / dbProducer.NeededItemAmount) * dbProducer.NeededItemAmount;

            if (!await player.removeItem(dbProducer.NeededItemId, addLimit))
            {
                dbChar.ItemVerarbeiter.CurrentIn    += addLimit;
                dbChar.ItemVerarbeiter.VerarbeiterId = dbProducer.Id;
                await NotifyHandler.SendNotification(player, $"Du hast erfolgreich {addLimit} Items hineingelegt!");

                await Main.database.CharacterCollection.ReplaceOneAsync(c => c.playerId == player.playerId, dbChar);

                return;
            }
            try
            {
                Console.WriteLine($"NeededItem: " + Main.database.ItemCollection.AsQueryable().FirstOrDefault(i => i.itemId == dbProducer.NeededItemId).name);
                if (!player.HasItem(dbProducer.NeededItemId, dbProducer.NeededItemAmount))
                {
                    NotifyHandler.SendNotification(player, "Dir fehlen Items zum Verarbeiten!");
                    return;
                }
                var playerMax   = dbChar.Inventar.FirstOrDefault(i => i.itemId == dbProducer.NeededItemId).amount;
                var playerLimit = (playerMax / dbProducer.NeededItemAmount) * dbProducer.NeededItemAmount;
                if (playerMax == 0)
                {
                    return;
                }
                if (!await player.removeItem(dbProducer.NeededItemId, playerLimit))
                {
                    NotifyHandler.SendNotification(player, "Fehler beim Auffüllen! [ITMP-001]");
                    return;
                }
                dbChar.ItemVerarbeiter.CurrentIn    += playerLimit;
                dbChar.ItemVerarbeiter.VerarbeiterId = dbProducer.Id;
                NotifyHandler.SendNotification(player, $"Du hast erfolgreich {playerLimit} Items hineingelegt!");
                Main.database.CharacterCollection.ReplaceOne(c => c.playerId == player.playerId, dbChar);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #15
0
        public async Task uninvite_CMD(User player, string str_playerId)
        {
            int playerId = int.Parse(str_playerId);
            var dbChar   = Main.database.CharacterCollection.AsQueryable().FirstOrDefault(c => c.playerId == playerId);
            var dbFrak   = Main.database.FractionCollection.AsQueryable().FirstOrDefault(f => f.frakId == player.frakId);

            if (dbFrak == null)
            {
                return;
            }
            if (dbFrak.frakMember.FirstOrDefault(f => f.playerid == player.playerId).rank < 11)
            {
                await NotifyHandler.SendNotification(player, "Du bist nicht berechtigt Leute rauszuwerfen!");

                return;
            }
            if (dbChar == null)
            {
                await NotifyHandler.SendNotification(player, "Dieser Spieler existiert nicht!");

                return;
            }
            if (dbChar.frakId != dbFrak.frakId)
            {
                await NotifyHandler.SendNotification(player, "Dieser Spieler ist kein Mitglied dieser Fraktion!");

                return;
            }
            dbChar.frakId = null;

            foreach (var member in dbFrak.frakMember)
            {
                if (member.playerid == playerId)
                {
                    dbFrak.frakMember.Remove(member);
                    await NotifyHandler.SendNotification(player, $"Du hast {dbChar.firstName} {dbChar.lastName} ({dbChar.playerId}) aus {dbFrak.frakName} geworfen!");

                    break;
                }
            }

            await Main.database.CharacterCollection.ReplaceOneAsync(c => c.playerId == playerId, dbChar);

            await Main.database.FractionCollection.ReplaceOneAsync(f => f.frakId == player.frakId, dbFrak);
        }
        public async Task Ammunation_Buy(User player, string itemId, string amount, int ammunationId)
        {
            Console.WriteLine(ammunationId);
            var dbAmmunation = Main.database.AmmunationCollection.AsQueryable()
                               .FirstOrDefault(a => a.Id == ammunationId);

            Console.WriteLine(JsonConvert.SerializeObject(dbAmmunation));
            var ammunationInv = dbAmmunation.Inventory;
            var dbItem        = ammunationInv.FirstOrDefault(i => i.ItemId == int.Parse(itemId));
            var dbChar        = Utils.Utils.GetDatabaseCharacter(player);

            if (!await player.removeMoneyAsync(dbItem.Price * int.Parse(amount)))
            {
                return;
            }
            player.addItem(dbItem.ItemId, int.Parse(amount));
            await NotifyHandler.SendNotification(player, "Erfolgreich gekauft!", 3000);
        }
        public Task LockVehicle(User player, Car vehicle)
        {
            if (player == null || !player.Exists || player.playerId <= 0 || vehicle == null || !vehicle.Exists || vehicle.carId <= 0)
            {
                return(Task.CompletedTask);
            }
            Console.WriteLine("64");
            if (vehicle.frakId > 0)
            {
                if (vehicle.frakId != player.frakId)
                {
                    NotifyHandler.SendNotification(player, "Du hast keinen Schlüssel!");
                    return(Task.CompletedTask);
                }
            }
            else
            {
                if (!vehicle.allowedIds.Contains(player.playerId) && vehicle.ownerId != player.playerId)
                {
                    Console.WriteLine("67");

                    NotifyHandler.SendNotification(player, "Du hast keinen Schlüssel!");
                    return(Task.CompletedTask);
                }
            }


            if (vehicle.LockState == VehicleLockState.Locked)
            {
                NotifyHandler.SendNotification(player, "Fahrzeug aufgeschlossen!");
                vehicle.LockState = VehicleLockState.Unlocked;
                return(Task.CompletedTask);
            }
            if (vehicle.LockState == VehicleLockState.Unlocked)
            {
                NotifyHandler.SendNotification(player, "Fahrzeug abgeschlossen!");
                vehicle.LockState = VehicleLockState.Locked;
                return(Task.CompletedTask);
            }

            return(Task.CompletedTask);
        }
 private void CheckRange(object sender, ElapsedEventArgs e)
 {
     if (!player.Position.IsInRange(dbItemShop.Pos.ToAltPos(), 7f))
     {
         NotifyHandler.SendNotification(player,
                                        "Du hast dich zu weit entfernt! Der Ammunationraub wurde abgebrochen!");
         var playerpool = Alt.GetAllPlayers();
         foreach (User p in playerpool)
         {
             if (p.frakId != 1 && p.frakId != 2)
             {
                 continue;
             }
             NotifyHandler.SendNotification(p, $"Ein Ammunationraub wurde vorzeitig abgebrochen! ({dbItemShop.Name})", 10000);
         }
         Utils.Serverglobals.IsShopRobActive = false;
         ShopRobTimer.Dispose();
         CheckRangeTimer.Dispose();
     }
 }
        public Task ToggleEngine(User player, Car vehicle)
        {
            if (player == null || !player.Exists || player.playerId <= 0 || vehicle == null || !vehicle.Exists || vehicle.carId <= 0)
            {
                return(Task.CompletedTask);
            }
            if (vehicle.frakId > 0)
            {
                if (vehicle.frakId != player.frakId)
                {
                    NotifyHandler.SendNotification(player, "Du hast keinen Schlüssel!");
                    return(Task.CompletedTask);
                }
            }
            else
            {
                if (!vehicle.allowedIds.Contains(player.playerId) && vehicle.ownerId != player.playerId)
                {
                    Console.WriteLine("67");

                    NotifyHandler.SendNotification(player, "Du hast keinen Schlüssel!");
                    return(Task.CompletedTask);
                }
            }

            if (vehicle.EngineOn)
            {
                NotifyHandler.SendNotification(player, "Motor Aus");
                vehicle.EngineOn = false;
                return(Task.CompletedTask);
            }

            if (!vehicle.EngineOn)
            {
                NotifyHandler.SendNotification(player, "Motor An");
                vehicle.EngineOn = true;
                return(Task.CompletedTask);
            }

            return(Task.CompletedTask);
        }
Exemple #20
0
        private static void HandleFreeJail(Characters c)
        {
            if (c == null)
            {
                throw new ArgumentNullException(nameof(c));
            }
            var playerPool = Alt.GetAllPlayers();

            foreach (User player in playerPool)
            {
                if (player.playerId != c.playerId)
                {
                    continue;
                }
                if (player.Position.IsInRange(new Position(1729.25f, 2563.642578125f, 45.56489944458008f), 70f))
                {
                    player.Position = new Position(1847.76171875f, 2585.59228515625f, 45.67206954956055f);
                }

                NotifyHandler.SendNotification(player, "Du bist nun aus dem Gefängnis entlassen!");
            }
        }
        public Task RobAmmunation(User x, int ammoId)
        {
            player     = x;
            dbItemShop = Main.database.AmmunationCollection.AsQueryable().FirstOrDefault(s => s.Id == ammoId);
            var playerpool = Alt.GetAllPlayers();

            if (Utils.Serverglobals.IsShopRobActive)
            {
                NotifyHandler.SendNotification(player, $"Es läuft bereits ein Raub!", 10000);
                return(Task.CompletedTask);
            }

            Utils.Serverglobals.IsShopRobActive = true;
            ShopRobTimer    = new Timer();
            CheckRangeTimer = new Timer();

            ShopRobTimer.Elapsed += new ElapsedEventHandler(ShopRobFinished);
            ShopRobTimer.Interval = 600000;
            ShopRobTimer.Enabled  = true;

            CheckRangeTimer.Elapsed += new ElapsedEventHandler(CheckRange);
            CheckRangeTimer.Interval = 1000;
            CheckRangeTimer.Enabled  = true;


            NotifyHandler.SendNotification(player, "Du bist dabei den Ammunation auszurauben!");


            foreach (User p in playerpool)
            {
                if (p.frakId != 1 && p.frakId != 2)
                {
                    continue;
                }
                NotifyHandler.SendNotification(p, $"Ein Ammunation wird ausgeraubt! ({dbItemShop.Name})", 10000);
            }
            return(Task.CompletedTask);
        }
        public static async Task buyFrakItemAsync(User player, string str_itemid, string str_amount)
        {
            int itemId = Int32.Parse(str_itemid);
            int amount = Int32.Parse(str_amount);
            int frakid = player.frakId;

            var dbFrak      = Main.database.FractionCollection.AsQueryable().FirstOrDefault(f => f.frakId == frakid);
            var dbFrakItems = Main.database.FrakNpcCollection.AsQueryable().FirstOrDefault(n => n.frakId == frakid).frakShopItems;
            var dbCharRank  = dbFrak.frakMember.FirstOrDefault(c => c.playerid == player.playerId).rank;
            var dbFrakItem  = dbFrakItems.FirstOrDefault(f => f.itemId == itemId);

            if (dbFrakItem.rank > dbCharRank)
            {
                await NotifyHandler.SendNotification(player, $"Dein Rang ist nicht ausreichend! ({dbFrakItem.rank})");

                return;
            }
            if (await player.removeMoneyAsync(dbFrakItem.itemPrice * amount))
            {
                player.addItem(itemId, amount);
                await NotifyHandler.SendNotification(player, $"{amount}x gekauft!", 1000);
            }
        }
        public Task openPhone(User player)
        {
            //Check if player has phone
            var dbChar   = Utils.Utils.GetDatabaseCharacter(player);
            var invPhone = dbChar.Inventar.ToList().FirstOrDefault(i => i.itemId == 30);

            if (invPhone == null)
            {
                NotifyHandler.SendNotification(player, "Du besitzt kein Smartphone!");
                return(Task.CompletedTask);
            }

            if (player.frakId == 1 || player.frakId == 2)
            {
                player.Emit("client:playAnimation", "anim@cellphone@in_car@ds", "cellphone_text_read_base", -1, 51);
                player.Emit("client:openPhone", true);
                return(Task.CompletedTask);
            }
            player.Emit("client:playAnimation", "anim@cellphone@in_car@ds", "cellphone_text_read_base", -1, 51);
            player.Emit("client:openPhone", false);


            return(Task.CompletedTask);
        }
Exemple #24
0
        public Task onPlayerDisconnect(User player, string reason)
        {
            var dbChar = Main.database.CharacterCollection.AsQueryable().FirstOrDefault(c => c.ownerObjId == player.uid);

            if (dbChar == null)
            {
                return(Task.CompletedTask);
            }


            foreach (User p in Alt.GetAllPlayers().Where(x => player.Position.IsInRange(x.Position, 20f)))
            {
                NotifyHandler.SendNotification(p, $"Anti-Offlineflucht {dbChar.firstName} {dbChar.lastName} ist disconnected! Grund: {reason}");
                Console.WriteLine("Disconnect Reason: " + reason);
            }



            //save position
            if (player.paintballArena == 0)
            {
                dbChar.pos_x    = player.Position.X;
                dbChar.pos_y    = player.Position.Y;
                dbChar.pos_z    = player.Position.Z;
                dbChar.health   = player.Health;
                dbChar.armor    = player.Armor;
                dbChar.isOnline = false;
            }
            if (player.paintballArena != 0)
            {
                PaintballHandler.HandleDisconnect(player);
            }

            Main.database.CharacterCollection.ReplaceOne(x => x.ownerObjId == player.uid, dbChar);
            return(Task.CompletedTask);
        }
        public static async Task Join(User player, string str_arena)
        {
            if (player.paintballArena == 0)
            {
                int arenaId        = int.Parse(str_arena);
                var paintballArena = Main.database.PaintballCollection.AsQueryable().FirstOrDefault(p => p.arenaId == arenaId);
                if (paintballArena.playerCount < paintballArena.playerMax)
                {
                    paintballArena.playerCount += 1;

                    if (await player.removeMoneyAsync(paintballArena.price))
                    {
                        await NotifyHandler.SendNotification(player, "Du bist Paintball beigetreten!");

                        await player.SaveWeapons();

                        player.paintballArena = arenaId;
                        player.Dimension      = 1;
                        await SetPaintballClothes(player);

                        player.RemoveAllWeapons();
                        await Main.database.PaintballCollection.ReplaceOneAsync(p => p.arenaId == arenaId, paintballArena);

                        player.GiveWeapon(AltV.Net.Enums.WeaponModel.AdvancedRifle, 9999, true);
                        player.GiveWeapon(AltV.Net.Enums.WeaponModel.GusenbergSweeper, 9999, true);
                        player.GiveWeapon(AltV.Net.Enums.WeaponModel.CombatPDW, 9999, true);
                        player.GiveWeapon(AltV.Net.Enums.WeaponModel.StunGun, 9999, true);
                        Spawn(player);
                    }
                }
                else
                {
                    await NotifyHandler.SendNotification(player, "Diese Arena ist voll!");
                }
            }
        }
        public async Task BuyClothing(User player, string clothId)
        {
            var dbClothing = Main.database.ClothesCollection.AsQueryable().FirstOrDefault(c => c.clothId == clothId);
            var price      = 0;

            switch (int.Parse(dbClothing.shopType))
            {
            //Ponsonboys
            case 1:
                price = 30000;
                break;

            //Suburban
            case 2:
                price = 5000;
                break;

            //Discount
            case 3:
                price = 2000;
                break;
            }

            if (!await player.removeMoneyAsync(price))
            {
                return;
            }
            {
                var dbchar = Utils.Utils.GetDatabaseCharacter(player);
                if (dbchar.OwnedClothes.Contains(int.Parse(dbClothing.clothId)))
                {
                    await NotifyHandler.SendNotification(player, "Du besitzt dies bereits!", 3000);

                    return;
                }
                dbchar.OwnedClothes.Add(int.Parse(dbClothing.clothId));
                switch (int.Parse(dbClothing.componentId))
                {
                case 1:
                    //Maske
                    break;

                case 2:
                    //Hair
                    break;

                case 3:
                    //Torsos
                    break;

                case 4:
                    //Legs
                    dbchar.Clothes.Legs = new Component()
                    {
                        colorId = int.Parse(dbClothing.colorId), drawableId = int.Parse(dbClothing.drawableId)
                    };
                    break;

                case 5:
                    //Bags
                    break;

                case 6:
                    //Shoes
                    dbchar.Clothes.Shoes = new Component()
                    {
                        colorId = int.Parse(dbClothing.colorId), drawableId = int.Parse(dbClothing.drawableId)
                    };
                    break;

                case 7:
                    //Accessories
                    break;

                case 8:
                    //Undershirts
                    dbchar.Clothes.Undershirt = new Component()
                    {
                        colorId = int.Parse(dbClothing.colorId), drawableId = int.Parse(dbClothing.drawableId)
                    };
                    break;

                case 9:
                    //Body Armors
                    break;

                case 10:
                    //Decals
                    break;

                case 11:
                    //Tops
                    dbchar.Clothes.Tops = new Component()
                    {
                        colorId = int.Parse(dbClothing.colorId), drawableId = int.Parse(dbClothing.drawableId)
                    };
                    break;
                }

                await NotifyHandler.SendNotification(player, "Erfolgreich gekauft!", 5000);

                Main.database.CharacterCollection.ReplaceOne(c => c.playerId == player.playerId, dbchar);
            }

            return;
        }
        public async Task useItem(User player, string str_itemId, string str_amount)
        {
            var dbitem = Main.database.ItemCollection.AsQueryable()
                         .FirstOrDefault(i => i.itemId == int.Parse(str_itemId));

            if (dbitem == null)
            {
                return;
            }
            if (!dbitem.isUseable)
            {
                return;
            }


            switch (int.Parse(str_itemId))
            {
            //Verbandkasten
            case 29:
                if (!await player.removeItem(int.Parse(str_itemId), int.Parse(str_amount)))
                {
                    await NotifyHandler.SendNotification(player, "Fehler beim Entfernen!");

                    return;
                }
                player.Emit("client:playAnimation", "anim@heists@narcotics@funding@gang_idle", "gang_chatting_idle01", 4500, 1);
                await Task.Delay(4500);

                player.Health = 200;
                break;

            //Pistole
            case 9:
                if (!await player.removeItem(int.Parse(str_itemId), 1))
                {
                    await NotifyHandler.SendNotification(player, "Fehler beim Entfernen!");

                    return;
                }
                player.GiveWeapon(WeaponModel.Pistol, 0, true);
                break;

            //Deagle
            case 10:
                if (!await player.removeItem(int.Parse(str_itemId), 1))
                {
                    await NotifyHandler.SendNotification(player, "Fehler beim Entfernen!");

                    return;
                }
                player.GiveWeapon(WeaponModel.Pistol50, 0, true);
                break;

            //Pistol ammo
            case 11:
                if (!await player.removeItem(int.Parse(str_itemId), int.Parse(str_amount)))
                {
                    await NotifyHandler.SendNotification(player, "Fehler beim Entfernen!");

                    return;
                }
                if (player.CurrentWeapon != (uint)WeaponModel.Pistol)
                {
                    NotifyHandler.SendNotification(player, "Du hast keine Pistole in der Hand!");
                    return;
                }
                player.GiveWeapon(WeaponModel.Pistol, int.Parse(str_amount), true);
                break;

            //Deagle Ammo
            case 12:
                if (!await player.removeItem(int.Parse(str_itemId), int.Parse(str_amount)))
                {
                    await NotifyHandler.SendNotification(player, "Fehler beim Entfernen!");

                    return;
                }
                if (player.CurrentWeapon != (uint)WeaponModel.Pistol50)
                {
                    NotifyHandler.SendNotification(player, "Du hast keine Deagle in der Hand!");
                    return;
                }
                player.GiveWeapon(WeaponModel.Pistol50, int.Parse(str_amount), true);
                break;

            //Taser
            case 18:
                if (!await player.removeItem(int.Parse(str_itemId), 1))
                {
                    await NotifyHandler.SendNotification(player, "Fehler beim Entfernen!");

                    return;
                }
                if (player.frakId != 2 && player.frakId != 1)
                {
                    return;
                }
                player.GiveWeapon(WeaponModel.StunGun, 0, true);
                break;

            //Weste
            case 34:
                if (!await player.removeItem(int.Parse(str_itemId), 1))
                {
                    await NotifyHandler.SendNotification(player, "Fehler beim Entfernen!");

                    return;
                }
                player.Emit("client:playAnimation", "anim@heists@narcotics@funding@gang_idle", "gang_chatting_idle01", 4500, 1);
                await Task.Delay(4500);

                player.Armor = 100;
                break;
            }
            return;
        }
        public async Task FrakGarage_Ausparken(User player, string str_carId)
        {
            var dbCar = Main.database.FrakcarCollection.AsQueryable()
                        .FirstOrDefault(c => c.carId == Int32.Parse(str_carId));

            var ausparkPunkte = Main.database.FrakGarageCollection.AsQueryable()
                                .FirstOrDefault(g => g.Id == dbCar.garageId).Ausparkpunkte;

            var dbModifiers = Main.database.VehicleModiferCollection.AsQueryable()
                              .FirstOrDefault(c => c.ModelName.ToLower() == dbCar.carmodel.ToLower());

            if (!dbCar.parkedIn)
            {
                return;
            }

            for (int i = 0; i < ausparkPunkte.Count; i++)
            {
                var ausparkPunkt    = ATMS.atmInteraction.toAltPos(ausparkPunkte.ElementAt(i).position);
                var ausparkRotation = ausparkPunkte.ElementAt(i).rotation;
                var ausparkBlocked  = Alt.GetAllVehicles().ToList().FirstOrDefault(v => v.Position.IsInRange(ausparkPunkt, 1.5f));
                if (ausparkBlocked != null)
                {
                }
                else
                {
                    Car spawnCar = (Car)Alt.CreateVehicle(dbCar.carmodel, ausparkPunkt, new Rotation(0, 0, (float)ausparkRotation));
                    switch (dbCar.frakId)
                    {
                    case 2:
                        spawnCar.PrimaryColor   = (byte)Gangcolors.FIB;
                        spawnCar.SecondaryColor = (byte)Gangcolors.FIB;
                        break;

                    case 5:
                        spawnCar.PrimaryColor   = (byte)Gangcolors.MIDNIGHT;
                        spawnCar.SecondaryColor = (byte)Gangcolors.MIDNIGHT;
                        break;

                    case 7:
                        spawnCar.PrimaryColor   = (byte)Gangcolors.MG13;
                        spawnCar.SecondaryColor = (byte)Gangcolors.MG13;
                        break;

                    case 8:
                        spawnCar.PrimaryColor   = (byte)Gangcolors.LCN;
                        spawnCar.SecondaryColor = (byte)Gangcolors.LCN;
                        break;

                    case 9:
                        spawnCar.PrimaryColor   = (byte)Gangcolors.VAGOS;
                        spawnCar.SecondaryColor = (byte)Gangcolors.VAGOS;
                        break;

                    case 10:
                        spawnCar.PrimaryColor   = (byte)Gangcolors.BALLAS;
                        spawnCar.SecondaryColor = (byte)Gangcolors.BALLAS;
                        break;
                    }

                    spawnCar.NumberplateText     = dbCar.numPlate;
                    spawnCar.frakId              = dbCar.frakId;
                    spawnCar.numPlate            = dbCar.numPlate;
                    spawnCar.fuel                = dbCar.fuel;
                    spawnCar.kilometer           = dbCar.kilometer;
                    spawnCar.carId               = dbCar.carId;
                    spawnCar.ManualEngineControl = true;
                    spawnCar.carmodel            = dbCar.carmodel;
                    spawnCar.LockState           = VehicleLockState.Locked;

                    dbCar.parkedIn = false;
                    Main.database.FrakcarCollection.ReplaceOne(c => c.carId == dbCar.carId, dbCar);
                    await Task.Delay(500);

                    Alt.EmitAllClients("vehicle:setSpeed", spawnCar, dbModifiers.VehSpeedModifier);
                    break;
                }
                if (i == ausparkPunkte.Count && ausparkBlocked.Exists)
                {
                    await NotifyHandler.SendNotification(player, "Es sind keine Ausparkpunkte frei!");

                    break;
                }
            }
            return;
        }
 public Task ShowSupportInfo(User player, User otherPlayer)
 {
     NotifyHandler.SendNotification(player, $"Support ID: {otherPlayer.playerId}", 5000);
     return(Task.CompletedTask);
 }