public static void SetCharacterTabletApps(int charId, bool weather, bool news, bool banking, bool lifeinvader, bool vehicles, bool events, bool company, bool notices) { try { if (charId == 0) { return; } var tabletData = CharactersTabletApps_.FirstOrDefault(x => x.charId == charId); if (tabletData != null) { tabletData.weather = weather; tabletData.news = news; tabletData.banking = banking; tabletData.lifeinvader = lifeinvader; tabletData.vehicles = vehicles; tabletData.events = events; tabletData.company = company; tabletData.notices = notices; using (gtaContext db = new gtaContext()) { db.Characters_Tablet_Apps.Update(tabletData); db.SaveChanges(); } } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void CreateBankAccount(int charid, int accountNumber, int PIN, string zoneName) { try { var BankAccountData = new Characters_Bank() { charId = charid, accountNumber = accountNumber, money = 0, pin = PIN, mainAccount = false, closed = false, pinTrys = 0, createZone = zoneName }; CharactersBank_.Add(BankAccountData); using (gtaContext db = new gtaContext()) { db.Characters_Bank.Add(BankAccountData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void CreateServerCompany(string companyName, int companyOwnerId, Position pos, string givenLicense) { if (companyName == "" || companyOwnerId == 0) { return; } var companyData = new Server_Companys { companyName = companyName, companyOwnerId = companyOwnerId, posX = pos.X, posY = pos.Y, posZ = pos.Z, givenLicense = givenLicense, createdTimestamp = DateTime.Now, companyMoney = 0 }; try { ServerCompanysData_.Add(companyData); using (gtaContext db = new gtaContext()) { db.Server_Companys.Add(companyData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void NewDeathLog(int player, int killer, uint weapon) { try { if (player <= 0 || killer <= 0) { return; } var logData = new Logs_Death { playerName = player, killerName = killer, weaponId = weapon }; Server_Deaths.Logs_Death_.Add(logData); using (gtaContext db = new gtaContext()) { db.LogsDeath.Add(logData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void CreateServerPed(IPlayer client, string model, Position pos, float rotation) { if (client == null || !client.Exists) { return; } var ServerPedData = new Server_Peds { model = model, posX = pos.X, posY = pos.Y, posZ = pos.Z, rotation = rotation }; try { ServerPeds_.Add(ServerPedData); using (gtaContext db = new gtaContext()) { db.Server_Peds.Add(ServerPedData); db.SaveChanges(); } HUDHandler.SendNotification(client, 2, 5000, $"Ped mit dem Model ({ServerPedData.model}) an deiner Position erstellt."); } catch (Exception e) { Alt.Log($"{e}"); } }
public static void SetPlayerBanned(IPlayer player, bool state, string reason) { if (player == null || !player.Exists) { return; } var pl = Player.FirstOrDefault(p => p.socialClub == player.SocialClubId); if (pl != null) { pl.ban = state; pl.banReason = reason; try { using (gtaContext db = new gtaContext()) { db.Accounts.Update(pl); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } } }
public static void NewFactionLog(int factionId, int charId, int targetCharId, string type, string text) { try { if (factionId == 0 || charId == 0) { return; } var logData = new Logs_Faction { factionId = factionId, charId = charId, targetCharId = targetCharId, type = type, text = text, timestamp = DateTime.Now }; ServerFactions.LogsFaction_.Add(logData); using (gtaContext db = new gtaContext()) { db.LogsFaction.Add(logData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void CreatePhoneChatMessage(int chatId, int fromNumber, int toNumber, int unix, string message) { try { var messageData = new CharactersPhoneChatMessages() { chatId = chatId, fromNumber = fromNumber, toNumber = toNumber, unix = unix, message = message }; CharactersPhoneChatMessages_.Add(messageData); using (gtaContext db = new gtaContext()) { db.CharactersPhoneChatMessages.Add(messageData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void DeletePhoneChat(int chatId) { try { using (var db = new gtaContext()) { var chatData = CharactersPhoneChats_.ToList().FirstOrDefault(x => x.chatId == chatId); if (chatData != null) { db.CharactersPhoneChats.Remove(chatData); CharactersPhoneChats_.Remove(chatData); } foreach (var message in CharactersPhoneChatMessages_.ToList().Where(x => x.chatId == chatId)) { db.CharactersPhoneChatMessages.Remove(message); CharactersPhoneChatMessages_.Remove(message); } db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
// 1 = DoJ, 2 = LSPD, 3 = LSFD, 4 = ACLS, 5 = Fahrschule public static void CreateServerFactionMember(int factionId, int charId, int rank, int dienstnummer) { try { if (factionId == 0 || charId == 0) { return; } var factionMemberData = ServerFactionMembers_.FirstOrDefault(x => x.charId == charId); if (factionMemberData != null) { return; } var factionInviteData = new Server_Faction_Members { charId = charId, factionId = factionId, rank = rank, serviceNumber = dienstnummer, isDuty = false, lastChange = DateTime.Now }; ServerFactionMembers_.Add(factionInviteData); using (gtaContext db = new gtaContext()) { db.Server_Faction_Members.Add(factionInviteData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void RemoveServerFactionStorageItemAmount(int factionId, int charId, string itemName, int itemAmount) { try { if (charId <= 0 || itemName == "" || itemAmount == 0 || factionId <= 0) { return; } var item = ServerFactionStorageItems_.FirstOrDefault(i => i.charId == charId && i.itemName == itemName && i.factionId == factionId); if (item != null) { using (gtaContext db = new gtaContext()) { int prevAmount = item.amount; item.amount -= itemAmount; if (item.amount > 0) { db.Server_Faction_Storage_Items.Update(item); db.SaveChanges(); } else { RemoveServerFactionStorageItem(factionId, charId, itemName); } } } } catch (Exception _) { Alt.Log($"{_}"); } }
public static void AddServerHouseRenter(int houseId, int renterId) { if (houseId <= 0 || renterId <= 0) { return; } var rentData = new Server_Houses_Renter { houseId = houseId, charId = renterId }; try { var renter = ServerHousesRenter_.FirstOrDefault(i => i.charId == renterId && i.houseId == houseId); if (renter != null) { return; } //Existiert nicht, Mieter hinzufĆ¼gen ServerHousesRenter_.Add(rentData); using (gtaContext db = new gtaContext()) { db.Server_Houses_Renters.Add(rentData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void SetHouseOwner(int houseId, int newOwner) { try { if (houseId <= 0) { return; } var house = ServerHouses_.FirstOrDefault(x => x.id == houseId); if (house != null) { house.ownerId = newOwner; house.isLocked = true; if (newOwner == 0) { house.isRentable = false; } using (gtaContext db = new gtaContext()) { db.Server_Houses.Update(house); db.SaveChanges(); } } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void CreateCharacterTabletTutorialAppEntry(int charId) { try { if (charId <= 0) { return; } var tutorialData = new Characters_Tablet_Tutorial { charId = charId, openTablet = false, openInventory = false, createBankAccount = false, buyVehicle = false, useGarage = false, acceptJob = false }; CharactersTabletTutorialData_.Add(tutorialData); using (gtaContext db = new gtaContext()) { db.Characters_Tablet_Tutorials.Add(tutorialData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void cmd_ChangeP(IPlayer player, int shopId, int itemId, int newPrice) { try { if (player == null || !player.Exists || shopId <= 0 || itemId <= 0 || newPrice < 0 || player.AdminLevel() <= 8) { return; } var shopItem = ServerShopsItems.ServerShopsItems_.FirstOrDefault(x => x != null && x.shopId == shopId && x.id == itemId); if (shopItem == null) { return; } shopItem.itemPrice = newPrice; using (gtaContext db = new gtaContext()) { db.Server_Shops_Items.Update(shopItem); db.SaveChanges(); } player.SendChatMessage("Preis geƤndert."); } catch (Exception e) { Alt.Log($"{e}"); } }
public static void CreateServerShopItem(IPlayer client, int shopId, string itemName, int itemAmount, int itemPrice) { if (client == null || !client.Exists) { return; } var ServerShopItemData = new Server_Shops_Items { shopId = shopId, itemName = itemName, itemAmount = itemAmount, itemPrice = itemPrice, itemGender = 2 }; try { ServerShopsItems_.Add(ServerShopItemData); using (gtaContext db = new gtaContext()) { db.Server_Shops_Items.Add(ServerShopItemData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static async Task SetPlayerOnline(ClassicPlayer player, int charId) { if (player == null || !player.Exists) { return; } player.SetCharacterMetaId(Convert.ToUInt64(charId)); var pl = Player.FirstOrDefault(p => p.socialClub == player.SocialClubId); if (pl != null) { player.CharacterId = charId; pl.Online = charId; try { using (gtaContext db = new gtaContext()) { db.Accounts.Update(pl); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } } }
public static void RemoveShopItemAmount(int shopId, string itemName, int itemAmount) { if (shopId == 0 || itemName == "" || itemAmount == 0) { return; } var shopItem = ServerShopsItems_.FirstOrDefault(x => x.shopId == shopId && x.itemName == itemName); if (shopItem == null) { return; } int prevAmount = shopItem.itemAmount; shopItem.itemAmount -= itemAmount; using (gtaContext db = new gtaContext()) { if (shopItem.itemAmount > 0) { db.Server_Shops_Items.Update(shopItem); db.SaveChanges(); } else { RemoveShopItem(shopId, itemName); } } }
public static void SetPlayerBanned(int playerId, bool state, string reason) { try { if (playerId <= 0) { return; } var pl = Player.FirstOrDefault(x => x.playerid == playerId); if (pl != null) { pl.ban = state; pl.banReason = reason; using (gtaContext db = new gtaContext()) { db.Accounts.Update(pl); db.SaveChanges(); } } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void CreateCharacterMinijobEntry(int charId, string job) { try { if (charId <= 0) { return; } var jobData = new Characters_Minijobs { charId = charId, jobName = job, exp = 0 }; CharactersMinijobsData_.Add(jobData); using (gtaContext db = new gtaContext()) { db.Characters_Minijobs.Add(jobData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void NewCompanyLog(int companyId, int charId, int targetCharId, string type, string text) { try { if (companyId <= 0 || charId <= 0) { return; } var logData = new Logs_Company { companyId = companyId, charId = charId, targetCharId = targetCharId, type = type, text = text, timestamp = DateTime.Now }; ServerCompanys.LogsCompany_.Add(logData); using (gtaContext db = new gtaContext()) { db.LogsCompany.Add(logData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void CreateCharacterOwnedClothes(int charId, string clothesName) { try { if (ExistCharacterClothes(charId, clothesName)) { return; } var clothesData = new CharactersOwnedClothes { charId = charId, clothesName = clothesName }; CharactersOwnedClothes_.Add(clothesData); using (var db = new gtaContext()) { db.CharactersOwnedClothes.Add(clothesData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void CreateCharacterLicensesEntry(int charId, bool pkw, bool lkw, bool bike, bool boat, bool fly, bool helicopter, bool passengertransport, bool weaponlicense) { if (charId <= 0) { return; } var licenseData = new Characters_Licenses { charId = charId, PKW = pkw, LKW = lkw, Bike = bike, Boat = boat, Fly = fly, Helicopter = helicopter, PassengerTransport = passengertransport, weaponlicense = weaponlicense }; try { CharactersLicenses_.Add(licenseData); using (gtaContext db = new gtaContext()) { db.Characters_Licenses.Add(licenseData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void CreateNewBankPaper(int accountNumber, string Date, string Time, string Type, string ToOrFrom, string Message, string moneyAmount, string zoneName) { var ServerBankPaperData = new Server_Bank_Paper { accountNumber = accountNumber, Date = Date, Time = Time, Type = Type, ToOrFrom = ToOrFrom, TransactionMessage = Message, moneyAmount = moneyAmount, zoneName = zoneName }; try { ServerBankPaper_.Add(ServerBankPaperData); using (gtaContext db = new gtaContext()) { db.Server_Bank_Paper.Add(ServerBankPaperData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void SetCharacterBankMainKonto(int accountNumber) { try { var charBankAcc = CharactersBank_.FirstOrDefault(x => x.accountNumber == accountNumber); if (charBankAcc == null) { return; } if (charBankAcc.mainAccount) { charBankAcc.mainAccount = false; } else { charBankAcc.mainAccount = true; } using (gtaContext db = new gtaContext()) { db.Characters_Bank.Update(charBankAcc); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void SetApartmentOwner(int hotelId, int apartmentId, int newOwner) { try { if (hotelId <= 0 || apartmentId <= 0) { return; } var hotelApartment = ServerHotelsApartments_.FirstOrDefault(x => x.hotelId == hotelId && x.id == apartmentId); if (hotelApartment != null) { hotelApartment.ownerId = newOwner; hotelApartment.isLocked = true; hotelApartment.lastRent = DateTime.Now; using (gtaContext db = new gtaContext()) { db.Server_Hotels_Apartments.Update(hotelApartment); db.SaveChanges(); } } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void ChangeBankAccountLockStatus(int accountNumber) { try { var charBankAcc = CharactersBank_.FirstOrDefault(x => x.accountNumber == accountNumber); if (charBankAcc == null) { return; } if (charBankAcc.closed) { charBankAcc.closed = false; } else if (!charBankAcc.closed) { charBankAcc.closed = true; } using (gtaContext db = new gtaContext()) { db.Characters_Bank.Update(charBankAcc); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void RemoveServerHotelStorageItemAmount(int apartmentId, string itemName, int itemAmount) { try { if (apartmentId <= 0 || itemName == "" || itemAmount == 0) { return; } var item = ServerHotelsStorage_.FirstOrDefault(i => i.apartmentId == apartmentId && i.itemName == itemName); if (item != null) { using (gtaContext db = new gtaContext()) { int prevAmount = item.amount; item.amount -= itemAmount; if (item.amount > 0) { db.Server_Hotels_Storages.Update(item); db.SaveChanges(); } else { RemoveServerHotelStorageItem(apartmentId, itemName); } } } } catch (Exception _) { Alt.Log($"{_}"); } }
public static void RemoveServerCompanyMember(int companyId, int charId) { try { if (companyId == 0 || charId == 0) { return; } var companyMemberData = ServerCompanysMember_.FirstOrDefault(x => x.companyId == companyId && x.charId == charId); if (companyMemberData != null) { ServerCompanysMember_.Remove(companyMemberData); using (gtaContext db = new gtaContext()) { db.Server_Company_Members.Remove(companyMemberData); db.SaveChanges(); } CharactersTablet.ChangeCharacterTabletAppInstallState(charId, "company", false); } } catch (Exception e) { Alt.Log($"{e}"); } }
public static void CreateCharacterTabletAppEntry(int charId, bool weather, bool news, bool banking, bool lifeinvader, bool vehicles, bool events, bool company, bool notices) { if (charId == 0) { return; } var appData = new Characters_Tablet_Apps { charId = charId, weather = weather, news = news, banking = banking, lifeinvader = lifeinvader, vehicles = vehicles, events = events, company = company, notices = notices }; try { CharactersTabletApps_.Add(appData); using (gtaContext db = new gtaContext()) { db.Characters_Tablet_Apps.Add(appData); db.SaveChanges(); } } catch (Exception e) { Alt.Log($"{e}"); } }