Last active
November 11, 2023 03:47
-
-
Save kingcc/f773492716c2dff46805a69402615a57 to your computer and use it in GitHub Desktop.
This CS1.6 amxx plugin switches a player’s weapon hand via double-click on move buttons quickly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <amxmodx> | |
#include <cstrike> | |
#include <engine> | |
#include <fakemeta> | |
#define PLUGIN "Change Hand" | |
#define AUTHOR "kingcc" | |
#define VERSION "1.0" | |
#define CVAR_CHANGE_HAND_TOGGLE_INTERVAL "change_hand_toggle_interval" | |
#define is_player(%1) (1 <= %1 <= max_players) | |
new max_players | |
new last_player_frames[64] | |
public plugin_init() { | |
register_plugin(PLUGIN, VERSION, AUTHOR) | |
register_cvar(CVAR_CHANGE_HAND_TOGGLE_INTERVAL, "24") | |
max_players = get_maxplayers() | |
for (new id = 0; id < max_players; id++) { | |
last_player_frames[id] = 0 | |
} | |
} | |
public client_PreThink(id) { | |
if (!is_player(id)) return | |
if (!is_user_connected(id)) return | |
if (!is_user_alive(id)) return | |
new old_buttons = pev(id, pev_oldbuttons) | |
new buttons = pev(id, pev_button) | |
new status = get_cvar_num("cl_righthand") | |
if (status == 1) { | |
if (!(old_buttons & IN_MOVERIGHT) && | |
!(old_buttons & IN_MOVELEFT) && | |
buttons & IN_MOVERIGHT && | |
!(buttons & IN_MOVELEFT)) { | |
if (last_player_frames[id] < get_cvar_num(CVAR_CHANGE_HAND_TOGGLE_INTERVAL)) { | |
client_cmd(id, "cl_righthand 0") | |
} else { | |
last_player_frames[id] = 0 | |
} | |
} | |
} else { | |
if (!(old_buttons & IN_MOVELEFT) && | |
!(old_buttons & IN_MOVERIGHT) && | |
buttons & IN_MOVELEFT && | |
!(buttons & IN_MOVERIGHT)) { | |
if (last_player_frames[id] < get_cvar_num(CVAR_CHANGE_HAND_TOGGLE_INTERVAL)) { | |
client_cmd(id, "cl_righthand 1") | |
} else { | |
last_player_frames[id] = 0 | |
} | |
} | |
} | |
if (last_player_frames[id] < 255) { | |
last_player_frames[id]++ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment