Advertisement
Guest User

Untitled

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