Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. #pragma semicolon 1
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5. #include <hamsandwich>
  6. #include <fakemeta>
  7. #include <ns>
  8. #include <nvault>
  9.  
  10. #define PLUGIN "_cl_autowepswitch"
  11. #define VERSION "0.1"
  12. #define AUTHOR "Asmodee`"
  13.  
  14. #define VAULTNAME "autowepswitch"
  15.  
  16. new bool:g_bAutoPickup[33];
  17. new g_Vault = 0;
  18.  
  19. public plugin_init()
  20. {
  21. register_plugin(PLUGIN, VERSION, AUTHOR);
  22. if (ns_is_combat()) {
  23. pause("ad");
  24. }
  25.  
  26. RegisterHam(Ham_Touch, "weapon_shotgun", "hamTouchGun");
  27. RegisterHam(Ham_Touch, "weapon_heavymachinegun", "hamTouchGun");
  28. RegisterHam(Ham_Touch, "weapon_grenadegun", "hamTouchGun");
  29.  
  30. register_clcmd("evlv_autowepswitch", "clcmd_autowepswitch", _, "Turns off auto weapon switching (Default 1)");
  31.  
  32. g_Vault = nvault_open(VAULTNAME);
  33. }
  34.  
  35. public plugin_end()
  36. {
  37. nvault_close(g_Vault);
  38. }
  39.  
  40. public client_authorized(id)
  41. {
  42. QueryCustomCvar(id);
  43. }
  44.  
  45. public clcmd_autowepswitch(id)
  46. {
  47. if (read_argc() == 1) {
  48. new cmd[32];
  49. read_argv(0, cmd, 31);
  50. client_print(id, print_console, "^"%s^" is ^"%d^"", cmd, g_bAutoPickup[id]);
  51. return PLUGIN_HANDLED;
  52. }
  53. new svalue[2];
  54. read_argv(1, svalue, 1);
  55. new value = str_to_num(svalue);
  56.  
  57. new authid[36];
  58. get_user_authid(id, authid, 36);
  59.  
  60. if ((value == 0) && (g_bAutoPickup[id] == true)) {
  61. g_bAutoPickup[id] = false;
  62. nvault_set(g_Vault, authid, "0");
  63. client_print(id, print_console, "Turned auto weapon switch OFF");
  64. } else if ((value == 1) && (g_bAutoPickup[id] == false)) {
  65. g_bAutoPickup[id] = true;
  66. nvault_set(g_Vault, authid, "1");
  67. client_print(id, print_console, "Turned auto weapon switch ON");
  68. } else {
  69. client_print(id, print_console, "Wow you're retarded. Try 0 or 1.");
  70. }
  71. return PLUGIN_HANDLED;
  72. }
  73.  
  74. public hamTouchGun(this, idother)
  75. {
  76. client_print(0, print_chat, "idother = %d", idother);
  77. if (g_bAutoPickup[idother]) {
  78. return HAM_IGNORED;
  79. }
  80. if (pev(idother, pev_team) == 1) {
  81. if (ns_has_weapon(idother, WEAPON_LMG)) {
  82. return HAM_SUPERCEDE;
  83. }
  84. }
  85. return HAM_IGNORED;
  86. }
  87.  
  88. QueryCustomCvar(id)
  89. {
  90. new authid[36];
  91. get_user_authid(id, authid, 36);
  92.  
  93. new svalue[2];
  94. new xtamp;
  95. if (nvault_lookup(g_Vault, authid, svalue, 2, xtamp) == 0) {
  96. g_bAutoPickup[id] = true;
  97. return;
  98. }
  99. new value = str_to_num(svalue);
  100. switch(value) {
  101. case 0:
  102. g_bAutoPickup[id] = false;
  103. case 1:
  104. g_bAutoPickup[id] = true;
  105. default:
  106. log_to_file("autowepswitch.log", "%s %s %d", authid, svalue, value);
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement