Guest User

Untitled

a guest
May 24th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. { "rp", SEC_PLAYER, true, NULL, "", rpCommandTable },
  2. { "gold", SEC_PLAYER, false, OldHandler<&ChatHandler::HandleGoldCommand>, "", NULL },
  3. { "spawn", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleXperimentCommand>, "", NULL },
  4.  
  5. bool ChatHandler::HandleGoldCommand(const char* args)
  6. {
  7. if (*args)
  8. return false;
  9.  
  10. Player* target = m_session->GetPlayer();
  11. target->SetMoney(MAX_MONEY_AMOUNT);
  12. PSendSysMessage("Added gold.");
  13. return true;
  14. }
  15.  
  16. bool ChatHandler::ShowHelpForSubCommands(ChatCommand* table, char const* cmd, char const* subcmd)
  17. {
  18. std::string list;
  19. for (uint32 i = 0; table[i].Name != NULL; ++i)
  20. {
  21. // must be available (ignore handler existence for show command with possibe avalable subcomands
  22. if (!isAvailable(table[i]))
  23. continue;
  24.  
  25. /// for empty subcmd show all available
  26. if (*subcmd && !hasStringAbbr(table[i].Name, subcmd))
  27. continue;
  28.  
  29. if (m_session)
  30. list += "\n ";
  31. else
  32. list += "\n\r ";
  33. list += "|cFFcc6600";
  34. list += table[i].Name;
  35. list += "|r";
  36. QueryResult text = WorldDatabase.PQuery("SELECT text FROM customhelp WHERE name = '%s'", table[i].Name);
  37. if (text)
  38. {
  39. std::string helptext = text->Fetch()[0].GetString();
  40. list += " ";
  41. list += "|cFF5785db";
  42. list += helptext;
  43. list += "|r";
  44. }
  45. if (table[i].ChildCommands)
  46. list += " |cFFc52e40<subcommands available>|r";
  47. }
  48.  
  49. if (list.empty())
  50. return false;
  51.  
  52. if (table == getCommandTable())
  53. {
  54. SendSysMessage(LANG_AVIABLE_CMD);
  55. PSendSysMessage("%s", list.c_str());
  56. PSendSysMessage("|cFFcbb6b8-Scroll up to see more commands-|r");
  57. }
  58. else
  59. PSendSysMessage(LANG_SUBCMDS_LIST, cmd, list.c_str());
  60. PSendSysMessage("|cFFcbb6b8-Scroll up to see more commands-|r");
  61.  
  62. return true;
  63. }
Add Comment
Please, Sign In to add comment