public void OnChatMessage(Client player, string message) { if (player.GetData(EntityData.PLAYER_PLAYING) == null) { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_cant_chat); } else if (player.GetData(EntityData.PLAYER_KILLED) != 0) { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_is_dead); } else if (player.GetData(EntityData.PLAYER_ON_AIR) != null) { WeazelNews.SendNewsMessage(player, message); } else if (player.GetData(EntityData.PLAYER_PHONE_TALKING) != null) { // Target player of the message Client target = player.GetData(EntityData.PLAYER_PHONE_TALKING); // We send the message to the player and target player.SendChatMessage(Constants.COLOR_CHAT_PHONE + GenRes.phone + player.Name + GenRes.chat_say + message); target.SendChatMessage(Constants.COLOR_CHAT_PHONE + GenRes.phone + player.Name + GenRes.chat_say + message); // We send the message to nearby players SendMessageToNearbyPlayers(player, message, Constants.MESSAGE_PHONE, player.Dimension > 0 ? 7.5f : 10.0f, true); } else { SendMessageToNearbyPlayers(player, message, Constants.MESSAGE_TALK, player.Dimension > 0 ? 7.5f : 10.0f); NAPI.Util.ConsoleOutput("[ID:" + player.Value + "]" + player.Name + GenRes.chat_say + message); } }
private void OnChatMessageHandler(Client player, string message, CancelEventArgs e) { try { if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_PLAYING) == false) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_CANT_CHAT); } else if (NAPI.Data.GetEntityData(player, EntityData.PLAYER_KILLED) != 0) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_IS_DEAD); } else if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_ON_AIR) == true) { WeazelNews.SendNewsMessage(player, message); } else if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_PHONE_TALKING) == true) { // Obtenemos el jugador destinatario Client target = NAPI.Data.GetEntityData(player, EntityData.PLAYER_PHONE_TALKING); // Comprobación de la longitud del mensaje String secondMessage = String.Empty; if (message.Length > Constants.CHAT_LENGTH) { // El mensaje tiene una longitud de dos líneas secondMessage = message.Substring(Constants.CHAT_LENGTH, message.Length - Constants.CHAT_LENGTH); message = message.Remove(Constants.CHAT_LENGTH, secondMessage.Length); } // Mandamos el mensaje al jugador y al objetivo NAPI.Chat.SendChatMessageToPlayer(player, secondMessage.Length > 0 ? Constants.COLOR_CHAT_PHONE + "[Teléfono] " + player.Name + " dice: " + message + "..." : Constants.COLOR_CHAT_PHONE + "[Teléfono] " + player.Name + " dice: " + message); NAPI.Chat.SendChatMessageToPlayer(target, secondMessage.Length > 0 ? Constants.COLOR_CHAT_PHONE + "[Teléfono] " + player.Name + " dice: " + message + "..." : Constants.COLOR_CHAT_PHONE + "[Teléfono] " + player.Name + " dice: " + message); if (secondMessage.Length > 0) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_CHAT_PHONE + secondMessage); NAPI.Chat.SendChatMessageToPlayer(target, Constants.COLOR_CHAT_PHONE + secondMessage); } // Mandamos el mensaje a los jugadores cercanos SendMessageToNearbyPlayers(player, message, Constants.MESSAGE_PHONE, NAPI.Entity.GetEntityDimension(player) > 0 ? 7.5f : 10.0f, true); } else { SendMessageToNearbyPlayers(player, message, Constants.MESSAGE_TALK, NAPI.Entity.GetEntityDimension(player) > 0 ? 7.5f : 10.0f); NAPI.Util.ConsoleOutput("[ID:" + player.Value + "]" + player.Name + " dice: " + message); } } catch (Exception ex) { NAPI.Util.ConsoleOutput("[EXCEPTION Chat.OnChatMessageHandler] " + ex.Message); } finally { e.Cancel = true; } }
public void OnChatMessage(Client player, string message) { if (player.HasData(EntityData.PLAYER_PLAYING) == false) { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_cant_chat); } else if (player.GetData(EntityData.PLAYER_KILLED) != 0) { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_is_dead); } else if (player.HasData(EntityData.PLAYER_ON_AIR) == true) { WeazelNews.SendNewsMessage(player, message); } else if (player.HasData(EntityData.PLAYER_PHONE_TALKING) == true) { // Target player of the message Client target = player.GetData(EntityData.PLAYER_PHONE_TALKING); string secondMessage = string.Empty; if (message.Length > Constants.CHAT_LENGTH) { // We split the message in two lines secondMessage = message.Substring(Constants.CHAT_LENGTH, message.Length - Constants.CHAT_LENGTH); message = message.Remove(Constants.CHAT_LENGTH, secondMessage.Length); } // We send the message to the player and target player.SendChatMessage(secondMessage.Length > 0 ? Constants.COLOR_CHAT_PHONE + GenRes.phone + player.Name + GenRes.chat_say + message + "..." : Constants.COLOR_CHAT_PHONE + GenRes.phone + player.Name + GenRes.chat_say + message); target.SendChatMessage(secondMessage.Length > 0 ? Constants.COLOR_CHAT_PHONE + GenRes.phone + player.Name + GenRes.chat_say + message + "..." : Constants.COLOR_CHAT_PHONE + GenRes.phone + player.Name + GenRes.chat_say + message); if (secondMessage.Length > 0) { player.SendChatMessage(Constants.COLOR_CHAT_PHONE + secondMessage); target.SendChatMessage(Constants.COLOR_CHAT_PHONE + secondMessage); } // We send the message to nearby players SendMessageToNearbyPlayers(player, message, Constants.MESSAGE_PHONE, player.Dimension > 0 ? 7.5f : 10.0f, true); } else { SendMessageToNearbyPlayers(player, message, Constants.MESSAGE_TALK, player.Dimension > 0 ? 7.5f : 10.0f); NAPI.Util.ConsoleOutput("[ID:" + player.Value + "]" + player.Name + GenRes.chat_say + message); } }
public void OnChatMessage(Client player, string message) { if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_PLAYING) == false) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_CANT_CHAT); } else if (NAPI.Data.GetEntityData(player, EntityData.PLAYER_KILLED) != 0) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_IS_DEAD); } else if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_ON_AIR) == true) { WeazelNews.SendNewsMessage(player, message); } else if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_PHONE_TALKING) == true) { // Target player of the message Client target = NAPI.Data.GetEntityData(player, EntityData.PLAYER_PHONE_TALKING); String secondMessage = String.Empty; if (message.Length > Constants.CHAT_LENGTH) { // We split the message in two lines secondMessage = message.Substring(Constants.CHAT_LENGTH, message.Length - Constants.CHAT_LENGTH); message = message.Remove(Constants.CHAT_LENGTH, secondMessage.Length); } // We send the message to the player and target NAPI.Chat.SendChatMessageToPlayer(player, secondMessage.Length > 0 ? Constants.COLOR_CHAT_PHONE + Messages.GEN_PHONE + player.Name + Messages.GEN_CHAT_SAY + message + "..." : Constants.COLOR_CHAT_PHONE + Messages.GEN_PHONE + player.Name + Messages.GEN_CHAT_SAY + message); NAPI.Chat.SendChatMessageToPlayer(target, secondMessage.Length > 0 ? Constants.COLOR_CHAT_PHONE + Messages.GEN_PHONE + player.Name + Messages.GEN_CHAT_SAY + message + "..." : Constants.COLOR_CHAT_PHONE + Messages.GEN_PHONE + player.Name + Messages.GEN_CHAT_SAY + message); if (secondMessage.Length > 0) { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_CHAT_PHONE + secondMessage); NAPI.Chat.SendChatMessageToPlayer(target, Constants.COLOR_CHAT_PHONE + secondMessage); } // We send the message to nearby players SendMessageToNearbyPlayers(player, message, Constants.MESSAGE_PHONE, NAPI.Entity.GetEntityDimension(player) > 0 ? 7.5f : 10.0f, true); } else { SendMessageToNearbyPlayers(player, message, Constants.MESSAGE_TALK, NAPI.Entity.GetEntityDimension(player) > 0 ? 7.5f : 10.0f); NAPI.Util.ConsoleOutput("[ID:" + player.Value + "]" + player.Name + Messages.GEN_CHAT_SAY + message); } }