public async void Login(Client sender, string username, string password) { Master masterAccount; if (username.Contains("@")) { masterAccount = await MasterRepository.GetMasterDataByEmail(username); } else { masterAccount = await MasterRepository.GetMasterDataByName(username); } if (masterAccount != null) { if (Crypter.CheckPassword(password, masterAccount.Password)) { string[] charNames = new string[5]; List <string> charImgs = new List <string>() { "", "", "", "", "" }; string[] factions = new string[5]; masterAccount.Players = await PlayerRepository.GetAllPlayerDataByMasterAccount(masterAccount); masterAccount.Client = sender; int count = 0; foreach (Player p in masterAccount.Players) { charNames[count] = p.Username.Roleplay(); charImgs[count] = p.Skin == 797459875 ? Images.SkinBlobs[p.Skin] : ""; if (p.FactionId != 0) { factions[count] = $"{FactionRepository.GetFactionById(p.FactionId).Name}<br/>{RankRepository.GetRankByFactionAndId(p.FactionId, p.FactionRank).Title}"; } else { factions[count] = "Civilian"; } count++; } Master.MasterData.Add(masterAccount); API.triggerClientEvent(sender, "playerLogResult", "success", masterAccount.Players.Count, string.Join(",", charNames), string.Join(",", factions), string.Join(".", charImgs)); masterAccount.LatestLogin = Server.Date; masterAccount.LatestIP = sender.address; masterAccount.ActiveConnectionLog = new ConnectionLog(masterAccount.Id, -1, API.getPlayerAddress(sender)); ConnectionLogRepository.AddNew(masterAccount.ActiveConnectionLog); MasterRepository.UpdateAsync(masterAccount); masterAccount.AdminLevel = 6; } else { API.triggerClientEvent(sender, "playerLogResult", "incorrect-pass"); API.SendErrorNotification(sender, "You have entered an incorrect password"); } } else { API.triggerClientEvent(sender, "playerLogResult", "invalid-user"); API.SendErrorNotification(sender, "You have entered an invalid username"); } }
private void OnClientEventTrigger(Client sender, string eventName, params object[] arguments) { switch (eventName) { case "onLoginSubmitted": Login(sender, arguments[0].ToString(), arguments[1].ToString()); break; case "player-selected": API.sendNativeToPlayer(sender, Hash._TRANSITION_FROM_BLURRED, 8.0); Player newPlayer = Master.MasterData.Single(m => m.Client == sender).Players[(int)arguments[0]]; newPlayer.Client = sender; Console.WriteLine("here"); newPlayer.MasterAccount = Master.MasterData.Single(m => m.Client == sender); PlayerInit(newPlayer); sender.FadeOutIn(200, 1000); break; case "CreateNewCharacter": API.sendNativeToPlayer(sender, Hash._TRANSITION_FROM_BLURRED, 8.0); sender.setSkin((PedHash)PedSkins.Gender.Where(p => p.Value == 0).ElementAt(new Random().Next(0, PedSkins.Gender.Count(p => p.Value == 0))).Key); sender.FadeOutIn(300, 2000); sender.position = new Vector3(9.284171, 6512.242, 31.87785); sender.rotation = new Vector3(0, 0, 310); sender.playAnimation("amb@world_human_hang_out_street@male_b@base", "base", 0); sender.dimension = Globals.GetPlayerID(sender) + 1; break; case "CreateCharUsernameCheck": API.triggerClientEvent(sender, "createCharUsernameResult", PlayerRepository.GetPlayersWithUsernameCount(arguments[0].ToString())); break; case "CancelCharCreate": Master ma = Master.MasterData.Single(me => me.Client == sender); string[] charNames = new string[5]; List <string> charImgs = new List <string>() { "", "", "", "", "" }; string[] factions = new string[5]; int count = 0; foreach (Player p in ma.Players) { charNames[count] = p.Username.Roleplay(); charImgs[count] = p.Skin == 797459875 ? Images.SkinBlobs[p.Skin] : ""; if (p.FactionId != 0) { factions[count] = $"{FactionRepository.GetFactionById(p.FactionId).Name}<br/>{RankRepository.GetRankByFactionAndId(p.FactionId, p.FactionRank).Title}"; } else { factions[count] = "Civilian"; } count++; } API.triggerClientEvent(sender, "playerLogResult", "success", ma.Players.Count, string.Join(",", charNames), string.Join(",", factions), string.Join(".", charImgs)); API.triggerClientEvent(sender, "showLoginCam"); break; case "CreateNewCharacterProceed": CreateCharacter(sender, arguments[0].ToString(), (int)arguments[1], new DateTime((int)arguments[4], (int)arguments[3], (int)arguments[2])); break; case "CreateCharacterChangeGender": if ((int)arguments[0] == 0) { sender.setSkin((PedHash)PedSkins.Gender.Where(p => p.Value == 0).ElementAt(new Random().Next(0, PedSkins.Gender.Count(p => p.Value == 0))).Key); } else { sender.setSkin((PedHash)PedSkins.Gender.Where(p => p.Value == 1).ElementAt(new Random().Next(0, PedSkins.Gender.Count(p => p.Value == 1))).Key); } break; case "SkinSelectCategory": SelectSkinCategory(sender, (int)arguments[0]); break; case "SkinSelectChange": SelectSkinChange(sender, (int)arguments[0]); break; case "SkinCustomisationOptions": GetSkinCustomisationOptions(sender, (int)arguments[0]); break; case "SkinCustomTypeChange": SkinCustomTypeChange(sender, (int)arguments[0], (int)arguments[1], (int)arguments[2]); break; case "SkinCustomTextureChange": SkinCustomTextureChange(sender, (int)arguments[0], (int)arguments[1], (int)arguments[2]); break; case "CreateCharacterComplete": CompleteCharCreation(sender); break; } }
private async void OnResourceStart() { Faction.FactionData = await FactionRepository.GetAllFactions(); foreach (Faction f in Faction.FactionData) { f.Ranks = await RankRepository.GetRanksByFactionId(f.Id); f.Vehicles = await VehicleRepository.GetAllVehiclesByFactionId(f.Id); await Task.Run(async() => { foreach (Vehicle v in f.Vehicles) { GrandTheftMultiplayer.Server.Elements.Vehicle vehicle = API.createVehicle((VehicleHash)v.Model, v.SavePosition, v.SaveRotation, 0, 0, v.Dimension); v.Entity = vehicle; v.UnoccupiedPosition = v.SavePosition; v.UnoccupiedRotation = v.SaveRotation; if (v.Color1.Length > 3) { v.Entity.customPrimaryColor = v.CustomColor(v.Color1); } else { v.Entity.primaryColor = int.Parse(v.Color1); } if (v.Color2.Length > 3) { v.Entity.customSecondaryColor = v.CustomColor(v.Color2); } else { v.Entity.secondaryColor = int.Parse(v.Color2); } for (int i = 0; i < 2000; i++) { if (Vehicle.IDs[i] != null) { continue; } Vehicle.IDs[i] = vehicle; break; } v.TrunkItems = new List <Inventory>(); v.IsEngineOn = false; vehicle.engineStatus = v.IsEngineOn; vehicle.health = (float)v.Health; vehicle.invincible = false; vehicle.numberPlate = v.LicensePlate; vehicle.numberPlateStyle = v.LicensePlateStyle; v.IsAdminVehicle = false; v.IsDealerVehicle = false; //for (int w = 0; w < v.WindowData.Length; w++) // API.breakVehicleWindow(vehicle, w, v.WindowData[w] == 1 ? true : false); API.setVehicleLocked(vehicle, v.Locked); //c = 1; //foreach (int d in v.DoorData) { // if (d == 1) // vehicle.breakDoor(c); // c++; //} v.Entity = vehicle; Vehicle.VehicleData.Add(vehicle, v); await Task.Delay(100); } }); } }