private static void DialogSpawns_Response(object sender, DialogResponseEventArgs e, PlayerClassType classId) { if (e.DialogButton != DialogButton.Left) { return; } if (!(e.Player is Player player)) { return; } var spawns = new ClassSpawnRepository(ConnectionFactory.GetConnection).GetAllByClassType((int)classId); switch (classId) { default: player.Position = new Vector3(spawns.ElementAt(e.ListItem).PositionX, spawns.ElementAt(e.ListItem).PositionY, spawns.ElementAt(e.ListItem).PositionZ); break; } }
private void Class_PlayerRequestSpawn(object sender, RequestSpawnEventArgs e) { if (!(sender is Player player)) { return; } var random = new Random(); var angle = 0.0f; var position = Vector3.Zero; var spawns = new ClassSpawnRepository(ConnectionFactory.GetConnection).GetAllByClassType((int)player.PlayerClass); var index = random.Next(0, spawns.Count()); switch (player.PlayerClass) { case PlayerClassType.TruckDriver: position = new Vector3(spawns.ElementAt(index).PositionX, spawns.ElementAt(index).PositionY, spawns.ElementAt(index).PositionZ); angle = spawns.ElementAt(index).Angle; BasePlayer.SendClientMessageToAll(Messages.PlayerJoinedTruckerClass, player.Name); break; case PlayerClassType.BusDriver: position = new Vector3(spawns.ElementAt(index).PositionX, spawns.ElementAt(index).PositionY, spawns.ElementAt(index).PositionZ); angle = spawns.ElementAt(index).Angle; BasePlayer.SendClientMessageToAll(Messages.PlayerJoinedBusDriverClass, player.Name); break; case PlayerClassType.Pilot: position = new Vector3(spawns.ElementAt(index).PositionX, spawns.ElementAt(index).PositionY, spawns.ElementAt(index).PositionZ); angle = spawns.ElementAt(index).Angle; BasePlayer.SendClientMessageToAll(Messages.PlayerJoinedPilotClass, player.Name); break; case PlayerClassType.Police: if (!player.CheckIfPlayerCanJoinPolice()) { e.PreventSpawning = true; return; } if (player.Account.Score < 100) { player.GameText("You need 100 score points for police class", 5000, 4); player.SendClientMessage(Color.Red, "You need 100 score points for police class"); e.PreventSpawning = true; return; } if (player.Account.Wanted > 0) { player.GameText("You are not allowed to choose police class when you're wanted", 5000, 4); player.SendClientMessage(Color.Red, "You are not allowed to choose police class when you're wanted"); e.PreventSpawning = true; return; } position = new Vector3(spawns.ElementAt(index).PositionX, spawns.ElementAt(index).PositionY, spawns.ElementAt(index).PositionZ); angle = spawns.ElementAt(index).Angle; BasePlayer.SendClientMessageToAll(Messages.PlayerJoinedPoliceClass, player.Name); break; case PlayerClassType.Mafia: position = new Vector3(spawns.ElementAt(index).PositionX, spawns.ElementAt(index).PositionY, spawns.ElementAt(index).PositionZ); angle = spawns.ElementAt(index).Angle; BasePlayer.SendClientMessageToAll(Messages.PlayerJoinedMafiaClass, player.Name); break; case PlayerClassType.Assistance: position = new Vector3(spawns.ElementAt(index).PositionX, spawns.ElementAt(index).PositionY, spawns.ElementAt(index).PositionZ); angle = spawns.ElementAt(index).Angle; BasePlayer.SendClientMessageToAll(Messages.PlayerJoinedAssistanceClass, player.Name); break; } player.SetSpawnInfo(0, player.Skin, position, angle); }