Advertisement
Guest User

adsad

a guest
Oct 15th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <colorchat>
  5.  
  6. #define SETTING_SHOWKYES "SHOWKYES"
  7.  
  8. new g_iPlayerKeys[33];
  9. new Float:fShowKeyTime = 0.0;
  10. new g_showkeys;
  11. new g_SyncShowKeys;
  12. new g_iMaxPlayers;
  13. new bool:g_bShowKeys[33];
  14.  
  15. public plugin_init()
  16. {
  17. register_plugin("Showkeys", "1.1", "vato loco & medusa");
  18.  
  19. register_clcmd("say /showkeys", "ClientShowKeys");
  20. register_clcmd("say_team /showkeys", "ClientShowKeys");
  21. register_clcmd("say /sk", "ClientShowKeys");
  22. register_clcmd("say_team /sk", "ClientShowKeys");
  23.  
  24. register_forward(FM_StartFrame, "fw_StartFrame");
  25. g_showkeys = register_cvar("hns_showkeys","1");
  26. g_SyncShowKeys = CreateHudSyncObj();
  27. g_iMaxPlayers = get_maxplayers();
  28. }
  29.  
  30. public ClientShowKeys(id)
  31. {
  32. g_bShowKeys[id] = g_bShowKeys[id] ? false : true;
  33.  
  34. ColorChat(id, RED, "^1[^4HNS^1] ShowKeys in spectators has been %s", g_bShowKeys[id] ? "^4enable" : "^3disable");
  35.  
  36. return PLUGIN_HANDLED;
  37. }
  38.  
  39. public change_setting_value (id, const setting[], const value[])
  40. {
  41. if (!strcmp (setting, SETTING_SHOWKYES))
  42. g_bShowKeys[id] = bool:str_to_num (value);
  43. }
  44.  
  45. public fw_StartFrame()
  46. {
  47. if(!get_pcvar_num(g_showkeys))
  48. return FMRES_IGNORED;
  49.  
  50. static Float:fGameTime, Float:fDelay;
  51. fGameTime = get_gametime();
  52. fDelay = 0.06;
  53.  
  54. if((fShowKeyTime + fDelay) <= fGameTime)
  55. {
  56. show_keyinfo();
  57. fShowKeyTime = fGameTime;
  58. }
  59. static id;
  60. for(id = 1; id <= g_iMaxPlayers; id++)
  61. {
  62. if(is_user_alive(id))
  63. {
  64. new Button = pev(id, pev_button)
  65. if(Button & IN_FORWARD)
  66. g_iPlayerKeys[id] |= IN_FORWARD;
  67. if(Button & IN_BACK)
  68. g_iPlayerKeys[id] |= IN_BACK;
  69. if(Button & IN_MOVELEFT)
  70. g_iPlayerKeys[id] |= IN_MOVELEFT;
  71. if(Button & IN_MOVERIGHT)
  72. g_iPlayerKeys[id] |= IN_MOVERIGHT;
  73. if(Button & IN_DUCK)
  74. g_iPlayerKeys[id] |= IN_DUCK;
  75. if(Button & IN_JUMP )
  76. g_iPlayerKeys[id] |= IN_JUMP;
  77. }
  78. }
  79. return FMRES_IGNORED;
  80. }
  81.  
  82. stock show_keyinfo()
  83. {
  84. static id;
  85. for(id = 1; id <= g_iMaxPlayers; id++)
  86. {
  87. if(!is_user_alive(id) && g_bShowKeys[id])
  88. {
  89. new specmode = pev(id, pev_iuser1);
  90. if(specmode == 2 || specmode == 4)
  91. {
  92. new target = pev(id, pev_iuser2);
  93.  
  94. if(target != id)
  95. {
  96. if(!is_user_alive(target))
  97. g_iPlayerKeys[target] = 0;
  98.  
  99. static plr_key[64];
  100.  
  101. set_hudmessage(0, 64, 39, -1.0, 0.54, 0, 0.0, 0.04, 0.08, 0.16, -1);
  102. formatex(plr_key, 63, "%s^n%s %s^n%s^n%s %s",
  103. g_iPlayerKeys[target] & IN_FORWARD ? "W" : " ",
  104. g_iPlayerKeys[target] & IN_MOVELEFT ? "A" : " ",
  105. g_iPlayerKeys[target] & IN_MOVERIGHT ? "D" : " ",
  106. g_iPlayerKeys[target] & IN_BACK ? "S" : " ",
  107. g_iPlayerKeys[target] & IN_JUMP ? "JUMP" : "␠ ",
  108. g_iPlayerKeys[target] & IN_DUCK ? "DUCK" : " ␠");
  109. ShowSyncHudMsg(id, g_SyncShowKeys, "%s", plr_key);
  110. }
  111. }
  112. }
  113. if(id == g_iMaxPlayers)
  114. {
  115. arrayset(g_iPlayerKeys, 0, 32);
  116. }
  117. }
  118. return PLUGIN_CONTINUE;
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement