Raised This Month: $51 Target: $400
 12% 

Help / Support [HELP ZP 4.3] Block suicide


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MarLeo94
Junior Member
Join Date: Jul 2013
Location: Reino de Europa.
Old 03-09-2015 , 13:00   [HELP ZP 4.3] Block suicide
Reply With Quote #1

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) == && cs_get_user_team(id) == CS_TEAM_T) {
        
client_print(idprint_chat"[ZP] Los zombies no pueden suicidarse.");
        
client_print(idprint_console"[ZP] Los zombies no pueden suicidarse.");
        
        return 
FMRES_SUPERCEDE;
    }
    else if(
get_pcvar_num(cvar_blocksuicide) == && cs_get_user_team(id) == CS_TEAM_CT) {
        
client_print(idprint_chat"[ZP] Los humanos no pueden suicidarse.");
        
client_print(idprint_console"[ZP] Los humanos no pueden suicidarse.");
        
        return 
FMRES_SUPERCEDE;
    }
    else if(
get_pcvar_num(cvar_blocksuicide) == 3) {
        
client_print(idprint_chat"[ZP] No puedes suicidarte.");
        
client_print(idprint_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) == || (userflags g_access_flag[ACCESS_ADMIN_MENU])) {
        if((
get_pcvar_num(cvar_blocksuicide) == && cs_get_user_team(id) == CS_TEAM_CT
        || (
get_pcvar_num(cvar_blocksuicide) == && 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_ClientKillid)
            }
code...

__________________

MarLeo94 is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 03-09-2015 , 17:06   Re: [HELP ZP 4.3] Block suicide
Reply With Quote #2

Why is your code in 3 different blocks? You should be using switch, as it is more efficient than if/else.

Are you registering forward for FM_ClientKill? The above code doesn't show that.
Spirit_12 is offline
MarLeo94
Junior Member
Join Date: Jul 2013
Location: Reino de Europa.
Old 03-09-2015 , 17:59   Re: [HELP ZP 4.3] Block suicide
Reply With Quote #3

Quote:
Originally Posted by Spirit_12 View Post
Why is your code in 3 different blocks? You should be using switch, as it is more efficient than if/else.

Are you registering forward for FM_ClientKill? The above code doesn't show that.
I put it because I want to do through a cvar that could kill myself just zombies, only humans or none (default only this comes the ZP).

And yes, I've checked the forward.
__________________

MarLeo94 is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 03-10-2015 , 07:04   Re: [HELP ZP 4.3] Block suicide
Reply With Quote #4

You need to provide the full code of the plugin.

Also, I would suggest using a switch for the cvar value.
Spirit_12 is offline
MarLeo94
Junior Member
Join Date: Jul 2013
Location: Reino de Europa.
Old 03-10-2015 , 09:18   Re: [HELP ZP 4.3] Block suicide
Reply With Quote #5

Quote:
Originally Posted by Spirit_12 View Post
You need to provide the full code of the plugin.

Also, I would suggest using a switch for the cvar value.
That's the entire code, no more... And about creating another cvar... I just want cvar if set to 1 the zombies can not commit suicide but humans if and which may also be passed to the viewer.
__________________

MarLeo94 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:09.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode