#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <regex>
#define MAX_PLAYERS 32
#define MAXINPUT 7
#define SANITARY "abcdefg"
new bool:g_restart_attempt[MAX_PLAYERS + 1]
new amx_show_activity
//new hitbox_allow_knife
//new hitbox_allow_he
new hitbox_bit
public plugin_init(){
register_plugin("Hitbox Manipulator", "1.00", "Migs Davis")
register_event("ResetHUD", "event_hud_reset", "be")
register_event("TextMsg", "event_restart_attempt", "a", "2=#Game_will_restart_in")
register_clcmd("fullupdate", "clcmd_fullupdate")
register_concmd("amx_hitbox", "admin_set_hitbox", ADMIN_KICK, "<0|a|b|c|d|e|f|g> - Set hitboxes. Letters equal the body part, can combine letters.")
//hitbox_allow_knife = register_cvar("hitbox_allow_knife", "1")
//hitbox_allow_he = register_cvar("hitbox_allow_he", "1")
hitbox_bit = register_cvar("hitbox_bit", "255")
amx_show_activity = get_cvar_pointer("amx_show_activity")
}
public clcmd_fullupdate() {
return PLUGIN_HANDLED
}
public event_restart_attempt(){
new players[32], num
get_players(players, num, "a")
for ( new i; i < num; ++i )
g_restart_attempt[players[i]] = true
}
public event_hud_reset(id){
if (g_restart_attempt[id]) {
g_restart_attempt[id] = false
return
}
set_properties(id)
}
public set_properties(id){
set_user_hitzones(0, 0, get_pcvar_num(hitbox_bit))
}
public admin_set_hitbox(id, level, cid){
new flags[MAXINPUT+1], name[32], error[128], result_code, bit = 1
if ( !cmd_access(id, level, cid, 2) )
return PLUGIN_HANDLED
read_argv(1, flags, MAXINPUT)
strtolower(flags)
new Regex:re = regex_match(flags, "0", result_code, error, 127)
if (re >= REGEX_OK) { //This if/else will detect strange syntax, even if it doesn't need to
regex_free(re)
if (flags[0] == '0') {
if (flags[1] == '^0'){
bit = 0;
} else {
bit = 0; //they have a 0 followed by unnecessary characters
}
} else{
bit = 1 // there is a 0 mixed in with other characters
}
} else {
new buf[2] = {0,0}
for (new i = 0; i<MAXINPUT; i++){
buf[0] = flags[i];
re = regex_match(SANITARY, buf[0], result_code, error, 127)
if (re >= REGEX_OK){
regex_free(re)
} else {
flags[i] = 0 //They have weird characters in here
}
}
}
if (bit) {
new buf2[2] = {97,0} //97 = a.
for (new j = 2; j <= 128; j*=2, buf2[0]++){
re = regex_match(flags, buf2, result_code, error, 127)
if (re >= REGEX_OK){
regex_free(re)
bit += j
}
}
}
if (bit == 1){
//They didn't type any valid flags at all
}
set_pcvar_num(hitbox_bit, bit)
get_user_name(id, name, 31)
switch ( get_pcvar_num(amx_show_activity) ){
case 2: client_print(0, print_chat, "[AMXX] ADMIN %s has manipulated the hitboxes!", name)
case 1: client_print(0, print_chat, "[AMXX] ADMIN has manipulated the hitboxes!")
}
set_properties(0)
log_amx("[AMXX] ADMIN %s: set hitboxes to %d", name, bit)
return PLUGIN_HANDLED
}