public static void ExitHouse(CondoInfoGlobalData h) { MenuList.HideMenu(); User.SetVirtualWorld(0); User.Teleport(new Vector3(h.x, h.y, h.z)); //SetEntityCoords(GetPlayerPed(-1), ToFloat(Convert.ToInt32(h.x)), ToFloat(Convert.ToInt32(h.y)), ToFloat(Convert.ToInt32(h.z)), true, false, false, true); }
public static void LoadHouse(DataRow row) { var housesObj = new CondoInfoGlobalData() { id = (int)row["id"], address = (string)row["address"], price = (int)row["price"], name_user = (string)row["name_user"], id_user = (int)row["id_user"], pin = (int)row["pin"], x = (float)row["x"], y = (float)row["y"], z = (float)row["z"], int_x = (float)row["int_x"], int_y = (float)row["int_y"], int_z = (float)row["int_z"] }; foreach (var property in typeof(CondoInfoGlobalData).GetProperties()) { Server.Sync.Data.Reset(300000 + housesObj.id, property.Name); Server.Sync.Data.Set(300000 + housesObj.id, property.Name, property.GetValue(housesObj, null)); } CondoGlobalDataList.Add(housesObj); MaxHouses++; }
public static async void MenuExitHouse(CondoInfoGlobalData h) { h = await GetAllData(h.id); if (User.GetPlayerVirtualWorld() == h.id + 10000) { MenuList.ShowCondoInMenu(h); } }
public static void AddCondoGlobalDataList(dynamic data) { Debug.WriteLine("START LOAD HOUSES"); CondoGlobalDataList.Clear(); /*for (int i = 0; i < HouseWater.Length / 4; i++) * { * var pos = new Vector3((float) HouseWater[i, 0], (float) HouseWater[i, 1], (float) HouseWater[i, 2]); * Checkpoint.Create(pos, 1.4f, "house:water"); * Marker.Create(pos, 1f, 1f, Marker.Blue.R, Marker.Blue.G, Marker.Blue.B, Marker.Blue.A); * }*/ for (int i = 0; i < HouseInts.Length / 3; i++) { var pos = new Vector3((float)HouseInts[i, 0], (float)HouseInts[i, 1], (float)HouseInts[i, 2]); Checkpoint.Create(pos, 1.4f, "house"); Marker.Create(pos, 1f, 1f, Marker.Blue.R, Marker.Blue.G, Marker.Blue.B, Marker.Blue.A); } var localData = (IList <Object>)data; foreach (var item in localData) { try { var hInfo = new CondoInfoGlobalData(); var localItem = (IDictionary <String, Object>)item; foreach (var property in typeof(CondoInfoGlobalData).GetProperties()) { property.SetValue(hInfo, localItem[property.Name], null); } Checkpoint.Create(new Vector3(hInfo.x, hInfo.y, hInfo.z), 1.4f, "house"); Marker.Create(new Vector3(hInfo.x, hInfo.y, hInfo.z), 1f, 1f, Marker.Blue.R, Marker.Blue.G, Marker.Blue.B, Marker.Blue.A); /*var blip = World.CreateBlip(new Vector3(hInfo.x, hInfo.y, hInfo.z)); * blip.Sprite = (BlipSprite) 40; * //blip.Name = "Апартаменты"; * blip.IsShortRange = true; * blip.Scale = 0.4f; //86*/ CondoGlobalDataList.Add(hInfo); } catch (Exception e) { Debug.WriteLine(e.ToString(), ""); throw; } } Main.FinishLoad(); Debug.WriteLine($"FINISH LOAD CONDO ({CondoGlobalDataList.Count})"); }
public static async Task <CondoInfoGlobalData> GetAllData(int id) { var data = await Client.Sync.Data.GetAll(300000 + id); if (data == null) { return(new CondoInfoGlobalData()); } var hData = new CondoInfoGlobalData(); var localData = (IDictionary <String, Object>)data; foreach (var property in typeof(CondoInfoGlobalData).GetProperties()) { property.SetValue(hData, localData[property.Name], null); } return(hData); }
public static async void MenuEnterHouse(CondoInfoGlobalData h) { h = await GetAllData(h.id); if (h.id == 0) { Notification.SendWithTime("~r~Произошла ошибка, попробуйте еще раз"); return; } if (h.id_user > 0) { MenuList.ShowCondoOutMenu(h); } else { MenuList.ShowCondoBuyMenu(h); } }
public static async void EnterHouse(CondoInfoGlobalData h) { if ((int)await Client.Sync.Data.Get(300000 + h.id, "pin") > 0) { int pass = Convert.ToInt32(await Menu.GetUserInput("Пароль", null, 5)); if (pass == h.pin) { MenuList.HideMenu(); User.SetVirtualWorld(h.id + 10000); User.Teleport(new Vector3(h.int_x, h.int_y, h.int_z)); } else { Notification.SendWithTime("~r~Вы не верно ввели пароль"); } } else { MenuList.HideMenu(); User.SetVirtualWorld(h.id + 10000); User.Teleport(new Vector3(h.int_x, h.int_y, h.int_z)); } //SetEntityCoords(GetPlayerPed(-1), ToFloat(Convert.ToInt32(h.int_x)), ToFloat(Convert.ToInt32(h.int_y)), ToFloat(Convert.ToInt32(h.int_z)), true, false, false, true); }
public static async void SellHouse(CondoInfoGlobalData h) { if (Screen.LoadingPrompt.IsActive) { Notification.SendWithTime(Lang.GetTextToPlayer("_lang_34")); return; } Client.Sync.Data.ShowSyncMessage = false; Screen.LoadingPrompt.Show("Обработка запроса, подождите"); await User.GetAllData(); var hData = await GetAllData(h.id); var playerId = User.GetServerId(); if (hData.id == 0) { Notification.SendWithTime(Lang.GetTextToPlayer("_lang_35")); return; } if (hData.id_user != User.Data.id) { Notification.SendWithTime("~r~Сожителям запрещено продавать дом"); return; } if (User.Data.condo_id == 0) { Notification.SendWithTime("~r~У Вас нет недвижимости"); return; } Client.Sync.Data.Set(playerId, "condo_id", 0); await Delay(200); if (await Client.Sync.Data.Get(playerId, "condo_id") != 0) { Notification.SendWithTime(Lang.GetTextToPlayer("_lang_32")); return; } var nalog = hData.price * (100 - Coffer.GetNalog()) / 100; User.AddMoney(nalog); Coffer.RemoveMoney(nalog); Main.SaveLog("BuySellCondo", $"[SELL] {User.Data.id} {User.Data.rp_name} | {nalog} | {User.Data.condo_id}"); User.Data.condo_id = 0; Notification.SendWithTime($"~g~{Coffer.GetNalog()}%\n~s~Получено: ~g~${nalog:#,#}"); if (User.Data.reg_status != 3) { Client.Sync.Data.Set(playerId, "reg_time", 28); Client.Sync.Data.Set(playerId, "reg_status", 1); } TriggerServerEvent("ARP:UpdateCondoInfo", "", 0, hData.id); User.SaveAccount(); MenuList.HideMenu(); await User.GetAllData(); Screen.LoadingPrompt.Hide(); Client.Sync.Data.ShowSyncMessage = true; }
public static async void BuyHouse(CondoInfoGlobalData h) { await User.GetAllData(); var hData = await GetAllData(h.id); var playerId = User.GetServerId(); if (hData.id == 0) { Notification.SendWithTime(Lang.GetTextToPlayer("_lang_35")); return; } if (hData.id_user != 0) { Notification.SendWithTime("~r~Недвижимость уже куплена"); return; } if (User.Data.condo_id != 0) { Notification.SendWithTime("~r~У Вас уже есть недвижимость"); return; } if (User.GetMoneyWithoutSync() < hData.price) { Notification.SendWithTime(Lang.GetTextToPlayer("_lang_2")); return; } Client.Sync.Data.Set(playerId, "condo_id", hData.id); await Delay(200); if (await Client.Sync.Data.Get(playerId, "condo_id") == 0) { Notification.SendWithTime(Lang.GetTextToPlayer("_lang_32")); return; } User.RemoveMoney(hData.price); Coffer.AddMoney(hData.price); User.Data.condo_id = hData.id; Main.SaveLog("BuySellCondo", $"[BUY] {User.Data.id} {User.Data.rp_name} | {hData.price} | {User.Data.condo_id}"); Notification.SendWithTime("~g~Поздравляем с покупкой недвижимости"); if (User.Data.reg_status != 3) { Client.Sync.Data.Set(playerId, "reg_time", 372); Client.Sync.Data.Set(playerId, "reg_status", 2); } TriggerServerEvent("ARP:UpdateCondoInfo", User.Data.rp_name, User.Data.id, hData.id); User.SaveAccount(); MenuList.HideMenu(); await Delay(10000); await User.GetAllData(); }