public async Task CMD_crearnegocio(Player player, int type) { //var user = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS"); if (user.adminLv == 5) { if (type == 1 || type == 2) { int bankId = await World.Banks.DatabaseFunctions.CreateBank(player, type); ColShape bank = NAPI.ColShape.CreateCylinderColShape(player.Position, 2, 6); TextLabel label = NAPI.TextLabel.CreateTextLabel("Pulsa ~y~F5 ~w~para interactuar", player.Position.Subtract(new Vector3(0, 0, 0.1)), 15, 6, 2, new Color(255, 255, 255)); Marker marker = NAPI.Marker.CreateMarker(0, player.Position.Subtract(new Vector3(0, 0, 0.1)), new Vector3(), new Vector3(), 1, new Color(251, 244, 1)); Blip blip = NAPI.Blip.CreateBlip(player.Position); if (type == 1) { blip.Sprite = 108; blip.Scale = 1f; blip.ShortRange = true; blip.Name = "Banco"; blip.Color = 5; } else { blip.Sprite = 277; blip.Scale = 1f; blip.ShortRange = true; blip.Name = "ATM"; blip.Color = 5; } Data.Entities.Bank banco = new Data.Entities.Bank { blip = blip, marker = marker, label = label, id = bankId, type = type }; //bank.SetExternalData<Data.Entities.Bank>(0, banco); bank.SetData("BANK_CLASS", banco); Utilities.Notifications.SendNotificationOK(player, $"Has creado el banco con ID {bankId}"); } else { player.SendChatMessage("<font color='red'>ERROR</font> No existe ese tipo de banco"); } } else { player.SendChatMessage("<font color='red'>[ERROR]</font> El comando no existe. (/ayuda para mas información)"); } }
public async static Task SpawnBank() { using (MySqlConnection connection = new MySqlConnection(Data.DatabaseHandler.connectionHandle)) { await connection.OpenAsync().ConfigureAwait(false); MySqlCommand command = connection.CreateCommand(); command.CommandText = "SELECT * FROM banks"; DbDataReader reader = await command.ExecuteReaderAsync().ConfigureAwait(false); if (reader.HasRows) { while (await reader.ReadAsync().ConfigureAwait(false)) { int id = reader.GetInt32(reader.GetOrdinal("id")); int type = reader.GetInt32(reader.GetOrdinal("type")); double x = reader.GetDouble(reader.GetOrdinal("x")); double y = reader.GetDouble(reader.GetOrdinal("y")); double z = reader.GetDouble(reader.GetOrdinal("z")); string a_id = Convert.ToString(id); NAPI.Task.Run(() => { Vector3 position = new Vector3(x, y, z); ColShape bank = NAPI.ColShape.CreateCylinderColShape(position.Subtract(new Vector3(0, 0, 1)), 2, 6); TextLabel label = NAPI.TextLabel.CreateTextLabel("Pulsa ~y~F5 ~w~para interactuar", position.Subtract(new Vector3(0, 0, 0.1)), 15, 6, 2, new Color(255, 255, 255)); Marker marker = NAPI.Marker.CreateMarker(0, position.Subtract(new Vector3(0, 0, 0.1)), new Vector3(), new Vector3(), 1, new Color(251, 244, 1)); Blip blip; if (type == 1) { blip = NAPI.Blip.CreateBlip(108, position, 1, 5, "Banco"); //blip.ShortRange = true; } else { blip = NAPI.Blip.CreateBlip(277, position, 1, 5, "ATM"); //blip.ShortRange = true; } Data.Entities.Bank banco = new Data.Entities.Bank { blip = blip, marker = marker, label = label, id = id, type = type }; //bank.SetExternalData<Data.Entities.Bank>(0, banco); bank.SetData("BANK_CLASS", banco); }); Data.Info.banksSpawned++; } } } }
public void Banks_EnterColShape(ColShape shape, Client player) { //var banco = shape.GetExternalData<Data.Entities.Bank>(0); if (!shape.HasData("BANK_CLASS")) { return; } Data.Entities.Bank banco = shape.GetData("BANK_CLASS"); //var user = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData("USER_CLASS"); if (banco != null) { user.isInBank = true; user.bankEntity = banco; } }