Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #include <amxmodx>
- #include <amxmisc>
- #include <hamsandwich>
- #include <fakemeta>
- #include <ns>
- #include <nvault>
- #define PLUGIN "_cl_autowepswitch"
- #define VERSION "0.1"
- #define AUTHOR "Asmodee`"
- #define VAULTNAME "autowepswitch"
- new bool:g_bAutoPickup[33];
- new g_Vault = 0;
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR);
- if (ns_is_combat()) {
- pause("ad");
- }
- RegisterHam(Ham_Touch, "weapon_shotgun", "hamTouchGun");
- RegisterHam(Ham_Touch, "weapon_heavymachinegun", "hamTouchGun");
- RegisterHam(Ham_Touch, "weapon_grenadegun", "hamTouchGun");
- register_clcmd("evlv_autowepswitch", "clcmd_autowepswitch", _, "Turns off auto weapon switching (Default 1)");
- g_Vault = nvault_open(VAULTNAME);
- }
- public plugin_end()
- {
- nvault_close(g_Vault);
- }
- public client_authorized(id)
- {
- QueryCustomCvar(id);
- }
- public clcmd_autowepswitch(id)
- {
- if (read_argc() == 1) {
- new cmd[32];
- read_argv(0, cmd, 31);
- client_print(id, print_console, "^"%s^" is ^"%d^"", cmd, g_bAutoPickup[id]);
- return PLUGIN_HANDLED;
- }
- new svalue[2];
- read_argv(1, svalue, 1);
- new value = str_to_num(svalue);
- new authid[36];
- get_user_authid(id, authid, 36);
- if ((value == 0) && (g_bAutoPickup[id] == true)) {
- g_bAutoPickup[id] = false;
- nvault_set(g_Vault, authid, "0");
- client_print(id, print_console, "Turned auto weapon switch OFF");
- } else if ((value == 1) && (g_bAutoPickup[id] == false)) {
- g_bAutoPickup[id] = true;
- nvault_set(g_Vault, authid, "1");
- client_print(id, print_console, "Turned auto weapon switch ON");
- } else {
- client_print(id, print_console, "Wow you're retarded. Try 0 or 1.");
- }
- return PLUGIN_HANDLED;
- }
- public hamTouchGun(this, idother)
- {
- client_print(0, print_chat, "idother = %d", idother);
- if (g_bAutoPickup[idother]) {
- return HAM_IGNORED;
- }
- if (pev(idother, pev_team) == 1) {
- if (ns_has_weapon(idother, WEAPON_LMG)) {
- return HAM_SUPERCEDE;
- }
- }
- return HAM_IGNORED;
- }
- QueryCustomCvar(id)
- {
- new authid[36];
- get_user_authid(id, authid, 36);
- new svalue[2];
- new xtamp;
- if (nvault_lookup(g_Vault, authid, svalue, 2, xtamp) == 0) {
- g_bAutoPickup[id] = true;
- return;
- }
- new value = str_to_num(svalue);
- switch(value) {
- case 0:
- g_bAutoPickup[id] = false;
- case 1:
- g_bAutoPickup[id] = true;
- default:
- log_to_file("autowepswitch.log", "%s %s %d", authid, svalue, value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement