Hello, I have the following code assumes that serves to block suicide, is controlled by a cvar (0 off, 1 zombies can not commit suicide, 2 humans can not commit suicide, 3 no one can commit suicide), the problem is that does not work, what's the problem?
PHP Code:
cvar_blocksuicide = register_cvar("zp_block_suicide", "1") // 0 nobody, 1 zombies, 2 humans, 3 all
PHP Code:
// Client Kill Forward
public fw_ClientKill(id)
{
if(!is_user_alive(id) && !is_user_connected(id)) {
return FMRES_IGNORED;
}
// Prevent players from killing themselves?
if(get_pcvar_num(cvar_blocksuicide) == 1 && cs_get_user_team(id) == CS_TEAM_T) {
client_print(id, print_chat, "[ZP] Los zombies no pueden suicidarse.");
client_print(id, print_console, "[ZP] Los zombies no pueden suicidarse.");
return FMRES_SUPERCEDE;
}
else if(get_pcvar_num(cvar_blocksuicide) == 2 && cs_get_user_team(id) == CS_TEAM_CT) {
client_print(id, print_chat, "[ZP] Los humanos no pueden suicidarse.");
client_print(id, print_console, "[ZP] Los humanos no pueden suicidarse.");
return FMRES_SUPERCEDE;
}
else if(get_pcvar_num(cvar_blocksuicide) == 3) {
client_print(id, print_chat, "[ZP] No puedes suicidarte.");
client_print(id, print_console, "[ZP] No puedes suicidarte.");
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
PHP Code:
// 7. Join spec
if(!g_isalive[id] || get_pcvar_num(cvar_blocksuicide) == 0 || (userflags & g_access_flag[ACCESS_ADMIN_MENU])) {
if((get_pcvar_num(cvar_blocksuicide) == 1 && cs_get_user_team(id) == CS_TEAM_CT)
|| (get_pcvar_num(cvar_blocksuicide) == 2 && cs_get_user_team(id) == CS_TEAM_T)) {
len += formatex(menu[len], charsmax(menu) - len, "\r7.\w %L^n^n", id, "MENU_SPECTATOR")
}
else if(get_pcvar_num(cvar_blocksuicide) == 3) {
len += formatex(menu[len], charsmax(menu) - len, "\d7. %L^n^n", id, "MENU_SPECTATOR")
}
}
else {
len += formatex(menu[len], charsmax(menu) - len, "\d7. %L^n^n", id, "MENU_SPECTATOR")
}
PHP Code:
case 6: // Join Spectator
{
// Player alive?
if(g_isalive[id]) {
// Prevent abuse by non-admins if block suicide setting is enabled
if(get_pcvar_num(cvar_blocksuicide) && !(get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MENU])) {
zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
return PLUGIN_HANDLED;
}
// Check that we still have both humans and zombies to keep the round going
check_round(id)
// Kill him before he switches team
dllfunc(DLLFunc_ClientKill, id)
}
code...
}
__________________