/// <summary> /// Wysyła wiadomość /me. /// </summary> /// <param name="charData"></param> /// <param name="message"></param> /// <param name="systemMe"></param> public static void SendPlayerMeMessage(Character charData, string message, bool systemMe) { if (charData == null) { return; } message = Command.UpperFirst(message, true, false); string outputMessage = systemMe ? "* " : "** "; outputMessage += $"{Player.GetPlayerIcName(charData)} {message}"; IEnumerable <Character> playersInRadius = Global.GetPlayersInRange(charData.PlayerHandle.Position, Constants.RadiusTalk, charData.PlayerHandle.Dimension); foreach (Character entry in playersInRadius) { double progress = Global.GetDistanceBetweenPositions(charData.PlayerHandle.Position, entry.PlayerHandle.Position) / Constants.RadiusTalk; int r = (int)Math.Floor(Global.Lerp(194, 144, (float)progress)), g = (int)Math.Floor(Global.Lerp(162, 112, (float)progress)), b = (int)Math.Floor(Global.Lerp(218, 168, (float)progress)); entry.PlayerHandle.SendChatMessage($"!{{{r}, {g}, {b}}}{outputMessage}"); Log.LogPlayer(entry, outputMessage, LogType.ActionIc); } }
public void Command_W(Client player, string args = "") { Character charData = Account.GetPlayerData(player); if (charData == null) { return; } string[] arguments = Command.GetCommandArguments(args); if (arguments.Length < 2) { Ui.ShowUsage(player, "/w [ID gracza] [treść wiadomości]"); return; } int serverId = Command.GetNumberFromString(arguments[0]); if (serverId == Command.InvalidNumber) { Ui.ShowError(player, "Podano niepoprawne ID gracza."); return; } Character targetData = Account.GetPlayerDataByServerId(serverId); if (targetData == null) { Ui.ShowError(player, "Nie znaleziono gracza o podanym Id."); return; } string message = Command.UpperFirst(Command.GetConcatString(arguments, 1)); if (charData.Id == targetData.Id) { Ui.ShowError(player, "Nie możesz wysyłać prywatnych wiadomości do siebie."); return; } if (targetData.WhisperBlock && !charData.HasAdminDuty) { Ui.ShowError(player, "Gracz ma zablokowane otrzymywanie prywatnych wiadomości."); return; } string forTarget = $"!{{#DEA909}}{Player.GetPlayerIcName(charData, true)}: {message}"; string forSender = $"!{{#E0E02F}}{Player.GetPlayerIcName(targetData, true)}: {message}"; NAPI.Chat.SendChatMessageToPlayer(charData.PlayerHandle, forSender); NAPI.Chat.SendChatMessageToPlayer(targetData.PlayerHandle, forTarget); Log.LogPlayer(charData, "(NADAWCA) " + forSender, LogType.PwSend); Log.LogPlayer(targetData, "(ODBIORCA) " + forTarget, LogType.PwSend); targetData.LastWhisper = charData.PlayerHandle; }
public void Command_Tm(Client player, string args = "") { Character charData = Account.GetPlayerData(player); if (charData == null) { return; } if (charData.AdminLevel <= 0) { return; } if (!Library.DoesPlayerHasAdminPerm(charData, Permissions.CoreTeleport, true)) { return; } string[] arguments = Command.GetCommandArguments(args); if (arguments.Length < 1) { Ui.ShowUsage(player, "/tm [ID gracza]"); return; } int serverId = Command.GetNumberFromString(arguments[0]); if (serverId == Command.InvalidNumber) { Ui.ShowError(player, "Podano niepoprawne ID gracza."); return; } Character targetData = Account.GetPlayerDataByServerId(serverId); if (targetData == null) { Ui.ShowError(player, "Nie znaleziono gracza o podanym Id."); return; } targetData.PlayerHandle.WarpOutOfVehicle(); targetData.PlayerHandle.Dimension = charData.PlayerHandle.Dimension; targetData.PlayerHandle.Position = charData.PlayerHandle.Position; Log.LogPlayer(charData, $"Teleportowano gracza {Player.GetPlayerDebugName(targetData)} do siebie", LogType.Teleport); }
/// <summary> /// Dodaje pieniądze na konto bankowe gracza /// </summary> /// <param name="charData"></param> /// <param name="amount"></param> /// <param name="description"></param> /// <returns></returns> public static bool GivePlayerBankCash(Character charData, int amount, string description) { if (charData == null) { return(false); } if (amount <= 0) { return(false); } amount = Math.Abs(amount); charData.AccountBalance += amount; charData.Save(); Log.LogPlayer(charData, $"Dodano ${amount} na konto bankowe. Stan konta: ${charData.AccountBalance}. Opis: " + $"{Command.UpperFirst(description)}", LogType.MoneyTook); return(true); }
/// <summary> /// Wysyła wiadomość /do /// </summary> /// <param name="charData"></param> /// <param name="message"></param> /// <param name="systemDo"></param> public static void SendPlayerDoMessage(Character charData, string message, bool systemDo) { if (charData == null) { return; } message = Command.UpperFirst(message); string outputMessage = systemDo ? "* " : "** "; outputMessage += $"{message} (( {Player.GetPlayerIcName(charData)} ))"; IEnumerable <Character> playersInRadius = Global.GetPlayersInRange(charData.PlayerHandle.Position, Constants.RadiusTalk, charData.PlayerHandle.Dimension); foreach (Character entry in playersInRadius) { entry.PlayerHandle.SendChatMessage($"!{{#9A9CCD}}{outputMessage}"); Log.LogPlayer(entry, outputMessage, LogType.ActionIc); } }
/// <summary> /// Dodaje pieniądze do portfela gracza /// </summary> /// <param name="charData"></param> /// <param name="amount"></param> /// <param name="description"></param> /// <returns></returns> public static bool GivePlayerWalletCash(Character charData, int amount, string description) { if (charData == null) { return(false); } if (amount <= 0) { return(false); } amount = Math.Abs(amount); charData.Cash += amount; charData.Save(); NAPI.ClientEvent.TriggerClientEvent(charData.PlayerHandle, "client.money.update", charData.Cash); Log.LogPlayer(charData, $"Dodano ${amount}. Ilość pieniędzy w portfelu: {charData.Cash}. Opis: {description}.", LogType.MoneyAdded); return(true); }
public void Command_B(Client player, string args = "") { Character charData = Account.GetPlayerData(player); if (charData == null) { return; } string[] arguments = Command.GetCommandArguments(args); if (arguments.Length < 1) { Ui.ShowUsage(player, "/b [treść wiadomości]"); return; } IEnumerable <Character> playersInRadius = Global.GetPlayersInRange(charData.PlayerHandle.Position, Constants.RadiusTalk, charData.PlayerHandle.Dimension); string outputMessage = $"(( {Player.GetPlayerIcName(charData, true)} " + $"{Command.UpperFirst(Command.GetConcatString(arguments))} ))"; foreach (Character entry in playersInRadius) { double progress = Global.GetDistanceBetweenPositions(charData.PlayerHandle.Position, entry.PlayerHandle.Position) / Constants.RadiusTalk; int r = (int)Math.Floor(Global.Lerp(252, 202, (float)progress)), g = (int)Math.Floor(Global.Lerp(232, 182, (float)progress)), b = (int)Math.Floor(Global.Lerp(232, 182, (float)progress)); entry.PlayerHandle.SendChatMessage($"!{{{r}, {g}, {b}}}{outputMessage}"); Log.LogPlayer(entry, outputMessage, LogType.ChatOoc); } }
public void CmdAset(Client player, string args = "") { Character charData = Account.GetPlayerData(player); if (charData == null) { return; } if (charData.AdminLevel == 0) { return; } const string legend = "/aset [admin, vw, hp, pogoda, czas, nick, pieniadze, pozycja]"; string[] arguments = Command.GetCommandArguments(args); if (arguments.Length < 1) { Ui.ShowUsage(player, legend); return; } string option = arguments[0].ToLower(); if (option == "admin") { if (!Library.DoesPlayerHasAdminPerm(charData, Permissions.AsetAdmin, true)) { return; } if (arguments.Length - 1 < 1) { Ui.ShowUsage(player, "/aset admin [ID gracza]"); return; } int targetId = Command.GetNumberFromString(arguments[1]); if (targetId == Command.InvalidNumber) { Ui.ShowError(player, "Podano niepoprawne Id gracza."); return; } Character targetData = Account.GetPlayerDataByServerId(targetId); if (targetData == null) { Ui.ShowError(player, "Nie znaleziono takiego gracza."); return; } List <DialogColumn> dialogColumns = new List <DialogColumn> { new DialogColumn("Ranga", 90) }; List <DialogRow> dialogRows = new List <DialogRow> { new DialogRow(0, new[] { "Brak" }), new DialogRow(1, new[] { "Helper" }), new DialogRow(2, new[] { "Support (1)" }), new DialogRow(3, new[] { "Support (2)" }), new DialogRow(4, new[] { "Support (3)" }), new DialogRow(5, new[] { "Support (4)" }), new DialogRow(6, new[] { "Gamemaster" }), new DialogRow(7, new[] { "Administrator" }), new DialogRow(8, new[] { "Developer" }), new DialogRow(9, new[] { "Moderator serwera" }), new DialogRow(10, new[] { "Senior moderator" }) }; string[] dialogButtons = { "Wybierz", "Anuluj" }; Dictionary <string, object> data = new Dictionary <string, object> { { "targetData", targetData } }; Account.SetServerData(charData, Account.ServerData.TempDialogData, data); Dialogs.Library.CreateDialog(player, DialogId.ChooseAdminLevel, "Wybierz poziom administratora", dialogColumns, dialogRows, dialogButtons); } else if (option == "vw") { if (!Library.DoesPlayerHasAdminPerm(charData, Permissions.AsetVw, true)) { return; } if (arguments.Length - 1 < 2) { Ui.ShowUsage(player, "/aset vw [ID gracza] [virtual world]"); return; } int targetId = Command.GetNumberFromString(arguments[1]); if (targetId == Command.InvalidNumber) { Ui.ShowError(player, "Podano niepoprawne Id gracza."); return; } Character targetData = Account.GetPlayerDataByServerId(targetId); if (targetData == null) { Ui.ShowError(player, "Nie znaleziono takiego gracza."); return; } int dimension = Command.GetNumberFromString(arguments[2]); if (dimension == Command.InvalidNumber) { Ui.ShowError(player, "Podano niepoprawny virtual world"); return; } targetData.PlayerHandle.Dimension = (uint)dimension; Ui.ShowInfo(player, $"Zmieniłeś graczowi {Player.GetPlayerIcName(targetData, true)} vw na {dimension}."); Ui.ShowInfo(targetData.PlayerHandle, $"Administrator {Player.GetPlayerOocName(charData)} zmienił Ci vw na {dimension}."); Log.LogPlayer(targetData, $"Zmiana vw na {dimension} przez {Player.GetPlayerDebugName(charData)}", LogType.Teleport); } else if (option == "hp") { if (!Library.DoesPlayerHasAdminPerm(charData, Permissions.AsetHp, true)) { return; } if (arguments.Length - 1 < 2) { Ui.ShowUsage(player, "/aset hp [ID gracza] [ilość hp]"); return; } int targetId = Command.GetNumberFromString(arguments[1]); if (targetId == Command.InvalidNumber) { Ui.ShowError(player, "Podano niepoprawne Id gracza."); return; } Character targetData = Account.GetPlayerDataByServerId(targetId); if (targetData == null) { Ui.ShowError(player, "Nie znaleziono takiego gracza."); return; } int hp = Command.GetNumberFromString(arguments[2]); if (hp < 0 || hp > 100) { Ui.ShowError(player, "HP musi zawierać się w przedziale [0 - 100]."); return; } targetData.PlayerHandle.Health = hp; targetData.Health = hp; Ui.ShowInfo(player, $"Zmieniłeś graczowi {Player.GetPlayerIcName(targetData, true)} hp na {hp}."); Ui.ShowInfo(targetData.PlayerHandle, $"Administrator {Player.GetPlayerOocName(charData)} zmienił Ci hp na {hp}."); Log.LogPlayer(targetData, $"Zmiana hp na {hp} przez {Player.GetPlayerDebugName(charData)}", LogType.ChangeHp); } else if (option == "pogoda") { if (!Library.DoesPlayerHasAdminPerm(charData, Permissions.AsetVw, true)) { return; } if (arguments.Length - 1 < 1) { Ui.ShowUsage(player, "/aset pogoda [ID pogody]"); return; } int weatherId = Command.GetNumberFromString(arguments[1]); if (weatherId < 0 || weatherId > Data.Weathers.Count - 1) { Ui.ShowError(player, "ID pogody może zawierać się w przedziale [0 - 13]"); return; } NAPI.World.SetWeather(Data.Weathers[weatherId]); Ui.ShowInfo(player, $"Ustawiłeś pogodę na {Enum.GetName(typeof(Weather), Data.Weathers[weatherId]).ToUpper()}."); } else if (option == "pozycja") { Player.SendFormattedChatMessage(player, $"Twoja aktualna pozycja: new Vector3({player.Position.X:F2}, {player.Position.Y:F2}, " + $"{player.Position.Z:F2})", Constants.ColorDelRio); } else if (option == "czas") { if (!Library.DoesPlayerHasAdminPerm(charData, Permissions.AsetCzas, true)) { return; } if (arguments.Length - 1 < 1) { Ui.ShowUsage(player, "/aset czas [godzina]"); return; } int hour = Command.GetNumberFromString(arguments[1]); if (hour < 0 || hour > 23) { Ui.ShowError(player, "Czas musi zawierać się w granicach [0 - 23]"); return; } NAPI.World.SetTime(hour, 0, 0); Ui.ShowInfo(player, $"Ustawiłeś czas serwera na godzinę {hour}."); } else if (option == "nick") { if (!Library.DoesPlayerHasAdminPerm(charData, Permissions.AsetNick, true)) { return; } if (arguments.Length - 1 < 2) { Ui.ShowUsage(player, "/aset nick [ID gracza] [nowy nick (wpisz usun aby przywrócić standardowy)]"); return; } int targetId = Command.GetNumberFromString(arguments[1]); if (targetId == Command.InvalidNumber) { Ui.ShowError(player, "Podano niepoprawne Id gracza."); return; } Character targetData = Account.GetPlayerDataByServerId(targetId); if (targetData == null) { Ui.ShowError(player, "Nie znaleziono takiego gracza."); return; } string nickname = Command.GetConcatString(arguments, 2); if (nickname.ToLower() == "usun") { targetData.HasCustomName = false; targetData.CustomName = null; // TODO: refresh nicku Ui.ShowInfo(player, $"Zmieniłeś graczowi {Player.GetPlayerIcName(targetData, true)} nick na domyślny."); Ui.ShowInfo(targetData.PlayerHandle, $"Administrator {Player.GetPlayerOocName(charData)} zmienił Ci nick na donmyślny."); Log.LogPlayer(targetData, $"Zmiana na domyślny przez {Player.GetPlayerDebugName(charData)}", LogType.ChangeNickname); } else { targetData.HasCustomName = true; targetData.CustomName = nickname; // TODO: refresh nicku Ui.ShowInfo(player, $"Zmieniłeś graczowi {Player.GetPlayerIcName(targetData, true)} nick na {nickname}."); Ui.ShowInfo(targetData.PlayerHandle, $"Administrator {Player.GetPlayerOocName(charData)} zmienił Ci nick na {nickname}."); Log.LogPlayer(targetData, $"Zmiana na \"{nickname}\" przez {Player.GetPlayerDebugName(charData)}", LogType.ChangeNickname); } } else if (option == "pieniadze") { if (!Library.DoesPlayerHasAdminPerm(charData, Permissions.AsetPieniadze, true)) { return; } if (arguments.Length - 1 < 2) { Ui.ShowUsage(player, "/aset pieniadze [ID gracza] [ilość pieniędzy do dodania/odjęcia (użyj znaku -)]"); return; } int targetId = Command.GetNumberFromString(arguments[1]); if (targetId == Command.InvalidNumber) { Ui.ShowError(player, "Podano niepoprawne Id gracza."); return; } Character targetData = Account.GetPlayerDataByServerId(targetId); if (targetData == null) { Ui.ShowError(player, "Nie znaleziono takiego gracza."); return; } int money = Command.GetNumberFromString(arguments[2]); if (money == Command.InvalidNumber) { Ui.ShowError(player, "Podano niepoprawną kwotę."); return; } if (money > 0) { if (Money.Library.GivePlayerWalletCash(targetData, Math.Abs(money), $"Od administratora {Player.GetPlayerDebugName(charData)}")) { Ui.ShowInfo(player, $"Dodałeś graczowi ${Math.Abs(money)}."); targetData.PlayerHandle.SendChatMessage( $"!{{#026D14}}[ Administrator {Player.GetPlayerOocName(charData)} " + $"dał Ci ${Math.Abs(money)}. ]"); } } else { money = Math.Abs(money); if (targetData.Cash < money) { Ui.ShowError(player, "Gracz nie posiada tyle pieniędzy w portfelu."); return; } if (Money.Library.TakePlayerWalletCash(targetData, Math.Abs(money), $"Od administratora {Player.GetPlayerDebugName(charData)}")) { Ui.ShowInfo(player, $"Dodałeś graczowi ${Math.Abs(money)}."); targetData.PlayerHandle.SendChatMessage( $"!{{#026D14}}[ Administrator {Player.GetPlayerOocName(charData)} " + $"zabrał Ci ${Math.Abs(money)}. ]"); } } } else { Ui.ShowUsage(player, legend); } }
/// <summary> /// Wysyła lokalną wiadomość czatu /// </summary> /// <param name="charData"></param> /// <param name="message"></param> /// <param name="pronoun"></param> /// <param name="ignoredEntity"></param> /// <param name="action"></param> /// <param name="messageType"></param> public static void SendPlayerLocalMessage(Character charData, string message, string pronoun, Client ignoredEntity = null, bool action = true, LocalMessageType messageType = LocalMessageType.Talk) { string messageOutput = $"{Player.GetPlayerIcName(charData)} {pronoun}: {Command.UpperFirst(message)}"; double radius = messageType == LocalMessageType.Shout ? Constants.RadiusShout : messageType == LocalMessageType.Whisper ? Constants.RadiusQuiet : messageType == LocalMessageType.Megaphone ? Constants.RadiusMegapthone : Constants.RadiusTalk; IEnumerable <Character> playersInRadius = Global.GetPlayersInRange(charData.PlayerHandle.Position, radius, charData.PlayerHandle.Dimension); List <int> asterisks = new List <int>(); if (action) { asterisks = GetAsterisksInText(messageOutput); if (asterisks.Count > 0 && asterisks.Count % 2 != 0) { asterisks.RemoveAt(asterisks.Count - 1); } } foreach (Character entry in playersInRadius) { if (ignoredEntity != null && ignoredEntity == entry.PlayerHandle) { continue; } string outputMessage = $"{messageOutput}"; double progress = Global.GetDistanceBetweenPositions(charData.PlayerHandle.Position, entry.PlayerHandle.Position) / radius; int cr = (int)Math.Floor(Global.Lerp(255, 60, (float)progress)); int cg = (int)Math.Floor(Global.Lerp(255, 60, (float)progress)); int cb = (int)Math.Floor(Global.Lerp(255, 60, (float)progress)); if (messageType == LocalMessageType.Megaphone) { cr = (int)Math.Floor(Global.Lerp(252, 173, (float)progress)); cg = (int)Math.Floor(Global.Lerp(249, 170, (float)progress)); cb = (int)Math.Floor(Global.Lerp(63, 10, (float)progress)); } if (action) { if (asterisks.Count > 0) { int r = (int)Math.Floor(Global.Lerp(194, 144, (float)progress)), g = (int)Math.Floor(Global.Lerp(162, 112, (float)progress)), b = (int)Math.Floor(Global.Lerp(218, 168, (float)progress)); for (int i = asterisks.Count - 1; i > -1; i--) { if (i % 2 == 0) { outputMessage = $"{outputMessage.Substring(0, asterisks[i])}!{{{r}, {g}, {b}}}" + $"{outputMessage.Substring(asterisks[i])}"; } else { outputMessage = $"{outputMessage.Substring(0, asterisks[i] + 1)}!{{{cr}, {cg}, {cb}}}" + $"{outputMessage.Substring(asterisks[i] + 1)}"; } } } } entry.PlayerHandle.SendChatMessage($"!{{{cr}, {cg}, {cb}}}{outputMessage}"); Log.LogPlayer(charData, messageOutput, LogType.ChatIc); } }