public Vector3 GetRandomPizzaDeliveryLocation(Player player) { int randomNumber = -1; Random rnd = new Random(); while (true) { randomNumber = rnd.Next(house.houses.Count); if (player.HasData("lastHouse") && player.GetData <int>("lastHouse") == randomNumber) { continue; } else { break; } } house.model random_house = house.houses[randomNumber]; if (random_house == null) { Console.WriteLine("Error occured. Check your code."); player.SendChatMessage("Error ocoured. Please contact the server admin."); return(new Vector3()); } player.SetData("lastHouse", randomNumber); return(random_house.enter); }
public static async Task <List <house.model> > loadAllhouses( ) { List <house.model> houses = new List <house.model>(); await databaseManager.selectQuery("SELECT * FROM houses", ( DbDataReader reader ) => { house.model house = new house.model(); house.id = (int)reader["id"]; house.owner = (string)reader["owner"]; house.enter = NAPI.Util.FromJson <Vector3>((string)reader["enterPos"]); house.exit = NAPI.Util.FromJson <Vector3>((string)reader["exitPos"]); house.sale = (int)reader["sale"]; house.rentPrice = (int)reader["rentPrice"]; house.size = (int)reader["size"]; house.locked = (bool)reader["locked"]; house.ipl = (string)reader["ipl"]; house.renters = NAPI.Util.FromJson <List <string> >((string)reader["renters"]); house.description = (string)reader["description"]; houses.Add(house); }).Execute( ); return(houses); }
public static async Task <int> addHouse(house.model house) { int i = await databaseManager.updateQuery($"INSERT INTO houses (owner, enterPos, exitPos, price, ipl, size, description) VALUES ('{house.owner}', '{NAPI.Util.ToJson(house.enter)}', '{NAPI.Util.ToJson(house.exit)}', '{house.sale}', '{house.ipl}', '{house.size}', '{house.description}')").Execute(); return(i); }