public void Execute(IRocketPlayer caller, string[] command) { bool VoteInProgress = Plugin.Instance.VoteInProgress; bool VoteInCooldown = Plugin.Instance.VoteInCooldown; int VoteTimer = Plugin.Instance.Configuration.Instance.VoteTimer; int VoteCooldown = Plugin.Instance.Configuration.Instance.VoteCooldown; if (command.Length == 0) { if (!VoteInProgress) { UnturnedChat.Say(caller, Plugin.Instance.Translate("no_ongoing_votes"), Color.red); Utility.Help((UnturnedPlayer)caller); } else { Voting.Vote(caller); } return; } if (command.Length == 1) { if (VoteInProgress) { UnturnedChat.Say(caller, Plugin.Instance.Translate("vote_error"), Plugin.Instance.MessageColor); return; } if (VoteInCooldown) { UnturnedChat.Say(caller, Plugin.Instance.Translate("vote_cooldown", VoteCooldown), Plugin.Instance.MessageColor); return; } } if (!VoteInProgress && !VoteInCooldown) { if (Utility.PlayerRequirement() == false) { UnturnedChat.Say(caller, Plugin.Instance.Translate("not_enough_players", Plugin.Instance.Configuration.Instance.MinimumPlayers), Color.red); return; } foreach (Vote vote in Plugin.Instance.Configuration.Instance.Votes) { if (String.Compare(command[0], vote.Name, true) == 0 || String.Compare(command[0], vote.Alias, true) == 0) { if (!vote.Enabled) { Utility.Notify((UnturnedPlayer)caller, 1); return; } if (!caller.HasPermission("cvote." + vote.Name.ToLower())) { Utility.Notify((UnturnedPlayer)caller, 2); return; } if (command.Length == 1) { if (vote.Name == "ItemAll" || vote.Name == "Kick" || vote.Name == "Mute" || vote.Name == "Spy") { return; } UnturnedChat.Say(Plugin.Instance.Translate("vote_started", caller.DisplayName, VoteTimer, Plugin.Instance.Translate(vote.Name)), Plugin.Instance.MessageColor); } else if (command.Length == 2) { if (vote.Name == "ItemAll") { ushort item; ushort.TryParse(command[1], out item); Plugin.Instance.ItemToGive = item; UnturnedChat.Say(Plugin.Instance.Translate("vote_started", caller.DisplayName, VoteTimer, Plugin.Instance.Translate(vote.Name, UnturnedItems.GetItemAssetById(Plugin.Instance.ItemToGive).itemName)), Plugin.Instance.MessageColor); } else if (vote.Name == "Kick") { if (UnturnedPlayer.FromName(command[1]) != null) { Plugin.Instance.PlayerToKickOrMute = UnturnedPlayer.FromName(command[1]).CSteamID; } UnturnedChat.Say(Plugin.Instance.Translate("vote_started", caller.DisplayName, VoteTimer, Plugin.Instance.Translate(vote.Name, UnturnedPlayer.FromName(command[1]).DisplayName)), Plugin.Instance.MessageColor); } else if (vote.Name == "Mute") { if (UnturnedPlayer.FromName(command[1]) != null) { Plugin.Instance.PlayerToKickOrMute = UnturnedPlayer.FromName(command[1]).CSteamID; } UnturnedChat.Say(Plugin.Instance.Translate("vote_started", caller.DisplayName, VoteTimer, Plugin.Instance.Translate(vote.Name, UnturnedPlayer.FromName(command[1]).DisplayName, Plugin.Instance.Configuration.Instance.MuteTime)), Plugin.Instance.MessageColor); } else if (vote.Name == "Spy") { if (UnturnedPlayer.FromName(command[1]) != null) { Plugin.Instance.PlayerToSpy = UnturnedPlayer.FromName(command[1]).CSteamID; } UnturnedChat.Say(Plugin.Instance.Translate("vote_started", caller.DisplayName, VoteTimer, Plugin.Instance.Translate(vote.Name)), Plugin.Instance.MessageColor); } } else { string Message = ""; for (int x = 0; x < command.Length; x++) { if (x == 0) { continue; } string Word = command[x]; Message += Word + " "; } UnturnedChat.Say(Plugin.Instance.Translate("vote_started", caller.DisplayName, VoteTimer, Plugin.Instance.Translate(vote.Name, Message)), Plugin.Instance.MessageColor); } Plugin.Instance.CurrentVote = vote.Name; Plugin.Instance.StartCoroutine(Voting.VotingProcess()); Plugin.Instance.VoteStarted(caller, Plugin.Instance.CurrentVote); if (Plugin.Instance.Configuration.Instance.AutoVoteCaller) { Voting.Vote(caller); } } } } }
public void Execute(IRocketPlayer caller, params string[] command) { if (!LIGHT.Instance.Configuration.Instance.LPXEnabled) { return; } string[] permission = { }; bool hasPerm = false; bool console = (caller is ConsolePlayer); if (!console) { if (LIGHT.Instance.Configuration.Instance.LPXEnabled) { permission = LIGHT.Instance.Database.getGroupPermission(LIGHT.Instance.Database.CheckUserGroup(caller.Id)); for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx" || permission[i] == "lpx.*" || permission[i] == "*") { hasPerm = true; } } } if (!hasPerm && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } } string comd = String.Join(" ", command); if (String.IsNullOrEmpty(comd.Trim())) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help")); return; } else { string[] oper = comd.Split(' '); hasPerm = false; if (oper.Length == 1) { switch (oper[0].ToLower()) { case "adduser": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.adduser" || permission[i] == "lpx.*" || permission[i] == "lpx.addu" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_adduser")); } break; case "removeuser": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.removeuser" || permission[i] == "lpx.*" || permission[i] == "lpx.ru" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_removeuser")); } break; case "addgroup": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.addgroup" || permission[i] == "lpx.*" || permission[i] == "lpx.addg" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_addgroup")); } break; case "removegroup": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.removegroup" || permission[i] == "lpx.*" || permission[i] == "lpx.rg" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_removegroup")); } break; case "addpermission": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.addpermission" || permission[i] == "lpx.*" || permission[i] == "lpx.addp" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_addpermission")); } break; case "removepermission": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.removepermission" || permission[i] == "lpx.*" || permission[i] == "lpx.rp" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_removepermission")); } break; case "addgroupfreeitem": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.addgroupfreeitem" || permission[i] == "lpx.*" || permission[i] == "lpx.addgfi" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_addgroupfreeitem")); } break; case "setgroupincome": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.setgroupincome" || permission[i] == "lpx.*" || permission[i] == "lpx.setgi" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_setgroupincome")); } break; case "listgroup": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.listgroup" || permission[i] == "lpx.*" || permission[i] == "lpx.listg" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { DataTable dt = new DataTable(); dt = LIGHT.Instance.Database.GetGroup(); string[] stringArr = new string[50]; string groups = ""; for (int i = 0; i < (dt.Rows.Count); i++) { stringArr[i] += dt.Rows[i].ItemArray[0].ToString(); if (i == (dt.Rows.Count - 1)) { groups += stringArr[i] + "."; } else { groups += stringArr[i] + ", "; } } UnturnedChat.Say(caller, groups); } break; case "listpermission": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.listpermission" || permission[i] == "lpx.*" || permission[i] == "lpx.listp" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_listpermission")); } break; case "addparentgroup": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.addparentgroup" || permission[i] == "lpx.*" || permission[i] == "lpx.addpg" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_addparentgroup")); } break; case "setpromotegroup": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.setpromotegroup" || permission[i] == "lpx.*" || permission[i] == "lpx.setpromog" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_setpromotegroup")); } break; case "setpromotetime": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.setpromotetime" || permission[i] == "lpx.*" || permission[i] == "lpx.setpromot" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_setpromotetime")); } break; case "enablepromote": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.enablepromote" || permission[i] == "lpx.*" || permission[i] == "lpx.enpromo" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_enablepromote")); } break; default: break; } return; } else { string[] param = string.Join(" ", oper.Skip(1).ToArray()).Split(' '); hasPerm = false; switch (oper[0].ToLower()) { case "adduser": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.adduser" || permission[i] == "lpx.*" || permission[i] == "lpx.addu" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { if (param.Length == 1) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_adduser2")); } else if (param.Length == 2) { if (LIGHT.Instance.Database.CheckGroup(param[1])) { UnturnedPlayer target = UnturnedPlayer.FromName(param[0]); if (target != null) { LIGHT.Instance.Database.AddUserIntoGroup(UnturnedPlayer.FromName(param[0]).Id, param[1]); UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_added_user", target.SteamName, param[1])); LIGHT.Instance.Database.LastLogin(target.Id); } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_nouser")); return; } } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_nogroup")); return; } } } break; case "removeuser": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.removeuser" || permission[i] == "lpx.*" || permission[i] == "lpx.ru" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { if (param.Length == 1) { try { UnturnedPlayer target = UnturnedPlayer.FromName(param[0]); if (target != null) { string group = LIGHT.Instance.Database.CheckUserGroup(target.Id); if (LIGHT.Instance.Database.RemoveUser(target.Id)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_removed_user", target.SteamName, group)); } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_remove", target.SteamName, group)); } } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_nouser")); return; } } catch { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_nouser")); return; } } } break; case "addgroup": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.addgroup" || permission[i] == "lpx.*" || permission[i] == "lpx.addg" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { if (LIGHT.Instance.Database.CheckGroup(param[0])) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_group_exist", param[0])); return; } else if (param.Length >= 2) { decimal income = 0M; if (decimal.TryParse(param[1], out income)) { string updategroup = "", parentgroup = ""; int UpdateTime = 7; bool EnableAuto = false; if (param.Length == 6) { bool.TryParse(param[5], out EnableAuto); } if (param.Length >= 5) { int.TryParse(param[4], out UpdateTime); } if (param.Length >= 4) { if (LIGHT.Instance.Database.CheckGroup(param[3]) == false) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_group_notexist")); return; } else { updategroup = param[3]; } } if (param.Length >= 3) { parentgroup = param[2]; } if (LIGHT.Instance.Database.AddGroup(param[0], param[1], parentgroup, updategroup, UpdateTime, EnableAuto)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_added_group", param[0])); } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_failed_group", param[0])); } } else { UnturnedChat.Say(caller, "Please only enter numbers in <income>"); UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_addgroup")); return; } } else if (param.Length == 1) { if (LIGHT.Instance.Database.AddGroup(param[0], "10", null, null, 7, false)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_added_group", param[0])); } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_failed_group", param[0])); } } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_invaild_para")); } } break; case "removegroup": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.removegroup" || permission[i] == "lpx.*" || permission[i] == "lpx.rg" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { if (!LIGHT.Instance.Database.CheckGroup(param[0])) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_nogroup", param[0])); return; } else { if (LIGHT.Instance.Database.RemoveGroup(param[0])) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_removed_group", param[0])); } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_removegroup", param[0])); } } } break; case "addpermission": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.addpermission" || permission[i] == "lpx.*" || permission[i] == "lpx.addp" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { if (param.Length == 1) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_addpermission2")); } else if (param.Length == 2) { if (LIGHT.Instance.Database.CheckGroup(param[0])) { if (!LIGHT.Instance.Database.checkPermissionCopy(param[0], param[1])) { bool result; result = LIGHT.Instance.Database.AddPermissionIntoGroup(param[1], param[0]); if (result) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_added_permission", param[1], param[0])); } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_failed_permission", param[1], param[0])); } } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_failed_copypermission", param[1], param[0])); return; } } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_nogroup")); return; } } } break; case "removepermission": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.removepermission" || permission[i] == "lpx.*" || permission[i] == "lpx.rp" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { if (param.Length == 1) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_removepermission2")); } else if (param.Length == 2) { if (LIGHT.Instance.Database.CheckGroup(param[0])) { bool result; result = LIGHT.Instance.Database.RemovePermissionFromGroup(param[0], param[1]); if (result) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_remove_removepermission", param[1], param[0])); } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_failed_removepermission", param[0])); } } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_nogroup")); return; } } } break; case "listpermission": string permissions = ""; for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.listpermission" || permission[i] == "lpx.*" || permission[i] == "lpx.listp" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { if (param.Length == 1) { permission = LIGHT.Instance.Database.getGroupPermission(param[0]); if (permission.Length > 0) { for (int i = permission.Length - 1; i >= 0; i--) { permissions += " " + permission[i]; } UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_listp_group", param[0])); UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_listp_permission", permissions)); } } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_listpermission")); return; } } break; case "addgroupfreeitem": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.addgroupfreeitem" || permission[i] == "lpx.*" || permission[i] == "lpx.addgfi" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { if (param.Length == 1) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_help_addgroupfreeitem2")); } else if (param.Length == 2) { if (LIGHT.Instance.Database.CheckGroup(param[0])) { bool result; result = LIGHT.Instance.Database.AddGroupFreeItem(param[0], param[1]); if (result) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_added_permission", param[0], param[1])); } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_failed_permission", param[0], param[1])); } } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_nogroup")); return; } } } break; case "setgroupincome": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.setgroupincome" || permission[i] == "lpx.*" || permission[i] == "lpx.setgi" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { if (LIGHT.Instance.Database.CheckGroup(param[0])) { if (LIGHT.Instance.Database.SetGroupIncome(param[0], param[1])) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_added_income", param[0], param[1])); } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_failed_setincome", param[0])); } } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_nogroup")); return; } } break; case "addparentgroup": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.addparentgroup" || permission[i] == "lpx.*" || permission[i] == "lpx.addpg" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { if (LIGHT.Instance.Database.CheckGroup(param[0])) { if (param[0] == param[1]) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_add_sameparentgroup")); return; } if (LIGHT.Instance.Database.AddParentGroup(param[0], param[1])) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_added_parentgroup", param[0], param[1])); } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_failed_parentgroup", param[0], param[1])); } } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_nogroup")); return; } } break; case "setpromotegroup": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.setpromotegroup" || permission[i] == "lpx.*" || permission[i] == "lpx.setpromog" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { if (LIGHT.Instance.Database.CheckGroup(param[0])) { if (LIGHT.Instance.Database.SetUpdateGroup(param[0], param[1])) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_set_promotegroup", param[0], param[1])); } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_failed_promotegroup", param[0], param[1])); } } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_nogroup")); return; } } break; case "setpromotetime": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.setpromotetime" || permission[i] == "lpx.*" || permission[i] == "lpx.setpromot" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { if (LIGHT.Instance.Database.CheckGroup(param[0])) { int updateTime = 7; if (int.TryParse(param[1], out updateTime)) { if (LIGHT.Instance.Database.SetUpdateTime(param[0], updateTime)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_set_promotetime", param[0], param[1])); } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_failed_promotetime", param[0])); } } } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_nogroup")); return; } } break; case "enablepromote": for (int i = permission.Length - 1; i >= 0; i--) { if (permission[i] == "lpx.enablepromote" || permission[i] == "lpx.*" || permission[i] == "lpx.enpromo" || permission[i] == "*") { hasPerm = true; } } if (!hasPerm && !console && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_no_perm")); return; } else { bool enable = false; if (LIGHT.Instance.Database.CheckGroup(param[0])) { if (bool.TryParse(param[1], out enable)) { if (LIGHT.Instance.Database.SetEnableUpdate(param[0], enable)) { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_set_enablepromote", param[0], param[1])); } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_failed_enablepromote", param[0])); } } } else { UnturnedChat.Say(caller, LIGHT.Instance.Translate("lpx_fail_nogroup")); return; } } break; default: break; } } } }
public static UnturnedPlayer GetUnturnedPlayerParameter(this string[] array, int index) { return((array.Length <= index) ? null : UnturnedPlayer.FromName(array[index])); }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer sender = (UnturnedPlayer)caller; if (command.Length < 2) { UnturnedChat.Say(sender, $"Erro! Use: /sms {Syntax}", Color.red); return; } UnturnedPlayer receiver = UnturnedPlayer.FromName(command[0]); if (receiver == null) { UnturnedChat.Say(sender, ZAP.Instance.Translate("no_player"), Color.red); return; } if (receiver.CSteamID == sender.CSteamID) { UnturnedChat.Say(sender, ZAP.Instance.Translate("no_yourself"), Color.red); return; } string msg = string.Empty; int n2 = 0; foreach (string msg3 in command) { n2++; if (n2 != 1) { msg = msg + " " + msg3; } } if (sender.Experience < ZAP.Instance.Configuration.Instance.SMSCost) { UnturnedChat.Say(sender, ZAP.Instance.Translate("not_enough_xp"), Color.red); return; } if (ZAP.Instance.Configuration.Instance.SMSEffect) { sender.TriggerEffect(ZAP.Instance.Configuration.Instance.SendEffectID); receiver.TriggerEffect(ZAP.Instance.Configuration.Instance.ReceiveEffectID); } if (ZAP.sms.ContainsKey(receiver.CSteamID)) { ZAP.sms[receiver.CSteamID] = sender.CSteamID; } else { ZAP.sms.Add(receiver.CSteamID, sender.CSteamID); } sender.Experience -= (uint)ZAP.Instance.Configuration.Instance.SMSCost; UnturnedChat.Say(sender, ZAP.Instance.Translate("sms_pay", ZAP.Instance.Configuration.Instance.SMSCost), Color.blue); UnturnedChat.Say(sender, ZAP.Instance.Translate("send_sms", receiver.DisplayName), ZAP.Instance.Configuration.Instance.ChatColor); UnturnedChat.Say(receiver, ZAP.Instance.Translate("receive_sms", sender.DisplayName, msg), ZAP.Instance.Configuration.Instance.ChatColor); return; }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; Stats stats = player.GetComponent <StatsPlayerComponent>().Stats.Instance; if (command.Length < 1) { return; } if (command[0].ToString().ToLower() == "pvp") { if (command.Length == 1) { Rocket.Unturned.Chat.UnturnedChat.Say(player, showPVP(player, stats), Color.yellow); } if (command.Length == 2) { if (player.HasPermission("stats.admin")) { UnturnedPlayer target = UnturnedPlayer.FromName(command[1].ToString().ToLower()); if (target == null) { Rocket.Unturned.Chat.UnturnedChat.Say(player, "Player does not exist or is offline!", Color.yellow); } else { Stats targetStats = target.GetComponent <StatsPlayerComponent>().Stats.Instance; Rocket.Unturned.Chat.UnturnedChat.Say(player, showPVP(target, targetStats), Color.yellow); } } else { Rocket.Unturned.Chat.UnturnedChat.Say(player, "You do not have permission to use this command!", Color.red); } } } else if (command[0].ToString().ToLower() == "pve") { if (command.Length == 1) { Rocket.Unturned.Chat.UnturnedChat.Say(player, showPVE(player, stats), Color.yellow); } if (command.Length == 2) { if (player.HasPermission("stats.admin")) { UnturnedPlayer target = UnturnedPlayer.FromName(command[1].ToString().ToLower()); if (target == null) { Rocket.Unturned.Chat.UnturnedChat.Say(player, "Player does not exist or is offline!", Color.yellow); } else { Stats targetStats = target.GetComponent <StatsPlayerComponent>().Stats.Instance; Rocket.Unturned.Chat.UnturnedChat.Say(player, showPVE(target, targetStats), Color.yellow); } } else { Rocket.Unturned.Chat.UnturnedChat.Say(player, "You do not have permission to use this command!", Color.red); } } } else if (command[0].ToString().ToLower() == "tk") { if (command.Length == 1) { Rocket.Unturned.Chat.UnturnedChat.Say(player, showTK(player, stats), Color.yellow); } else if (command.Length == 2) { if (player.HasPermission("stats.admin")) { UnturnedPlayer target = UnturnedPlayer.FromName(command[1].ToString().ToLower()); if (target == null) { Rocket.Unturned.Chat.UnturnedChat.Say(player, "Player does not exist or is offline!", Color.yellow); } else { Stats targetStats = target.GetComponent <StatsPlayerComponent>().Stats.Instance; Rocket.Unturned.Chat.UnturnedChat.Say(player, showTK(target, targetStats), Color.yellow); } } else { Rocket.Unturned.Chat.UnturnedChat.Say(player, "You do not have permission to use this command!", Color.red); } } } else if (command[0].ToString().ToLower() == "td") { if (command.Length == 1) { Rocket.Unturned.Chat.UnturnedChat.Say(player, showTD(player, stats), Color.yellow); } else if (command.Length == 2) { if (player.HasPermission("stats.admin")) { UnturnedPlayer target = UnturnedPlayer.FromName(command[1].ToString().ToLower()); if (target == null) { Rocket.Unturned.Chat.UnturnedChat.Say(player, "Player does not exist or is offline!", Color.yellow); } else { Stats targetStats = target.GetComponent <StatsPlayerComponent>().Stats.Instance; Rocket.Unturned.Chat.UnturnedChat.Say(player, showTD(target, targetStats), Color.yellow); } } else { Rocket.Unturned.Chat.UnturnedChat.Say(player, "You do not have permission to use this command!", Color.red); } } } else if (command[0].ToString().ToLower() == "kd") { if (command.Length == 1) { Rocket.Unturned.Chat.UnturnedChat.Say(player, showKD(player, stats), Color.yellow); } else if (command.Length == 2) { if (player.HasPermission("stats.admin")) { UnturnedPlayer target = UnturnedPlayer.FromName(command[1].ToString().ToLower()); if (target == null) { Rocket.Unturned.Chat.UnturnedChat.Say(player, "Player does not exist or is offline!", Color.yellow); } else { Stats targetStats = target.GetComponent <StatsPlayerComponent>().Stats.Instance; Rocket.Unturned.Chat.UnturnedChat.Say(player, showKD(target, targetStats), Color.yellow); } } else { Rocket.Unturned.Chat.UnturnedChat.Say(player, "You do not have permission to use this command!", Color.red); } } } else { Rocket.Unturned.Chat.UnturnedChat.Say(player, "Not a valid mode or stat node! Select mode: pvp or pve, or a stat node: tk, td, or kd.", Color.yellow); } }
public void Execute(IRocketPlayer caller, string[] command) { if (!caller.HasPermission("godvanishplus.vanish")) { UnturnedChat.Say(caller, "You do not have access to use this command!", Color.red); return; } if (caller is ConsolePlayer && command.Length < 1) { Rocket.Core.Logging.Logger.Log("This command cannot be called from console. Try /vanish <player>"); return; } else if (caller is UnturnedPlayer && command.Length < 1) { UnturnedPlayer player = (UnturnedPlayer)caller; if (player.Features.VanishMode) { UnturnedChat.Say(caller, GodVanishPlus.Instance.Configuration.Instance.vanishOffMsg, UnturnedChat.GetColorFromName(GodVanishPlus.Instance.Configuration.Instance.vanishColorOff, Color.red)); Rocket.Core.Logging.Logger.Log(caller.DisplayName + " has turned off Vanish Mode"); player.Features.VanishMode = false; return; } else { UnturnedChat.Say(caller, GodVanishPlus.Instance.Configuration.Instance.vanishOnMsg, UnturnedChat.GetColorFromName(GodVanishPlus.Instance.Configuration.Instance.vanishColorOn, Color.cyan)); Rocket.Core.Logging.Logger.Log(caller.DisplayName + " has turned on Vanish Mode"); player.Features.VanishMode = true; return; } } else if (caller is ConsolePlayer && command.Length >= 1 || caller is UnturnedPlayer) { if (caller.HasPermission("nebulafalls.vanish.others")) { UnturnedPlayer vanishPlayer = (UnturnedPlayer)UnturnedPlayer.FromName(command[0]); if (vanishPlayer == null) { UnturnedChat.Say(caller, "This player could not be found!", Color.red); return; } else { if (vanishPlayer.Features.VanishMode) { vanishPlayer.Features.VanishMode = false; UnturnedChat.Say(vanishPlayer, GodVanishPlus.Instance.Configuration.Instance.vanishOthersOff + caller.DisplayName, UnturnedChat.GetColorFromName(GodVanishPlus.Instance.Configuration.Instance.vanishOthersColor, Color.yellow)); UnturnedChat.Say(caller, GodVanishPlus.Instance.Configuration.Instance.takenOthersVanish + vanishPlayer.DisplayName, UnturnedChat.GetColorFromName(GodVanishPlus.Instance.Configuration.Instance.vanishOthersColor, Color.yellow)); Rocket.Core.Logging.Logger.Log(caller.DisplayName + " has turned off Vanish Mode for: " + vanishPlayer.DisplayName); return; } else { vanishPlayer.Features.VanishMode = true; UnturnedChat.Say(vanishPlayer, GodVanishPlus.Instance.Configuration.Instance.vanishOthersOn + caller.DisplayName, UnturnedChat.GetColorFromName(GodVanishPlus.Instance.Configuration.Instance.vanishOthersColor, Color.yellow)); UnturnedChat.Say(caller, GodVanishPlus.Instance.Configuration.Instance.givenOthersVanish + vanishPlayer.DisplayName, UnturnedChat.GetColorFromName(GodVanishPlus.Instance.Configuration.Instance.vanishOthersColor, Color.yellow)); Rocket.Core.Logging.Logger.Log(caller.DisplayName + " has turned on Vanish Mode for: " + vanishPlayer.DisplayName); return; } } } else { UnturnedChat.Say(caller, "You do not have permission to give other players vanish!", Color.red); return; } } }
public void Execute(IRocketPlayer caller, params string[] command) { bool hasPerm = false; UnturnedPlayer player = (UnturnedPlayer)caller; if (command.Length == 0) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_help_1")); return; } if (command.Length > 0) { if (player.HasPermission("car") || player.HasPermission("car.*") || player.HasPermission("*")) { hasPerm = true; } if (!hasPerm && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("lpx_no_perm")); return; } else { InteractableVehicle veh = player.Player.movement.getVehicle(); switch (command[0].ToLower()) { case "refuel": if (player.HasPermission("car.refuel") || player.HasPermission("car.*") || player.HasPermission("*")) { hasPerm = true; } if (!hasPerm && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("lpx_no_perm")); return; } if (command.Length < 2) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_refuel_help_1")); return; } else { if (veh != null) { VehicleAsset vehi = veh.asset; ushort fuel = vehi.fuel; ushort maxfuel = vehi.fuel; double percent; double truefuel; if (command[1] == "full" || command[1] == "all" || command[1] == "100") { truefuel = (double)fuel - (double)veh.fuel; percent = double.Parse(fuel.ToString()) / (double)maxfuel * 100.00; percent = Math.Round(percent, 2); } else { if (ushort.TryParse(command[1], out fuel)) { if ((((double)veh.fuel / (double)maxfuel * 100.00) + (double)fuel) > 100.00) { truefuel = (double)maxfuel - (double)veh.fuel; } else { truefuel = (double)fuel / 100.00 * (double)maxfuel; } truefuel = Math.Round(truefuel, 0); percent = Math.Round(((double)truefuel / (double)maxfuel) * 100.00, 2); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_refuel_error2")); return; } } _ = decimal.Parse("1.3"); decimal.TryParse(LPXRemastered.Instance.Configuration.Instance.FuelPrice.ToString(), out decimal price); if (price != 0.00m) { decimal balance = Uconomy.Instance.Database.GetBalance(player.Id); decimal totalprice = Math.Round(price * (decimal)truefuel / (decimal)10, 2); if (balance < totalprice) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_not_enough_currency", Uconomy.Instance.Configuration.Instance.MoneyName)); return; } decimal bal = Uconomy.Instance.Database.IncreaseBalance(player.CSteamID.ToString(), (totalprice * -1)); UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_refuel_paid", totalprice, Uconomy.Instance.Configuration.Instance.MoneyName, veh.instanceID.ToString(), percent.ToString())); if (bal >= 0.0m) { UnturnedChat.Say(player.CSteamID, LPXRemastered.Instance.Translate("new_balance_msg", new object[] { bal, Uconomy.Instance.Configuration.Instance.MoneyName })); } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_refuelled_1", percent.ToString())); } veh.askFillFuel((ushort)truefuel); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_error_1")); return; } } break; case "lock": if (veh != null) { if (command.Length == 1) { if (LPXRemastered.Instance.DatabaseCar.CheckOwner(veh.instanceID.ToString()) == player.Id) { LPXRemastered.Instance.DatabaseCar.AddLockedStatus(veh.instanceID.ToString(), true); UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_Locked", veh.instanceID.ToString())); } else { string[] PlayersWithKey = LPXRemastered.Instance.DatabaseCar.GetGivenKeys(veh.instanceID.ToString()); for (int x = 0; x < PlayersWithKey.Length; x++) { if (PlayersWithKey[x].Trim() == player.Id) { LPXRemastered.Instance.DatabaseCar.AddLockedStatus(veh.instanceID.ToString(), true); UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_Locked", veh.instanceID.ToString())); break; } } UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_notowner")); return; } } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_error_1")); return; } break; case "unlock": if (veh != null) { if (command.Length == 1) { if (LPXRemastered.Instance.DatabaseCar.CheckOwner(veh.instanceID.ToString()) == player.Id) { LPXRemastered.Instance.DatabaseCar.AddLockedStatus(veh.instanceID.ToString(), false); UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_Unlocked", veh.instanceID.ToString())); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_notowner")); return; } } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_error_1")); return; } break; case "key": if (command.Length == 1) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_keyhelp")); return; } if (command.Length == 2) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_keyhelp2")); return; } if (command.Length > 2) { if (LPXRemastered.Instance.DatabaseCar.CheckCarExistInDB(command[1])) { if (LPXRemastered.Instance.DatabaseCar.CheckOwner(command[1]) == player.Id) { UnturnedPlayer PlayerKey = UnturnedPlayer.FromName(command[2]); if (PlayerKey != null) { LPXRemastered.Instance.DatabaseCar.AddGivenKeys(command[1], PlayerKey.Id); UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_key_given", command[1], PlayerKey.CharacterName)); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("lpx_playernotfound")); return; } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_notowner")); return; } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_not_found")); return; } } break; case "repair": if (player.HasPermission("car.repair") || player.HasPermission("car.*") || player.HasPermission("*")) { hasPerm = true; } if (!hasPerm && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("lpx_no_perm")); return; } if (command.Length == 1) { if (veh != null) { VehicleAsset vehi = veh.asset; int repair; double percent; repair = vehi.health - veh.health; if (repair > 0) { percent = Math.Round(((double)repair / (double)vehi.health) * 100.00, 2); if (LPXRemastered.Instance.Configuration.Instance.RepairPrice == 0) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_repaired", veh.instanceID.ToString(), percent)); } else { _ = decimal.Parse("2"); decimal.TryParse(LPXRemastered.Instance.Configuration.Instance.RepairPrice.ToString(), out decimal price); decimal balance = Uconomy.Instance.Database.GetBalance(player.Id); decimal totalprice = Math.Round(price * (decimal)repair / (decimal)6, 2); if (balance < totalprice) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_not_enough_currency", Uconomy.Instance.Configuration.Instance.MoneyName)); return; } decimal bal = Uconomy.Instance.Database.IncreaseBalance(player.CSteamID.ToString(), (totalprice * -1)); if (bal >= 0.0m) { UnturnedChat.Say(player.CSteamID, LPXRemastered.Instance.Translate("new_balance_msg", new object[] { bal, Uconomy.Instance.Configuration.Instance.MoneyName })); } UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_repaired_price", veh.instanceID.ToString(), percent, totalprice, Uconomy.Instance.Configuration.Instance.MoneyName)); } veh.askRepair((ushort)repair); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_repair_notneeded", veh.instanceID.ToString())); return; } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_error_1")); return; } } break; case "locate": if (command.Length == 1) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_locate_help")); return; } if (command.Length == 2) { if (LPXRemastered.Instance.DatabaseCar.CheckCarExistInDB(command[1])) { if (LPXRemastered.Instance.DatabaseCar.CheckOwner(command[1]) == player.Id) { string Status = ""; if (ushort.TryParse(command[1], out ushort index)) { InteractableVehicle vehicle = VehicleManager.getVehicle(index); _ = vehicle.tryRemovePlayer(out _, player.CSteamID, out Vector3 point, out _); if (vehicle.isEmpty) { Status += "It is Empty. "; } if (vehicle.isDrowned) { Status += "It is Drowned. "; } if (vehicle.isDriven) { Status += "It is Being Drove. "; } UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_located", index, Math.Round(point.x, 0), Math.Round(point.y, 0), Math.Round(point.z, 0), Status)); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("lpx_invalid_input")); return; } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_notowner")); return; } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_not_found")); return; } } break; case "rkey": if (command.Length == 1) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_rkey_help")); return; } if (command.Length == 2) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_rkey_help2")); return; } if (command.Length > 2) { if (LPXRemastered.Instance.DatabaseCar.CheckCarExistInDB(command[1])) { UnturnedPlayer target; if (LPXRemastered.Instance.DatabaseCar.CheckOwner(command[1]) == player.Id) { target = UnturnedPlayer.FromName(command[2]); if (target == null) { if (LPXRemastered.Instance.DatabaseCar.RemoveGiveKeysCar(command[1], command[2])) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_rkey_success", command[2], command[1])); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_rkey_keynotfound", command[1])); return; } } else { if (LPXRemastered.Instance.DatabaseCar.RemoveGiveKeysCar(command[1], target.Id)) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_rkey_success", target.CharacterName, command[1])); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_rkey_keynotfound", command[1])); return; } } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_notowner")); return; } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_not_found")); return; } } break; case "list": string cars = LPXRemastered.Instance.DatabaseCar.GetAllOwnedCars(player.Id); if (cars == "" || cars == " ") { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_zero_owned")); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_list_all")); } break; case "steal": if (command.Length == 1) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_steal_help")); return; } else { if (LPXRemastered.Instance.DatabaseCar.CheckCarExistInDB(command[1])) { /** La voiture existe **/ decimal[] stealVehPrice = { 100, 100, /**/ 100, 250, 500, /**/ 1000, 1500, 2000, /**/ 2500, 3000, 4000, 10000, /**/ 50000 }; decimal[] lLicencePrice = { 500, 750, /**/ 1000, 1500, 3500, /**/ 1250, 1750, 3750, /**/ 1500, 2000, 4000, 10000, /**/ 90000 }; string strVehID = LPXRemastered.Instance.DatabaseCar.GetCarID(command[1]); int vehID = LPXRemastered.Instance.DatabaseCar.ConvertLicenceToInt(strVehID); if (vehID == -1) { break; } /** Prix vol vehicule **/ decimal vehprice = stealVehPrice[vehID]; if (player.HasPermission("Car_Steal_" + strVehID) || player.HasPermission("Car_Steal_*")) { vehprice = 100; /** Prix pour forcer le vehicule avec autorisation **/ } /** Prix licence **/ decimal licPrice = 0; if (!player.HasPermission("Licence_" + strVehID) && LPXRemastered.Instance.DatabaseCar.CheckLicence(player.Id, strVehID)) { licPrice = lLicencePrice[vehID]; } decimal balance = Uconomy.Instance.Database.GetBalance(player.Id); decimal price = vehprice + licPrice; if (balance < price) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_not_enough_currency", Uconomy.Instance.Configuration.Instance.MoneyName)); return; } /** Paiement du vol du vehicule **/ decimal bal = Uconomy.Instance.Database.IncreaseBalance(player.Id, (price * -1)); if (bal >= 0.0m) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("new_balance_msg", new object[] { bal, Uconomy.Instance.Configuration.Instance.MoneyName })); } /** Unlocking du vehicule **/ string oldowner = LPXRemastered.Instance.DatabaseCar.GetOwnerName(command[1]); LPXRemastered.Instance.DatabaseCar.RemoveOwnership(command[1]); LPXRemastered.Instance.DatabaseCar.AddOwnership(command[1], player.Id, player.DisplayName); Logger.Log(player.CharacterName + " a vole la voiture numero " + command[1] + " de categorie " + vehID + " appartenant a " + oldowner); } } break; default: break; } } } }
public static UnturnedPlayer RocketPlayerToU(this RocketPlayer rocket) { return(UnturnedPlayer.FromName(rocket.DisplayName)); }
public void Execute(IRocketPlayer caller, string[] command) { if (command.Length == 1) { if (command[0].ToLower() == "stop") { int amountStopped = clearAndStopAllSpyThreads(ref Plugin.ThreadsList); clearAndStopAllSpyThreads(ref Plugin.PerUserThreads); sendMessage(caller, Plugin.Instance.Translate("stopped_spies", amountStopped)); return; } } int enteredDelay = 500; int enteredAmount = 2; if (command.Length != 3) { sendMessage(caller, Plugin.Instance.Translate("wrong_usage", Syntax)); return; } UnturnedPlayer otherPlayer = UnturnedPlayer.FromName(command[0]); if (otherPlayer == null) { sendMessage(caller, Plugin.Instance.Translate("player_not_found", command[0])); return; } if (!int.TryParse(command[1], out enteredAmount)) { sendMessage(caller, Plugin.Instance.Translate("invalid_amount")); return; } if (!int.TryParse(command[2], out enteredDelay)) { sendMessage(caller, Plugin.Instance.Translate("invalid_delay")); return; } if (Plugin.GetMinDelayFromConfig() != 0) { if (enteredDelay < Plugin.GetMinDelayFromConfig()) { UnturnedChat.Say(caller, Plugin.Instance.Translate("under_minimum_delay", enteredDelay)); return; } } SteamPlayer steamP = null; foreach (var p in Provider.clients) { if (p.playerID.steamID == otherPlayer.CSteamID) { steamP = p; break; } } if (steamP == null) { return; } if (!(caller is ConsolePlayer)) { clearAndStopSpecificUserThreads(ref Plugin.PerUserThreads, ((UnturnedPlayer)caller).CSteamID); } Thread t = null; t = new Thread(() => { Plugin.SpamSpy(steamP, enteredDelay, enteredAmount, caller, t); }); t.Start(); Plugin.ThreadsList.Add(t); if (!(caller is ConsolePlayer)) { Plugin.PerUserThreads.Add(((UnturnedPlayer)caller).CSteamID, t); } }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = null; if (command.Length == 0) { if (caller is ConsolePlayer) { Plugin.CustomKitsPlugin.Write("<player>", ConsoleColor.Red); return; } player = (UnturnedPlayer)caller; } else if (command.Length == 1) { if (caller.HasPermission(OTHER_PERM)) { player = UnturnedPlayer.FromName(command[0]); } else { UnturnedChat.Say(caller, "You do not have permissions to execute this command.", Color.red); return; } } if (player == null) { if (caller is ConsolePlayer) { Plugin.CustomKitsPlugin.Write(Plugin.CustomKitsPlugin.Instance.Translate("player_doesn't_exist", command[0]), ConsoleColor.Red); return; } UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("player_doesn't_exist", command[0]), Color.red); return; } if (KitManager.Kits.ContainsKey(player.CSteamID.m_SteamID)) { if (KitManager.KitCount(player, KitManager.Kits) > 1) { string kitList = string.Join(", ", KitManager.Kits[player.CSteamID.m_SteamID].Keys.ToArray()); if (caller is ConsolePlayer) { Plugin.CustomKitsPlugin.Write(Plugin.CustomKitsPlugin.Instance.Translate("kit_list", kitList), ConsoleColor.Green); return; } UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("kit_list", kitList), Color.green); } else if (KitManager.KitCount(player, KitManager.Kits) == 1) { foreach (var kit in KitManager.Kits[player.CSteamID.m_SteamID].Keys) { if (caller is ConsolePlayer) { Plugin.CustomKitsPlugin.Write(Plugin.CustomKitsPlugin.Instance.Translate("kit_list", kit), ConsoleColor.Green); return; } UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("kit_list", kit), Color.green); } } else { if (caller is ConsolePlayer) { Plugin.CustomKitsPlugin.Write(Plugin.CustomKitsPlugin.Instance.Translate("no_saved_kits"), ConsoleColor.Red); return; } UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("no_saved_kits"), Color.red); } } else { if (caller is ConsolePlayer) { Plugin.CustomKitsPlugin.Write(Plugin.CustomKitsPlugin.Instance.Translate("no_saved_kits"), ConsoleColor.Red); return; } UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("no_saved_kits"), Color.red); } }
public void Execute(IRocketPlayer caller, string[] command) { switch (command.Length) { case (0): if (caller is ConsolePlayer) { Rocket.Core.Logging.Logger.LogException(new System.InvalidOperationException($"Console does not have an iventory to repair! You must be a player to execute /repair or /fix")); } else { Repair((UnturnedPlayer)caller); } break; case (1): CheckCommand(); break; default: Rocket.Core.Logging.Logger.LogException(new System.InvalidOperationException($"Command can contain only 2 parameters!")); break; } void Repair(UnturnedPlayer player) { for (byte page = 0; page < player.Inventory.items.Length; page++)//7, becuase there are currently 7 types of wear where player possibly can store items: EItemType.HAT/PANTS/SHIRT/MASK/BACKPACK/VEST/GLASSES { if (player.Inventory.items[page] == null) { continue; } for (byte index = 0; index < player.Inventory.getItemCount(page); index++) { try { if (player.Inventory.items[page].items[index].item.quality == 100) { continue; } player.Inventory.sendUpdateQuality(page, player.Inventory.items[page].items[index].x, player.Inventory.items[page].items[index].y, 100); } catch (System.Exception) { continue; } } } } void CheckCommand() { if (command[0].ToLower() == "all") { if (Provider.clients.Count != 0) { foreach (var steamplayer in Provider.clients) { Repair(UnturnedPlayer.FromSteamPlayer(steamplayer)); } } else { Rocket.Core.Logging.Logger.LogError("Player not found!"); } } else { UnturnedPlayer player = UnturnedPlayer.FromName(command[0]); if (player != null) { Repair(player); } else { Rocket.Core.Logging.Logger.LogError("Player not found!"); } } } }
public void Execute(IRocketPlayer caller, params string[] command) { if (command.Length != 2) { if (caller is UnturnedPlayer) { ChatManager.serverSendMessage(BankingSystem.Instance.Translate("chat_title", Uconomy.Instance.Translate("command_pay_invalid_colored")), Color.white, null, ((UnturnedPlayer)caller).SteamPlayer(), EChatMode.SAY, BankingSystem.Instance.Configuration.Instance.iconUrl, true); } else { UnturnedChat.Say(caller, Uconomy.Instance.Translations.Instance.Translate("command_pay_invalid"), UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green)); } return; } var otherPlayer = command.GetCSteamIDParameter(0)?.ToString(); var otherPlayerOnline = UnturnedPlayer.FromName(command[0]); if (otherPlayerOnline != null) { otherPlayer = otherPlayerOnline.Id; } if (otherPlayer != null) { if (caller.Id == otherPlayer) { if (caller is UnturnedPlayer) { ChatManager.serverSendMessage(BankingSystem.Instance.Translate("chat_title", Uconomy.Instance.Translate("command_pay_error_pay_self_colored")), Color.white, null, ((UnturnedPlayer)caller).SteamPlayer(), EChatMode.SAY, BankingSystem.Instance.Configuration.Instance.iconUrl, true); } else { UnturnedChat.Say(caller, Uconomy.Instance.Translations.Instance.Translate("command_pay_error_pay_self"), UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green)); } return; } if (!decimal.TryParse(command[1], out var amount) || amount <= 0) { if (caller is UnturnedPlayer) { ChatManager.serverSendMessage(BankingSystem.Instance.Translate("chat_title", Uconomy.Instance.Translate("command_pay_error_invalid_amount_colored")), Color.white, null, ((UnturnedPlayer)caller).SteamPlayer(), EChatMode.SAY, BankingSystem.Instance.Configuration.Instance.iconUrl, true); } else { UnturnedChat.Say(caller, Uconomy.Instance.Translations.Instance.Translate("command_pay_error_invalid_amount"), UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green)); } return; } if (caller is ConsolePlayer) { Uconomy.Instance.Database.IncreaseBalance(otherPlayer, amount); if (otherPlayerOnline != null) { ChatManager.serverSendMessage(BankingSystem.Instance.Translate("chat_title", Uconomy.Instance.Translate("command_pay_console_colored", amount, Uconomy.Instance.Configuration.Instance.MoneyName)), Color.white, null, otherPlayerOnline.SteamPlayer(), EChatMode.SAY, BankingSystem.Instance.Configuration.Instance.iconUrl, true); } } else { var myBalance = Uconomy.Instance.Database.GetBalance(caller.Id); if (myBalance - amount <= 0) { if (caller is UnturnedPlayer) { ChatManager.serverSendMessage(BankingSystem.Instance.Translate("chat_title", Uconomy.Instance.Translate("command_pay_error_invalid_amount_colored")), Color.white, null, ((UnturnedPlayer)caller).SteamPlayer(), EChatMode.SAY, BankingSystem.Instance.Configuration.Instance.iconUrl, true); } else { UnturnedChat.Say(caller, Uconomy.Instance.Translations.Instance.Translate("command_pay_error_cant_afford"), UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green)); } } else { Uconomy.Instance.Database.IncreaseBalance(caller.Id, -amount); if (otherPlayerOnline != null) { if (caller is UnturnedPlayer) { ChatManager.serverSendMessage(BankingSystem.Instance.Translate("chat_title", Uconomy.Instance.Translate("command_pay_private_colored", otherPlayerOnline.CharacterName, amount, Uconomy.Instance.Configuration.Instance.MoneyName)), Color.white, null, ((UnturnedPlayer)caller).SteamPlayer(), EChatMode.SAY, BankingSystem.Instance.Configuration.Instance.iconUrl, true); } else { UnturnedChat.Say(caller, Uconomy.Instance.Translations.Instance.Translate("command_pay_private", otherPlayerOnline.CharacterName, amount, Uconomy.Instance.Configuration.Instance.MoneyName), UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green)); } } else { if (caller is UnturnedPlayer) { ChatManager.serverSendMessage(BankingSystem.Instance.Translate("chat_title", Uconomy.Instance.Translate("command_pay_private_colored", otherPlayer, amount, Uconomy.Instance.Configuration.Instance.MoneyName)), Color.white, null, ((UnturnedPlayer)caller).SteamPlayer(), EChatMode.SAY, BankingSystem.Instance.Configuration.Instance.iconUrl, true); } else { UnturnedChat.Say(caller, Uconomy.Instance.Translations.Instance.Translate("command_pay_private", otherPlayer, amount, Uconomy.Instance.Configuration.Instance.MoneyName), UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green)); } } Uconomy.Instance.Database.IncreaseBalance(otherPlayer, amount); if (otherPlayerOnline != null) { if (otherPlayerOnline is UnturnedPlayer) { ChatManager.serverSendMessage(BankingSystem.Instance.Translate("chat_title", Uconomy.Instance.Translate("command_pay_other_private_colored", amount, Uconomy.Instance.Configuration.Instance.MoneyName, caller.DisplayName)), Color.white, null, otherPlayerOnline.SteamPlayer(), EChatMode.SAY, BankingSystem.Instance.Configuration.Instance.iconUrl, true); } else { UnturnedChat.Say(otherPlayerOnline.CSteamID, Uconomy.Instance.Translations.Instance.Translate("command_pay_other_private", amount, Uconomy.Instance.Configuration.Instance.MoneyName, caller.DisplayName), UnturnedChat.GetColorFromName(Uconomy.MessageColor, Color.green)); } } Uconomy.Instance.HasBeenPayed((UnturnedPlayer)caller, otherPlayer, amount); } } } else { if (otherPlayerOnline is UnturnedPlayer) { ChatManager.serverSendMessage(BankingSystem.Instance.Translate("chat_title", Uconomy.Instance.Translate("command_pay_error_player_not_found_colored")), Color.white, null, otherPlayerOnline.SteamPlayer(), EChatMode.SAY, BankingSystem.Instance.Configuration.Instance.iconUrl, true); } else { UnturnedChat.Say(caller, Uconomy.Instance.Translations.Instance.Translate("command_pay_error_player_not_found")); } } }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; if (command.Length < 1) { return; } if (command[0].ToString().ToLower() == "help") { Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("help_1"), Color.yellow); Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("help_2"), Color.yellow); Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("help_3"), Color.yellow); Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("help_4"), Color.yellow); Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("help_5"), Color.yellow); Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("help_6"), Color.yellow); return; } if (command [0].ToString().ToLower() == "list") { string playerName = player.CharacterName + ".txt"; string currentPath = System.IO.Directory.GetCurrentDirectory(); string filePathName = currentPath + "\\Plugins\\CFire\\Players\\Characters\\" + playerName; List <string> cfList = File.ReadAllLines(filePathName).ToList(); string cfActive = string.Join(",", cfList.ToArray()); if (cfActive != "") { Rocket.Unturned.Chat.UnturnedChat.Say(player, "Active Ceasefires: " + cfActive, Color.red); } if (cfActive == "") { Rocket.Unturned.Chat.UnturnedChat.Say(player, "Active Ceasefires: None", Color.red); } } if (command[0].ToString().ToLower() == "tp") { float flo = 0.0F; Vector3 pos; if (CFire_Plug.CFire_Plugin.Instance.tpDeaths.ContainsKey(player.CSteamID)) { CFire_Plug.CFire_Plugin.Instance.tpDeaths.TryGetValue(player.CSteamID, out pos); player.Teleport(pos, flo); CFire_Plug.CFire_Plugin.Instance.tpDeaths.Remove(player.CSteamID); } else { Rocket.Unturned.Chat.UnturnedChat.Say(player, CFire_Plugin.Instance.Translate("error_tp"), Color.red); return; } } if (command[0].ToString().ToLower() == "accept" || command[0].ToString().ToLower() == "a") { if (!player.HasPermission("cfire.accept")) { Rocket.Unturned.Chat.UnturnedChat.Say(player, CFire_Plugin.Instance.Translate("nopermission_accept"), Color.red); return; } if (requests.ContainsKey(player.CSteamID)) { UnturnedPlayer tpP = UnturnedPlayer.FromCSteamID(requests[player.CSteamID]); requests.Remove(player.CSteamID); Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("request_accepted") + " " + tpP.CharacterName, Color.yellow); Rocket.Unturned.Chat.UnturnedChat.Say(tpP, player.CharacterName + " " + CFire_Plugin.Instance.Translate("request_accepted_1"), Color.yellow); string player1filename = player.CSteamID + ".txt"; string player2filename = tpP.CSteamID + ".txt"; string player1SID = player.CSteamID + ""; string player2SID = tpP.CSteamID + ""; string player1filename2 = player.CharacterName + ".txt"; string player2filename2 = tpP.CharacterName + ".txt"; string player1Name = player.CharacterName + ""; string player2Name = tpP.CharacterName + ""; string currentPath = System.IO.Directory.GetCurrentDirectory(); //write SID files using (System.IO.StreamWriter file = new System.IO.StreamWriter(currentPath + "\\Plugins\\CFire\\Players\\" + player2filename, true)) { file.WriteLine(player1SID); file.Close(); } using (System.IO.StreamWriter file = new System.IO.StreamWriter(currentPath + "\\Plugins\\CFire\\Players\\" + player1filename, true)) { file.WriteLine(player2SID); file.Close(); } //write character name files using (System.IO.StreamWriter file = new System.IO.StreamWriter(currentPath + "\\Plugins\\CFire\\Players\\Characters\\" + player2filename2, true)) { file.WriteLine(player1Name); file.Close(); } using (System.IO.StreamWriter file = new System.IO.StreamWriter(currentPath + "\\Plugins\\CFire\\Players\\Characters\\" + player1filename2, true)) { file.WriteLine(player2Name); file.Close(); } } else { Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("request_none"), Color.red); } } else if (command[0].ToString() == "deny" || command[0].ToString().ToLower() == "d") { if (!player.HasPermission("cfire.deny")) { Rocket.Unturned.Chat.UnturnedChat.Say(player, CFire_Plugin.Instance.Translate("nopermission_deny"), Color.red); return; } if (requests.ContainsKey(player.CSteamID)) { UnturnedPlayer tpP = UnturnedPlayer.FromCSteamID(requests[player.CSteamID]); requests.Remove(player.CSteamID); Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("request_denied") + " " + tpP.CharacterName, Color.yellow); Rocket.Unturned.Chat.UnturnedChat.Say(tpP, player.CharacterName + " " + CFire_Plugin.Instance.Translate("request_denied_1"), Color.red); } else { Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("request_none"), Color.red); } } else //Try sending a ceasefire request to a player. { if (!player.HasPermission("cfire.send")) { Rocket.Unturned.Chat.UnturnedChat.Say(player, CFire_Plugin.Instance.Translate("nopermission_send"), Color.red); return; } UnturnedPlayer rTo = UnturnedPlayer.FromName(command[0].ToString()); #region Error Checking if (rTo == null && command[0].ToString() != "tp" && command[0].ToString() != "list") { Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("playerNotFound"), Color.red); Steamworks.CSteamID id; CFire_Plug.CFire_Plugin.Instance.link.TryGetValue(command[0].ToString(), out id); string currentPathz = System.IO.Directory.GetCurrentDirectory(); string player5SID = player.CSteamID + ""; string player5Name = player.CharacterName + ""; string player5SIDFile = player.CSteamID + ".txt"; string player5File = player.CharacterName + ".txt"; string fileName5SID = currentPathz + "\\Plugins\\CFire\\Players\\" + player5SIDFile; string fileName5 = currentPathz + "\\Plugins\\CFire\\Players\\Characters\\" + player5File; string player6SID = id + ""; string player6Name = command[0].ToString() + ""; string player6SIDFile = id + ".txt"; string player6File = command[0].ToString() + ".txt"; string fileName6SID = currentPathz + "\\Plugins\\CFire\\Players\\" + player6SIDFile; string fileName6 = currentPathz + "\\Plugins\\CFire\\Players\\Characters\\" + player6File; string linez; System.IO.StreamReader filez = new System.IO.StreamReader(fileName5); while ((linez = filez.ReadLine()) != null) { if (linez == player6Name) { filez.Close(); List <string> cfListz = File.ReadAllLines(fileName5).ToList(); cfListz.Remove(player6Name); File.WriteAllLines(fileName5, cfListz.ToArray()); List <string> cfListx = File.ReadAllLines(fileName5SID).ToList(); cfListx.Remove(player6SID); File.WriteAllLines(fileName5SID, cfListx.ToArray()); List <string> cfListy = File.ReadAllLines(fileName6).ToList(); cfListy.Remove(player5Name); File.WriteAllLines(fileName6, cfListy.ToArray()); List <string> cfListw = File.ReadAllLines(fileName6SID).ToList(); cfListw.Remove(player5SID); File.WriteAllLines(fileName6SID, cfListw.ToArray()); Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("offlineRemove"), Color.red); break; } } } if (rTo != null && player != null && caller != null) //prevents null exceptions { //Need to prevent spam requests. if (requests.ContainsKey(rTo.CSteamID)) { if (requests[rTo.CSteamID] == player.CSteamID) { Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("request_pending") + " " + rTo.CharacterName, Color.red); return; } } #endregion if (coolDown.ContainsKey(player.CSteamID)) { //Rocket.Unturned.Chat.UnturnedChat.Say(caller, "Debug: " + (DateTime.Now - coolDown[player.CSteamID]).TotalSeconds); if ((DateTime.Now - coolDown[player.CSteamID]).TotalSeconds < CFire_Plugin.Instance.Configuration.Instance.CFireCoolDownSeconds) { Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("error_cooldown"), Color.red); return; } coolDown.Remove(player.CSteamID); } if (coolDown.ContainsKey(player.CSteamID)) { coolDown[player.CSteamID] = DateTime.Now; } else { coolDown.Add(player.CSteamID, DateTime.Now); } UnturnedPlayer tgt = UnturnedPlayer.FromName(command[0].ToString()); if (player.CharacterName == tgt.CharacterName) { Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("request_dopple"), Color.yellow); return; } bool cf = false; string currentPath = System.IO.Directory.GetCurrentDirectory(); string player1SID = player.CSteamID + ""; string player2SID = tgt.CSteamID + ""; string player1Name = player.CharacterName + ""; string player2Name = tgt.CharacterName + ""; string player1File = player.CSteamID + ".txt"; string player2File = tgt.CSteamID + ".txt"; string player3File = player.CharacterName + ".txt"; string player4File = tgt.CharacterName + ".txt"; string fileName1 = currentPath + "\\Plugins\\CFire\\Players\\" + player1File; string fileName2 = currentPath + "\\Plugins\\CFire\\Players\\" + player2File; string fileName3 = currentPath + "\\Plugins\\CFire\\Players\\Characters\\" + player3File; string fileName4 = currentPath + "\\Plugins\\CFire\\Players\\Characters\\" + player4File; string line; System.IO.StreamReader file = new System.IO.StreamReader(fileName1); while ((line = file.ReadLine()) != null) { if (line == player2SID) { Rocket.Unturned.Chat.UnturnedChat.Say(player, CFire_Plugin.Instance.Translate("cancel_cf") + " " + rTo.CharacterName + " " + CFire_Plugin.Instance.Translate("cancel_cf_1"), Color.yellow); Rocket.Unturned.Chat.UnturnedChat.Say(rTo, player.CharacterName + " " + CFire_Plugin.Instance.Translate("cancel_cf_2"), Color.yellow); new Thread(() => { Thread.CurrentThread.IsBackground = true; while ((DateTime.Now - coolDown[player.CSteamID]).TotalSeconds < CFire_Plugin.Instance.Configuration.Instance.CFireCeaseFireEndSeconds) { //do nothing for delay } file.Close(); //remove ceasefire from first player SID List <string> cfList1 = File.ReadAllLines(fileName1).ToList(); cfList1.Remove(player2SID); File.WriteAllLines(fileName1, cfList1.ToArray()); //remove ceasefire from second player SID List <string> cfList2 = File.ReadAllLines(fileName2).ToList(); cfList2.Remove(player1SID); File.WriteAllLines(fileName2, cfList2.ToArray()); //remove ceasefire from first player Name List <string> cfList3 = File.ReadAllLines(fileName3).ToList(); cfList3.Remove(player2Name); File.WriteAllLines(fileName3, cfList3.ToArray()); //remove ceasefire from second player Name List <string> cfList4 = File.ReadAllLines(fileName4).ToList(); cfList4.Remove(player1Name); File.WriteAllLines(fileName4, cfList4.ToArray()); Rocket.Unturned.Chat.UnturnedChat.Say(player, CFire_Plugin.Instance.Translate("cf_ended") + rTo.CharacterName + CFire_Plugin.Instance.Translate("cf_ended_1"), Color.red); Rocket.Unturned.Chat.UnturnedChat.Say(rTo, CFire_Plugin.Instance.Translate("cf_ended") + player.CharacterName + CFire_Plugin.Instance.Translate("cf_ended_1"), Color.red); }).Start(); cf = true; break; } } file.Close(); if (player.CharacterName != tgt.CharacterName) { if (cf == false) { if (requests.ContainsKey(rTo.CSteamID)) { requests [rTo.CSteamID] = player.CSteamID; Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("request_sent") + " " + rTo.CharacterName, Color.yellow); Rocket.Unturned.Chat.UnturnedChat.Say(rTo, player.CharacterName + " " + CFire_Plugin.Instance.Translate("request_sent_1"), Color.yellow); } else { requests.Add(rTo.CSteamID, player.CSteamID); Rocket.Unturned.Chat.UnturnedChat.Say(caller, CFire_Plugin.Instance.Translate("request_sent") + " " + rTo.CharacterName, Color.yellow); Rocket.Unturned.Chat.UnturnedChat.Say(rTo, player.CharacterName + " " + CFire_Plugin.Instance.Translate("request_sent_1"), Color.yellow); } } } } } }
public void Execute(IRocketPlayer caller, params string[] command) { if (command.Length == 3 && command[0] == "add" && caller.HasPermission("hitman.add")) { var otherPlayer = UnturnedPlayer.FromName(command[1]); if (otherPlayer == null) { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_not_found") != "hitman_general_not_found") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_general_not_found")); } return; } if (caller.Id == otherPlayer.Id) { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_self") != "hitman_add_self") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_add_self")); } return; } decimal bounty = 0; if (!decimal.TryParse(command[2], out bounty) || bounty <= 0) { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_amount") != "hitman_add_amount") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_add_amount")); } return; } var myBalance = Uconomy.Instance.Database.GetBalance(caller.Id); if (myBalance - bounty < 0) { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_balance") != "hitman_add_balance") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_add_balance")); } return; } if (bounty < FeexHitman.Instance.Configuration.Instance.MinimumBounty) { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_minimum") != "hitman_add_minimum") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_add_minimum", FeexHitman.Instance.Configuration.Instance.MinimumBounty)); } return; } if (FeexHitman.Instance.FeexHitmanDatabase.CheckExists(otherPlayer.CSteamID)) { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_increased") != "hitman_general_chat_increased") { UnturnedChat.Say( FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_increased", otherPlayer.CharacterName, bounty, Convert.ToDecimal( FeexHitman.Instance.FeexHitmanDatabase.GetBounty(otherPlayer.CSteamID)) + bounty), UnityEngine.Color.yellow); } } else { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_created") != "hitman_general_chat_created") { UnturnedChat.Say( FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_created", otherPlayer.CharacterName, bounty), UnityEngine.Color.yellow); } } Uconomy.Instance.Database.IncreaseBalance(caller.Id.ToString(), -bounty); FeexHitman.Instance.FeexHitmanDatabase.AddUpdateVictimAccount(otherPlayer.CSteamID, bounty, otherPlayer.CharacterName); } else if (command.Length == 2 && command[0] == "payout" && caller.HasPermission("hitman.payout")) { var otherPlayer = UnturnedPlayer.FromName(command[1]); if (otherPlayer == null) { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_not_found") != "hitman_general_not_found") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_general_not_found")); } return; } if (FeexHitman.Instance.FeexHitmanDatabase.CheckExists(otherPlayer.CSteamID)) { var bounty = FeexHitman.Instance.FeexHitmanDatabase.GetBounty(otherPlayer.CSteamID); Uconomy.Instance.Database.IncreaseBalance(caller.Id, bounty); FeexHitman.Instance.FeexHitmanDatabase.RemoveVictimAccount(otherPlayer.CSteamID); if (FeexHitman.Instance.Translations.Instance.Translate("hitman_payout") != "hitman_payout") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_payout", otherPlayer.CharacterName, bounty)); } } else { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_check_false") != "hitman_check_false") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_check_false", otherPlayer.CharacterName)); } } } else if (command.Length == 2 && command[0] == "check" && caller.HasPermission("hitman.check")) { var otherPlayer = UnturnedPlayer.FromName(command[1]); if (otherPlayer == null) { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_not_found") != "hitman_general_not_found") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_general_not_found")); } return; } if (FeexHitman.Instance.FeexHitmanDatabase.CheckExists(otherPlayer.CSteamID)) { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_check_true") != "hitman_check_true") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_check_true", otherPlayer.CharacterName, FeexHitman.Instance.FeexHitmanDatabase.GetBounty(otherPlayer.CSteamID))); } } else { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_check_false") != "hitman_check_false") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_check_false", otherPlayer.CharacterName)); } } } else if (command.Length == 1 && command[0] == "list" && caller.HasPermission("hitman.list")) { if (FeexHitman.Instance.FeexHitmanDatabase.GetBountyCount() == 0) { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_list_false") != "hitman_list_false") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_list_false")); } } else { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_list_true") != "hitman_list_true") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_list_true", FeexHitman.Instance.FeexHitmanDatabase.GetBountyCount(), FeexHitman.Instance.FeexHitmanDatabase.GetBountyList())); } } } else { if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_invalid_parameter") != "hitman_general_invalid_parameter") { UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_general_invalid_parameter")); } } }
public void Execute(IRocketPlayer caller, params string[] command) { try { if (command.Length == 0 || command.Length > 3) { UnturnedChat.Say(caller, "Invalid input. /mute <name> Reason <time>", UnturnedChat.GetColorFromName(UTools.Instance.Configuration.Instance.DutyMsgColor, Color.red)); return; } bool isOnline = false; CSteamID steamid; string charactername = null; string adminId = "Console"; string adminName = "Console"; string reason = ""; int duration = 0; UnturnedPlayer otherPlayer = UnturnedPlayer.FromName(command[0]); ulong? otherPlayerID = command.GetCSteamIDParameter(0); if (otherPlayer == null || otherPlayer.CSteamID.ToString() == "0" || caller != null && otherPlayer.CSteamID.ToString() == caller.Id) { KeyValuePair <CSteamID, string> player = UTools.GetPlayer(command[0]); if (player.Key.ToString() != "0") { steamid = player.Key; charactername = player.Value; } else { if (otherPlayerID != null) { steamid = new CSteamID(otherPlayerID.Value); Profile playerProfile = new Profile(otherPlayerID.Value); charactername = playerProfile.SteamID; } else { UnturnedChat.Say(caller, UTools.Instance.Translate("tpa_player_not_found"), UnturnedChat.GetColorFromName(UTools.Instance.Configuration.Instance.DutyMsgColor, Color.red)); return; } } } else { isOnline = true; steamid = otherPlayer.CSteamID; charactername = otherPlayer.CharacterName; if (otherPlayer.HasPermission("mute.immune")) { UnturnedChat.Say(caller, UTools.Instance.Translate("mute_immune", otherPlayer.CharacterName)); return; } } if (caller != null) { if (caller.ToString() != "Rocket.API.ConsolePlayer") { adminId = caller.ToString(); } adminName = caller.DisplayName; } if (adminId.ToString() == steamid.ToString()) { UnturnedChat.Say(caller, "You cannot mute yourself!", UnturnedChat.GetColorFromName(UTools.Instance.Configuration.Instance.DutyMsgColor, Color.red)); return; } if (UTools.Instance.Database.convertTimeToSeconds(UTools.Instance.Configuration.Instance.DefaultMuteDuration) != 0) { int.TryParse(UTools.Instance.Database.convertTimeToSeconds(UTools.Instance.Configuration.Instance.DefaultMuteDuration).ToString(), out duration); } if (command.Length == 3) { if (int.TryParse(UTools.Instance.Database.convertTimeToSeconds(command[2]).ToString(), out duration)) { reason = command[1]; } else { UnturnedChat.Say(caller, UTools.Instance.Translate("Invalid use! /mute <name> Reason <time>"), UnturnedChat.GetColorFromName(UTools.Instance.Configuration.Instance.DutyMsgColor, Color.red)); return; } } else if (command.Length == 2) { if (UTools.Instance.Database.convertTimeToSeconds(command[1]) > 0) { int.TryParse(UTools.Instance.Database.convertTimeToSeconds(command[1]).ToString(), out duration); } else { reason = command[1]; } } if (UTools.Instance.Database.IsChatBanned(steamid.ToString()) != null) { UnturnedChat.Say(caller, "Player already muted", UnturnedChat.GetColorFromName(UTools.Instance.Configuration.Instance.DutyMsgColor, Color.red)); return; } UTools.Instance.Database.ChatBanPlayer(charactername, steamid.ToString(), adminId, reason, duration); UnturnedChat.Say(UTools.Instance.Translate("mute_public", charactername), UnturnedChat.GetColorFromName(UTools.Instance.Configuration.Instance.DutyMsgColor, Color.red)); UnturnedChat.Say(steamid, UTools.Instance.Translate("mute_private", (duration / 60)), UnturnedChat.GetColorFromName(UTools.Instance.Configuration.Instance.DutyMsgColor, Color.red)); } catch (System.Exception e) { Rocket.Core.Logging.Logger.LogException(e); } }
public void Execute(IRocketPlayer caller, params string[] command) { try { if (PlayerReport.Instance.MySQLON) { if (caller is ConsolePlayer) { Logger.Log(PlayerReport.Instance.Translate("command_from_console")); return; } if (command.Length < 2) { UnturnedChat.Say(caller, "Try /report " + Syntax); return; } // To admins test if this command is working if (PlayerReport.Instance.Configuration.Instance.TestCode && (command[0] == PlayerReport.Instance.Configuration.Instance.KeyTestCode)) { UnturnedPlayer Reported1 = UnturnedPlayer.FromName(command[1]); UnturnedPlayer Reporter1 = (UnturnedPlayer)caller; if (Reported1 == null) { UnturnedChat.Say(caller, PlayerReport.Instance.Translate("command_player_not_found")); return; } string ReportText1 = ""; int num1 = 0; foreach (var c in command) { num1++; if (num1 == 1) { continue; } ReportText1 = ReportText1 + " " + c; } if (PlayerReport.Instance.Configuration.Instance.LimCharacter <= 5) { PlayerReport.Instance.Configuration.Instance.DatabasePort = 50; PlayerReport.Instance.Configuration.Save(); } if (PlayerReport.Instance.Configuration.Instance.MaxCharacter) { if (ReportText1.Length <= PlayerReport.Instance.Configuration.Instance.LimCharacter) { PlayerReport.Instance.Database.MySqlAddReport(caller, Reported1.CSteamID, Reporter1.CSteamID, ReportText1); } else { UnturnedChat.Say(caller, PlayerReport.Instance.Translate("command_report_maxchar")); } } else { PlayerReport.Instance.Database.MySqlAddReport(caller, Reported1.CSteamID, Reporter1.CSteamID, ReportText1); } return; } UnturnedPlayer Reported = UnturnedPlayer.FromName(command[0]); UnturnedPlayer Reporter = (UnturnedPlayer)caller; if (Reported == null) { UnturnedChat.Say(caller, PlayerReport.Instance.Translate("command_player_not_found")); return; } if (caller.Id == Reported.Id) { UnturnedChat.Say(caller, PlayerReport.Instance.Translate("command_report_yourself")); return; } string ReportText = ""; int num = 0; foreach (var s in command) { num++; if (num == 1) { continue; } ReportText = ReportText + " " + s; } if (PlayerReport.Instance.Configuration.Instance.LimCharacter <= 5) { PlayerReport.Instance.Configuration.Instance.DatabasePort = 50; PlayerReport.Instance.Configuration.Save(); } if (PlayerReport.Instance.Configuration.Instance.MaxCharacter) { if (ReportText.Length <= PlayerReport.Instance.Configuration.Instance.LimCharacter) { PlayerReport.Instance.Database.MySqlAddReport(caller, Reported.CSteamID, Reporter.CSteamID, ReportText); if (PlayerReport.Instance.Configuration.Instance.LogFile) { File.AppendAllText(PlayerReport.ReportLog, "[" + DateTime.Now + "] " + Reported.DisplayName + "(" + Reported.Id + ") " + "was reported by " + Reporter.DisplayName + "(" + Reporter.Id + ") because" + ReportText + Environment.NewLine); } } else { UnturnedChat.Say(caller, PlayerReport.Instance.Translate("command_report_maxchar")); } } else { PlayerReport.Instance.Database.MySqlAddReport(caller, Reported.CSteamID, Reporter.CSteamID, ReportText); if (PlayerReport.Instance.Configuration.Instance.LogFile) { File.AppendAllText(PlayerReport.ReportLog, "[" + DateTime.Now + "] " + Reported.DisplayName + "(" + Reported.Id + ") " + "was reported by " + Reporter.DisplayName + "(" + Reporter.Id + ") because" + ReportText + Environment.NewLine); } } } else { if (caller is ConsolePlayer) { Logger.Log(PlayerReport.Instance.Translate("command_erro_saving")); return; } else { UnturnedChat.Say(caller, PlayerReport.Instance.Translate("command_erro_saving")); } } } catch (Exception ex) { Logger.Log(ex); } }
public void Execute(IRocketPlayer caller, string [] command) { UnturnedPlayer player = (UnturnedPlayer)caller; if (command.Length > 0) { var trail = Trails.Instance.Configuration.Instance.customTrails.Where(t => t.name.ToLower().Contains(command [1].ToLower())).FirstOrDefault(); if (trail == null) { UnturnedChat.Say(player, Trails.Instance.Translate("trail_not_found", command [1]), Color.red); return; } switch (command [0].ToLower()) { case "add": case "a": if (command.Length == 3) { if (player.HasPermission("trail.player.force")) { UnturnedPlayer setPlayer = UnturnedPlayer.FromName(command [2]); if (setPlayer != null) { if (Trails.trails.ContainsKey((ulong)setPlayer.CSteamID)) { Trails.trails [(ulong)setPlayer.CSteamID].Add(trail.id); } else { Trails.trails.Add((ulong)setPlayer.CSteamID, new List <ushort> () { trail.id }); } UnturnedChat.Say(setPlayer, Trails.Instance.Translate("set_trail_by_admin", trail.name, player.DisplayName), Color.green); UnturnedChat.Say(player, Trails.Instance.Translate("set_trail_admin", setPlayer.DisplayName, trail.name), Color.green); } else { UnturnedChat.Say(player, Trails.Instance.Translate("player_not_found", command [1]), Color.red); } } else { UnturnedChat.Say(player, Trails.Instance.Translate("no_force_permission"), Color.red); } } else { if (player.HasPermission(trail.permission.ToLower())) { if (Trails.trails.ContainsKey((ulong)player.CSteamID)) { Trails.trails [(ulong)player.CSteamID].Add(trail.id); } else { Trails.trails.Add((ulong)player.CSteamID, new List <ushort> () { trail.id }); } UnturnedChat.Say(player, Trails.Instance.Translate("set_trail", trail.name), Color.green); } else { UnturnedChat.Say(player, Trails.Instance.Translate("no_permission", trail.name), Color.red); } } break; case "remove": case "r": if (command.Length == 2) { if (command [1] == "*") { if (Trails.trails.ContainsKey((ulong)player.CSteamID)) { Trails.trails.Remove((ulong)player.CSteamID); } UnturnedChat.Say(player, Trails.Instance.Translate("removed_all_trails"), Color.green); } else { if (Trails.trails.ContainsKey((ulong)player.CSteamID)) { if (Trails.trails [(ulong)player.CSteamID].Contains(trail.id)) { Trails.trails.Remove(trail.id); } } } } break; case "help": case "h": if (command.Length >= 2) { switch (command [1].ToLower()) { case "add": case "a": UnturnedChat.Say(player, "/trail add <trail name> [player name]", Color.green); break; case "remove": case "r": UnturnedChat.Say(player, "/trail remove <* | trail name>", Color.green); break; default: UnturnedChat.Say(player, "Invalid Format: /trail help <add | remove>", Color.red); break; } } else { UnturnedChat.Say(player, "Invalid Format: /trail help <add | remove>", Color.red); } break; default: UnturnedChat.Say(player, "Invalid Format: /trail <add | remove | help>", Color.red); break; } } else { if (Trails.trails.ContainsKey((ulong)player.CSteamID)) { Trails.trails.Remove((ulong)player.CSteamID); } UnturnedChat.Say(player, Trails.Instance.Translate("removed_all_trails"), Color.green); } }
public void Execute(IRocketPlayer caller, string[] command) { if (caller is ConsolePlayer) { if (command.Length == 0) { Logger.Log("missing parameter"); return; } UnturnedPlayer player = UnturnedPlayer.FromName(command[0]); IRocketPlayer Rplayer = (IRocketPlayer)player; if (player == null) { Logger.Log("failed to find player by the name: " + command[0]); return; } if (player.Features.GodMode) { player.Features.GodMode = false; Logger.Log(player.DisplayName + " is no longer in godmode"); UnturnedChat.Say(Rplayer, "you are no longer in godmode", UnityEngine.Color.yellow); } else { player.Features.GodMode = true; Logger.Log(player.DisplayName + " is now in godmode"); UnturnedChat.Say(Rplayer, "you are now in godmode", UnityEngine.Color.yellow); } } else { UnturnedPlayer player = (UnturnedPlayer)caller; if (command.Length == 1 && caller.HasPermission("godmode.other")) { UnturnedPlayer Uplayer = UnturnedPlayer.FromName(command[0]); IRocketPlayer Rplayer = (IRocketPlayer)Uplayer; if (Uplayer.Features.GodMode) { Uplayer.Features.GodMode = false; UnturnedChat.Say(caller, "you have disabled godmode on: " + Uplayer.DisplayName, UnityEngine.Color.yellow); UnturnedChat.Say(Rplayer, caller.DisplayName + " has taken you out of godmode", UnityEngine.Color.yellow); Logger.Log(caller.DisplayName + " has taken " + Uplayer.DisplayName + " out of godmode"); } else { Uplayer.Features.GodMode = true; UnturnedChat.Say(caller, "you have enabled godmode on: " + Uplayer.DisplayName, UnityEngine.Color.yellow); UnturnedChat.Say(Rplayer, caller.DisplayName + " has put you in godmode", UnityEngine.Color.yellow); Logger.Log(caller.DisplayName + " has put " + Uplayer.DisplayName + " in godmode"); } return; } if (player.Features.GodMode) { player.Features.GodMode = false; string globalMessage = player.DisplayName + " has disabled godmode"; Logger.Log(globalMessage); UnturnedChat.Say(globalMessage, UnityEngine.Color.yellow); } else { player.Features.GodMode = true; string globalMessage = player.DisplayName + " has enabled godmode"; Logger.Log(globalMessage); UnturnedChat.Say(globalMessage, UnityEngine.Color.yellow); } } }
public void Execute(IRocketPlayer caller, string[] command) { var player = (UnturnedPlayer)caller; switch (command.Length) { case 1: UnturnedChat.Say(caller, Syntax); break; case 2: UnturnedPlayer player2 = UnturnedPlayer.FromName(command[0]); if (player2 != null) { if (player2.Id == player.Id) { UnturnedChat.Say(caller, Economy.Instance.Translate("pay_nopoint")); } else { int money = Convert.ToInt32(command[1]); if (money > 0) { if (Economy.Instance.Configuration.Instance.XpMode == false) { if (money < EconomyDB.GetBalance(player) + 1) { EconomyDB.RemoveBalance(player, money); EconomyDB.AddBalance(player2, money); UnturnedChat.Say(caller, string.Format(Economy.Instance.Translate("pay_success"), money, Economy.Instance.Configuration.Instance.CurrencyName, player2.DisplayName)); UnturnedChat.Say(player2, string.Format(Economy.Instance.Translate("pay_recieve"), money, Economy.Instance.Configuration.Instance.CurrencyName, player.DisplayName)); } else { UnturnedChat.Say(caller, Economy.Instance.Translate("no_balance")); } } else { if (money < player.Experience + 1) { player.Experience = player.Experience - (uint)money; player2.Experience = player.Experience + (uint)money; UnturnedChat.Say(caller, string.Format(Economy.Instance.Translate("xppay_success"), money, player2.DisplayName)); UnturnedChat.Say(player2, string.Format(Economy.Instance.Translate("xppay_recieve"), money, player.DisplayName)); Logger.Log(string.Format(Economy.Instance.Translate("c_pay_success"), money, player2.DisplayName, caller.DisplayName)); } else { UnturnedChat.Say(caller, Economy.Instance.Translate("no_balance")); } } } else { UnturnedChat.Say(caller, Economy.Instance.Translate("err_ammount")); } } } else { UnturnedChat.Say(caller, Syntax); } break; default: UnturnedChat.Say(caller, Syntax); break; } }
public void Execute(IRocketPlayer caller, params string[] command) { if (command.Length == 1) { UnturnedPlayer player = (UnturnedPlayer)caller; UnturnedPlayer otherplayer = UnturnedPlayer.FromName(command[0]); if (otherplayer == null) { UnturnedChat.Say(caller, Plugin.Instance.Translate("player_not_found"), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); return; } else if (otherplayer.Id == caller.Id) { player.CurrentVehicle.tryRemovePlayer(out _, player.CSteamID, out _, out _); UnturnedChat.Say(caller, Plugin.Instance.Translate("driverkick_self"), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); return; } else if (player.CurrentVehicle.lockedOwner == player.CSteamID && player.HasPermission("myvehicle.driverkick")) { if (otherplayer.IsInVehicle) { if (otherplayer.CurrentVehicle.isDriver) { otherplayer.CurrentVehicle.tryRemovePlayer(out _, player.CSteamID, out _, out _); UnturnedChat.Say(caller, Plugin.Instance.Translate("driverkick", otherplayer.DisplayName), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); UnturnedChat.Say(otherplayer, Plugin.Instance.Translate("kicked", caller.DisplayName), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); } else { UnturnedChat.Say(caller, Plugin.Instance.Translate("not_driving", otherplayer.DisplayName), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); } } else { UnturnedChat.Say(caller, Plugin.Instance.Translate("not_in_vehicle", otherplayer.DisplayName), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); } return; } if (caller.HasPermission("driverkick.admin") || caller.IsAdmin) { if (otherplayer.IsInVehicle) { if (otherplayer.CurrentVehicle.isDriver) { otherplayer.CurrentVehicle.tryRemovePlayer(out _, player.CSteamID, out _, out _); UnturnedChat.Say(caller, Plugin.Instance.Translate("driverkick", otherplayer.DisplayName), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); UnturnedChat.Say(otherplayer, Plugin.Instance.Translate("kicked", caller.DisplayName), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); } else { UnturnedChat.Say(caller, Plugin.Instance.Translate("not_driving", otherplayer.DisplayName), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); } } else { UnturnedChat.Say(caller, Plugin.Instance.Translate("not_in_vehicle", otherplayer.DisplayName), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); } return; } } if (command.Length == 0) { UnturnedPlayer player = (UnturnedPlayer)caller; if (player.IsInVehicle) { if (player.CurrentVehicle.isDriver) { player.CurrentVehicle.tryRemovePlayer(out _, player.CSteamID, out _, out _); UnturnedChat.Say(caller, Plugin.Instance.Translate("driverkick_self"), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); return; } else { UnturnedChat.Say(caller, Plugin.Instance.Translate("not_driving_self"), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); } } else { UnturnedChat.Say(caller, Plugin.Instance.Translate("not_in_vehicle_self"), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); return; } } else { UnturnedChat.Say(caller, Plugin.Instance.Translate("syntax", Syntax), UnturnedChat.GetColorFromName(Plugin.Instance.Configuration.Instance.MessageColor, Color.red)); } }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; if (command.Length == 0) // /jail { UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("jail.syntax")}", Color.red); return; } UnturnedPlayer toPlayer = UnturnedPlayer.FromName(command[0]); if (command.Length == 1) // /jail [playername] { if (toPlayer == null) { UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("jail.player.not.found", command[0])}", Color.red); return; } if (toPlayer.CSteamID == player.CSteamID) { UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("jail.player.self")}", Color.red); return; } UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("jail.syntax")}", Color.red); return; } int.TryParse(command[1], out int resultDuration); if (command.Length == 2) // /jail [playername] [duration] { if (toPlayer == null) { UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("jail.player.not.found", command[0])}", Color.red); return; } if (toPlayer.HasPermission(Permissions[0])) // есть ли у другого игрока пермишен иммунитета { UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("jail.player.immune", toPlayer.CharacterName)}", Color.red); return; } if (JailTimePlugin.Instance.Prison.IsPlayerContains(toPlayer.CSteamID)) // находится ли игрок в тюрьме { UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("jail.player.arrested", toPlayer.CharacterName, resultDuration)}", Color.red); return; } if (toPlayer.CSteamID == player.CSteamID) // проверка на само jail { UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("jail.player.self")}", Color.red); return; } // одеть наручники на игрока JailTimePlugin.Instance.Prison.HandcuffToPlayer(toPlayer.CSteamID); JailTimePlugin.Instance.Prison.ArrestPlayer(toPlayer.CSteamID, resultDuration); UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("jail.successful.arrested", toPlayer.CharacterName, resultDuration)}", Color.yellow); UnturnedChat.Say(toPlayer, $"{JailTimePlugin.Instance.Translate("jail.player.arrested.message", player.CharacterName, resultDuration)}", Color.red); } }