Advertisement
Hyuna

Admin Power Menu v1.0 by Hyuna

Jun 29th, 2016
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.75 KB | None | 0 0
  1. /*
  2.     AMX Mod X Plugin: Admin Powers Menu
  3.     Copyright (C) 2016  Hyuna aka NorToN
  4.  
  5.     This program is free software: you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation, either version 3 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17. */
  18.  
  19. #include <amxmodx>
  20. #include <amxmisc>
  21. #include <cstrike>
  22. #include <fun>
  23. #include <hamsandwich>
  24.  
  25. #pragma semicolon 1
  26.  
  27. #if !defined MAX_PLAYERS
  28.     #define MAX_PLAYERS 32
  29. #endif
  30.  
  31. #if !defined Ham_CS_Player_ResetMaxSpeed
  32.     #define Ham_CS_Player_ResetMaxSpeed Ham_Item_PreFrame
  33. #endif
  34.  
  35. #define PLUGIN_VERSION "v1.0"
  36.  
  37. // Settings
  38. #define ADMIN_FLAG ADMIN_CHAT
  39.  
  40. const Float:g_fMinGravity = 0.5;
  41. const Float: g_fMaxSpeed = 500.0;
  42.  
  43. // End of settings
  44.  
  45. enum _:dData
  46. {
  47.     dNoclip,
  48.     dGodMode,
  49.     dGravity,
  50.     dSpeed
  51. }
  52.  
  53. new bool:g_bData[MAX_PLAYERS + 1][dData];
  54.  
  55. // Power Names
  56. new const g_szData[dData][16] = { "Noclip", "GodMode", "Gravity", "Speed" };
  57.  
  58. // Weapons Max Speed data
  59. new const Float:g_iWeaponsMaxSpeed[CSW_LAST_WEAPON + 1] =
  60. {
  61.     250.0// No weapon
  62.     250.0// P228
  63.     250.0// Glock
  64.     260.0// Scout
  65.     250.0// HeGrenade
  66.     240.0// XM1014
  67.     250.0// C4
  68.     250.0// Mac 10
  69.     240.0// Aug
  70.     250.0// SmokeGreandae
  71.     250.0// Elite
  72.     250.0// FiveSeven
  73.     250.0// UMP 45
  74.     210.0// SG 550
  75.     240.0// Galil
  76.     240.0// Famas
  77.     250.0// USP
  78.     250.0,  // Glock 18
  79.     210.0// AWP
  80.     250.0// MP5
  81.     220.0// M249
  82.     230.0// M3
  83.     230.0// M4A1
  84.     250.0// TMP
  85.     210.0// G3SG1
  86.     250.0// FlashBang
  87.     250.0// Deagle
  88.     235.0// SG552
  89.     221.0// AK47
  90.     250.0// Knife
  91.     245.0   // P90
  92. };
  93.  
  94. public plugin_init() {
  95.     register_plugin("Power Menu",PLUGIN_VERSION,"Hyuna");
  96.  
  97.     register_saycmd("power","cmdPower",ADMIN_CHAT);
  98.  
  99.     RegisterHam(Ham_CS_Player_ResetMaxSpeed,"player","fw_HamResetMaxSpeedPre",0);
  100.     RegisterHam(Ham_Spawn,"player","fw_HamPlayerSpawnPost",1);
  101.  
  102.     set_cvar_float("sv_maxspeed",g_fMaxSpeed);
  103. }
  104.  
  105. public fw_HamResetMaxSpeedPre(client) {
  106.     if (g_bData[client][dSpeed])   
  107.         return HAM_SUPERCEDE;
  108.  
  109.     return HAM_IGNORED;
  110. }
  111.  
  112. public fw_HamPlayerSpawnPost(client) {
  113.     static i;
  114.  
  115.     for (i = 0; i < dData; i++)
  116.         g_bData[client][i] = false;
  117. }
  118.  
  119. public cmdPower(client, level, cid) {
  120.     if (!cmd_access(client,level,cid,2))
  121.     {
  122.         client_print(client,print_chat,"[AMXX] You don't have access to this command!");
  123.         return PLUGIN_HANDLED;
  124.     }
  125.  
  126.     if (!is_user_alive(client))
  127.     {
  128.         client_print(client,print_chat,"[AMXX] You must be alive to use this menu!");
  129.         return PLUGIN_HANDLED;
  130.     }
  131.  
  132.     return CreateMenu(client);
  133. }
  134.  
  135. CreateMenu(client) {
  136.     static some[256], iMenu;
  137.    
  138.     iMenu = menu_create("\d[\yAMXX\d] \wAdmin Power Menu","mHandler");
  139.  
  140.     formatex(some,charsmax(some),"\yNoclip - \d[ \r%s \d]",(g_bData[client][dNoclip] ? "ON":"OFF"));
  141.     menu_additem(iMenu,some);
  142.  
  143.     formatex(some,charsmax(some),"\yGodMode - \d[ \r%s \d]",(g_bData[client][dGodMode] ? "ON":"OFF"));
  144.     menu_additem(iMenu,some);
  145.  
  146.     formatex(some,charsmax(some),"\yGravity - \d[ \r%s \d]",(g_bData[client][dGravity] ? "ON":"OFF"));
  147.     menu_additem(iMenu,some);
  148.  
  149.     formatex(some,charsmax(some),"\ySpeed - \d[ \r%s \d]",(g_bData[client][dSpeed] ? "ON":"OFF"));
  150.     menu_additem(iMenu,some);
  151.  
  152.     menu_display(client,iMenu);
  153.  
  154.     return 1;
  155. }
  156.  
  157. public mHandler(client, menu, item) {
  158.     if (item == MENU_EXIT || !is_user_alive(client))
  159.     {
  160.         menu_destroy(menu);
  161.         return PLUGIN_HANDLED;
  162.     }
  163.  
  164.     g_bData[client][item] = !g_bData[client][item];
  165.  
  166.     switch(item)
  167.     {
  168.         case 0: set_user_noclip(client,g_bData[client][dNoclip]);
  169.         case 1: set_user_godmode(client,g_bData[client][dGodMode]);
  170.         case 2: set_user_gravity(client,(g_bData[client][dGravity] ? g_fMinGravity:1.0));
  171.         case 3: set_user_maxspeed(client,(g_bData[client][dSpeed] ? g_fMaxSpeed:g_iWeaponsMaxSpeed[get_user_weapon(client)]));
  172.     }
  173.  
  174.     client_print(client,print_chat,"[AMXX] You have %sabled %s.",(g_bData[client][item] ? "en":"dis"),g_szData[item])
  175.  
  176.     menu_destroy(menu);
  177.  
  178.     return CreateMenu(client);
  179. }
  180.  
  181. stock register_saycmd(const cmd[], const function[], access) {
  182.     static const cmdsay[][] = { "say", "say_team" };
  183.     static const marks[] = { '!', '/', '.' };
  184.     static some[64], i, j;
  185.  
  186.     for (i = 0; i < 2; i++)
  187.     {
  188.         for (j = 0; j < 3; j++)
  189.         {
  190.             formatex(some,charsmax(some),"%s %c%s",cmdsay[i],marks[j],cmd,access);
  191.             register_clcmd(some,function);
  192.         }
  193.     }
  194. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement