PageRenderTime 22ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/addons/sourcemod/scripting/funvotes/votealltalk.sp

https://bitbucket.org/kimoto/sushi
Unknown | 104 lines | 92 code | 12 blank | 0 comment | 0 complexity | b092e87919252143512a913609e74912 MD5 | raw file
  1. /**
  2. * vim: set ts=4 :
  3. * =============================================================================
  4. * SourceMod Basefunvotes Plugin
  5. * Provides votealltalk functionality
  6. *
  7. * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
  8. * =============================================================================
  9. *
  10. * This program is free software; you can redistribute it and/or modify it under
  11. * the terms of the GNU General Public License, version 3.0, as published by the
  12. * Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17. * details.
  18. *
  19. * You should have received a copy of the GNU General Public License along with
  20. * this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * As a special exception, AlliedModders LLC gives you permission to link the
  23. * code of this program (as well as its derivative works) to "Half-Life 2," the
  24. * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
  25. * by the Valve Corporation. You must obey the GNU General Public License in
  26. * all respects for all other code used. Additionally, AlliedModders LLC grants
  27. * this exception to all derivative works. AlliedModders LLC defines further
  28. * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
  29. * or <http://www.sourcemod.net/license.php>.
  30. *
  31. * Version: $Id$
  32. */
  33. DisplayVoteAllTalkMenu(client)
  34. {
  35. if (IsVoteInProgress())
  36. {
  37. ReplyToCommand(client, "[SM] %t", "Vote in Progress");
  38. return;
  39. }
  40. if (!TestVoteDelay(client))
  41. {
  42. return;
  43. }
  44. LogAction(client, -1, "\"%L\" initiated an alltalk vote.", client);
  45. ShowActivity2(client, "[SM] ", "%t", "Initiated Vote Alltalk");
  46. g_voteType = voteType:alltalk;
  47. g_voteInfo[VOTE_NAME][0] = '\0';
  48. g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
  49. if (GetConVarBool(g_Cvar_Alltalk))
  50. {
  51. SetMenuTitle(g_hVoteMenu, "Votealltalk Off");
  52. }
  53. else
  54. {
  55. SetMenuTitle(g_hVoteMenu, "Votealltalk On");
  56. }
  57. AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
  58. AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
  59. SetMenuExitButton(g_hVoteMenu, false);
  60. VoteMenuToAll(g_hVoteMenu, 20);
  61. }
  62. public AdminMenu_VoteAllTalk(Handle:topmenu,
  63. TopMenuAction:action,
  64. TopMenuObject:object_id,
  65. param,
  66. String:buffer[],
  67. maxlength)
  68. {
  69. if (action == TopMenuAction_DisplayOption)
  70. {
  71. Format(buffer, maxlength, "%T", "Alltalk vote", param);
  72. }
  73. else if (action == TopMenuAction_SelectOption)
  74. {
  75. DisplayVoteAllTalkMenu(param);
  76. }
  77. else if (action == TopMenuAction_DrawOption)
  78. {
  79. /* disable this option if a vote is already running */
  80. buffer[0] = !IsNewVoteAllowed() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
  81. }
  82. }
  83. public Action:Command_VoteAlltalk(client, args)
  84. {
  85. if (args > 0)
  86. {
  87. ReplyToCommand(client, "[SM] Usage: sm_votealltalk");
  88. return Plugin_Handled;
  89. }
  90. DisplayVoteAllTalkMenu(client);
  91. return Plugin_Handled;
  92. }