AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [DONE]Blocking a function with cvar (https://forums.alliedmods.net/showthread.php?t=207933)

Unkolix 02-08-2013 12:04

[DONE]Blocking a function with cvar
 
Hey! Could someone tell me how to block a function with cvar?
I have this code, that blocks players from getting grenades in certain maps and I want to block that if
PHP Code:

g_map_active register_cvar("map_active""1"

is set to 0.
I believe it should be something with this:
PHP Code:

if (!get_pcvar_num(map_active))
        return 
PLUGIN_CONTINUE 

But I can't figure it out were to put it.
PHP Code:

public fwHamPlayerSpawnPost(id
{
    
VIPMenuUsed=0;
    
get_mapnameszMap charsmaxszMap ) );
    for( new 
sizeofmapnames ) ; i++ )
    {
        if ( 
containiszMap mapnames] ) !=-)
            return;
    }
    if(
is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_H)
    {
        
give_item(id"weapon_hegrenade");
        
give_item(id"weapon_flashbang");
        
give_item(id"weapon_flashbang");
        
give_item(id"weapon_smokegrenade");
        
give_item(id"item_assaultsuit");
        
give_item(id"item_thighpack");
    }



naven 02-08-2013 12:22

Re: Blocking a function with cvar
 
Quote:

how to block a cvar with another cvar?
I don't see where is this another cvar.

If you meant to check a cvar for giving grenades, do it here:
Code:

if(is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_H && get_pcvar_num(map_active))

Unkolix 02-08-2013 12:40

Re: Blocking a function with cvar
 
EDITED!!!!

Got it working with vip menu, but still it doesn't give grenades on that map if g_map_active is 0... I did the same as this:
PHP Code:

public Showrod(id)
{
    
get_mapnameszMap charsmaxszMap ) );
    
map_active get_pcvar_num (g_map_active)
    if (
map_active == 1)
    {
        for( new 
sizeofmapnames ) ; i++ )
        {
            if ( 
containiszMap mapnames] ) !=-)
                return;
        }
    }
    new 
menu menu_create("\rVIP meniu:""Pressedrod");
    
    
menu_additem(menu"\yM4A1 su Deagle""1"0);
    
menu_additem(menu"\yAK47 su Deagle""2"0);
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);


And this: But this doesn't work...
PHP Code:

public fwHamPlayerSpawnPost(id
{
    
VIPMenuUsed=0;
    
get_mapnameszMap charsmaxszMap ) );
    
map_active get_pcvar_num (g_map_active)
    if (
map_active == 1)
    {
        for( new 
sizeofmapnames ) ; i++ )
        {
            if ( 
containiszMap mapnames] ) !=-)
                return;
        }
    }
    if(
is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_H)
    {
        
give_item(id"weapon_hegrenade");
        
give_item(id"weapon_flashbang");
        
give_item(id"weapon_flashbang");
        
give_item(id"weapon_smokegrenade");
        
give_item(id"item_assaultsuit");
        if(
g_bHasBombSite && cs_get_user_team(id) == CS_TEAM_CT)
        {
            
cs_set_user_defuse(id1);
        }
    }



naven 02-09-2013 11:36

Re: Blocking a function with cvar
 
Really, I do not understand you at all now.

Unkolix 02-09-2013 11:45

Re: Blocking a function with cvar
 
Nevermind. I got it working.


All times are GMT -4. The time now is 20:34.

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