PHP Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Auto Hand switch"
#define VERSION "1.0"
#define AUTHOR "Khalid"
/*#define TASKID1 2000
#define TASKID2 2032*/
new Agreed[33] = 0
new gKeys = (MENU_KEY_0|MENU_KEY_1|MENU_KEY_2)
//new right_hand = 1
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("TeamInfo", "eTeam_Join", "b")
register_menucmd(register_menuid("This server requires to change weapon view model to right/left hand each round end!^nDo you agree?"), gKeys, "menu_handler")
register_logevent("eRoundEnd", 2, "1=Round_End")
register_event("HLTV", "eNewRound", "ae", "1=0", "2=0")
}
public eTeam_Join(id)
{
set_task(15.0, "show_menu_to_user", id)
}
public show_menu_to_user(id) // So it won't be slow hacking ...
{
new menu[256]
formatex(menu, charsmax(menu), "This server requires to change weapon view model to right/left hand each round end!^nDo you agree?^n1. Yes, I agree^n 2. No, I don't agree \r[You will be kicked]")
show_menu(id, gKeys, menu, 15)
set_task(15.0, "kick_user", id) // Kick him if he didn't choose
return PLUGIN_CONTINUE
}
public kick_user(id)
{
//new id = TASK - TASKID1
if(Agreed[id] == 1)
return PLUGIN_HANDLED
server_cmd("kick #%d ^"You must agree to continue playing here!^"", get_user_userid(id))
return PLUGIN_HANDLED
}
public client_disconnect(id)
{
Agreed[id] = 0
if(task_exists(id))
remove_task(id)
/*if(task_exists(id + TASKID2))
remove_task(id + TASKID2)*/
}
public menu_handler(id, key)
{
if(key == 0)
{
Agreed[id] = 1
client_print(id, print_chat, "You have agreed!")
//set_task(5.0, "client_cvar", TASKID2 + id,_,_, "b")
}
else if(key == 1)
server_cmd("kick #%d ^"You must agree to continue playing here!^"", get_user_userid(id))
}
public eNewRound()
{
new players[32], count, player
get_players(players, count)
for(new i; i < count; i++)
{
player = players[i]
client_cmd(player, "cl_righthand 1")
}
}
public eRoundEnd()
{
new players[32], count, player
get_players(players, count)
/*for(new i; i < count; i++)
{
player = players[i]
if(right_hand == 1)
{
if(Agreed[player] == 1)
client_cmd(player, "cl_righthand 1")
right_hand = 0
}
else if(right_hand == 0)
{
if(Agreed[player] == 1)
client_cmd(player, "cl_righthand 0")
right_hand = 0
}
}*/
for(new i; i< count; i++)
{
player = players[i]
client_cmd(player, "cl_righthand 0")
}
}
/*public client_cvar(TASK2)
{
new id = TASK2 - TASKID2
query_client_cvar(id, "cl_righthand", "client_cvar2")
}
public client_cvar2(id, cvar[], value[])
{
new numvalue = str_to_num(value)
if( right_hand != numvalue )
client_cmd(id, "cl_righthand %d", numvalue)
return PLUGIN_HANDLED
}*/