Agregar comando/cvar para ac/desc plugin
#1
Hola, buenass! Espero que esten bien. alguien me ayuda para agregar un cvar que al ingresar por ejemplo: En consola "amx_cvar dm_enabler 1" active y con 0 desactive el plugin ?

ES UN DEATHMATCH

Ya agregue el:
Código PHP:
new p_Enabler 

tambien en el plugin init

Código PHP:
p_Enabler register_cvar("dm_enabler","1"); 

pero donde agrego esto? :

Código PHP:
if(get_pcvar_num(p_Enabler)) 

Intente seguir el tutorial este y no entiendo. Gracias

Código PHP:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <hamsandwich>
#include <fakemeta>

new const P_INFO[ ][ ] = { "DeathMatch""beta""kkkk" };

#define TASK_RESPAWN 1487
#define TASK_PROTECTION 1587

#define ID_RESPAWN ( taskid - TASK_RESPAWN )
#define ID_PROT ( taskid - TASK_PROTECTION )

new kWpn33 ], kLastItem33 ][ ];
new 
dm_timetorespawndm_grenadesdm_protectiontime;

/* Cvar Enable-Disable plugin*/

new p_Enabler


enum _
:WPNDATA
{
    
WPN_NAME30 ],
    
WPN_ENT20 ],
    
WPN_CSW
}

new const 
PrimaryWpns[ ][ WPNDATA ] = 
{
    { 
"Mp5 Navy""weapon_mp5navy"CSW_MP5NAVY },
    { 
"Galil""weapon_galil"CSW_GALIL },
    { 
"Famas""weapon_famas"CSW_FAMAS },
    { 
"M4A1""weapon_m4a1"CSW_M4A1 },
    { 
"Ak47""weapon_ak47"CSW_AK47},
    { 
"BullPop (AUG)""weapon_aug"CSW_AUG },
    { 
"AWP Magnum""weapon_awp"CSW_AWP },
    { 
"M249""weapon_m249"CSW_M249 }
};

new const 
SecondaryWpns[ ][ WPNDATA ] =
{
    { 
"Glock""weapon_glock18"CSW_GLOCK18 },
    { 
"USP""weapon_usp"CSW_USP },
    { 
"Deagle""weapon_deagle"CSW_DEAGLE }
};

new const 
objective_ents[ ][ ] = { "func_bomb_target""info_bomb_target""hostage_entity""monster_scientist",
                
"func_hostage_rescue""info_hostage_rescue""info_vip_start",
                
"func_vip_safetyzone""func_escapezone" };

public 
plugin_precache() register_forwardFM_Spawn"fm_SpawnObj" );

public 
plugin_init() 
{
    
register_pluginP_INFO], P_INFO], P_INFO] );
    
    
RegisterHamHam_Spawn"player""ham_PlayerSpawnPost"true );
    
RegisterHamHam_Killed"player""ham_PlayerKilledPost"true );
    
    
register_clcmd"say /guns""cmdWpns" );
    
    
register_event"TeamInfo""WhenJoinTeam""a")
    
register_messageget_user_msgid("StatusIcon"), "message_statusicon" );
    
    
p_Enabler register_cvar("dm_enabler","1");
    
    
dm_timetorespawn register_cvar"dm_ttr""5.0" );
    
dm_grenades register_cvar"dm_grenades""1" );
    
dm_protectiontime register_cvar"dm_pt""3.0" );
}

public 
client_putinserverindex )
{
    {
    
kLastItemindex ] = { 0}
    
kWpnindex ] = 0;}

}

public 
client_disconnectindex 
{
    
remove_taskindex TASK_RESPAWN );
    
remove_taskindex TASK_PROTECTION );
}

public 
WhenJoinTeam()
{    
    {
    new 
index read_data(1);
    
    if( !
is_user_connectedindex )) return;
    
    
set_taskget_pcvar_float(dm_timetorespawn), "Respawn"index TASK_RESPAWN );
    }
}

public 
message_statusicon(msg_idmsg_destid)
{
    static 
szIcon[8]; get_msg_arg_string(2szIconcharsmax(szIcon));
 
    if (
equal(szIcon"buyzone") && get_msg_arg_int(1))
    {
        
set_pdata_int(id235get_pdata_int(id235) & ~(1<<0));
        return 
PLUGIN_HANDLED;
    }
 
    return 
PLUGIN_CONTINUE;


public 
ham_PlayerSpawnPostindex )
{
    if( !
is_user_aliveindex )) return;
    
    
kWpnindex ] = 0;
    
    
strip_user_weaponsindex )
    
give_itemindex"weapon_knife" );
    
cmdWpnsindex );
    
    
set_user_godmodeindex);
    
set_user_renderingindexkRenderFxGlowShell02550kRenderNormal10 );
    
set_taskget_pcvar_float(dm_protectiontime), "RemoveGM"index TASK_PROTECTION );
}

public 
ham_PlayerKilledPostvictimattackershouldgibs )
{
    if( !
is_user_connectedattacker )) return;
    
    
set_taskget_pcvar_float(dm_timetorespawn), "Respawn"victim TASK_RESPAWN );
}

public 
fm_SpawnObj(ent)
{
    if (!
pev_valid(ent)) return FMRES_IGNORED;

    static 
classname[32], ipev(entpev_classnameclassnamesizeof classname 1);
    
    for (
0sizeof objective_ents; ++i
    {
        if (
equal(classnameobjective_ents[i])) 
        {
            
engfunc(EngFunc_RemoveEntityent);
            return 
FMRES_SUPERCEDE;
        }
    }

    return 
FMRES_IGNORED;
}

public 
Respawntaskid )
{
    if( 
is_user_aliveID_RESPAWN ) ) return;
    
    
ExecuteHamBHam_CS_RoundRespawnID_RESPAWN );
}

public 
RemoveGMtaskid )
{
    if( !
is_user_aliveID_PROT )) return;
    
    
set_user_godmodeID_PROT);
    
set_user_renderingID_PROT );
}

public 
cmdWpnsindex )
{
    static 
menumenu menu_create"\y[ \dDeathMatch \y] \wArmamento^n^t^t^t^t\d""menu_cmd" );
    
    
menu_additemmenu"Elegir armas""1" );
    
menu_additemmenu, (kLastItemindex ][ ] && kLastItemindex ][ ])?"Repetir":"\dElegir Anterior""2" );
    
    
menu_displayindexmenu );
    return 
PLUGIN_HANDLED;
}

public 
menu_cmdindexmenuitem )
{
    switch( 
item )
    {
        case 
0ShowWeaponMenuindex );
        case 
1
        {
            if( 
kLastItemindex ][ ] && kLastItemindex ][ ] )
            {
                
Rebuyindex )
                return 
PLUGIN_HANDLED;
            }
            
            
cmdWpnsindex );
        }
        
        case 
MENU_EXIT: { menu_destroymenu ); return PLUGIN_HANDLED; }
    }
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;
}

ShowWeaponMenuindex )
{
    static 
menui;
    
    if( 
kWpnindex ] == 0)
    {
        
menu menu_create"\y[ \dDeathMatch \y] \wPrimirias^n^t^t^t^t\d ""menu_weapon" );
        
        for( 
sizeof PrimaryWpns ; ++)
            
menu_additemmenuPrimaryWpns][ WPN_NAME ], "" );
    }
    else if( 
kWpnindex ] == )
    {
        
menu menu_create"\y[ \dDeathMatch \y] \wSecundarias^n^t^t^t^t\d""menu_weapon" );
        
        for( 
sizeof SecondaryWpns ; ++)
            
menu_additemmenuSecondaryWpns][ WPN_NAME ], "" );
    }
    
    
menu_displayindexmenu );
}

public 
menu_weaponindexmenuitem )
{
    if( 
item == MENU_EXIT)
    {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }
    
    if( 
kWpnindex ] == )
    {
        
give_itemindexPrimaryWpnsitem ][ WPN_ENT ] );
        
cs_set_user_bpammoindexPrimaryWpnsitem ][ WPN_CSW ], 999 );
        
        
kLastItemindex ][ ] = item;
        
kWpnindex ] = 1;
        
        
ShowWeaponMenuindex );
    }
    else if (
kWpnindex ] == )
    {
        
give_itemindexSecondaryWpnsitem ][ WPN_ENT ] );
        
cs_set_user_bpammoindexSecondaryWpnsitem ][ WPN_CSW ], 999 );
        
        
kLastItemindex ][ ] = item;
        
kWpnindex ] = 2;
        
        if( 
get_pcvar_num(dm_grenades))
        {
            
give_itemindex"weapon_hegrenade" );
            
give_itemindex"weapon_flashbang" );
            
cs_set_user_bpammoindexCSW_HEGRENADE);
            
cs_set_user_bpammoindexCSW_FLASHBANG);
        }
    }
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;
}

Rebuyindex )
{
    if( !
is_user_aliveindex )) return;
    
    
give_itemindexPrimaryWpnskLastItemindex ][0] ][ WPN_ENT ] );
    
give_itemindexSecondaryWpnskLastItemindex ][1] ][ WPN_ENT ] );
    
cs_set_user_bpammoindexSecondaryWpnskLastItemindex ][1] ][ WPN_CSW ], 999 );
    
cs_set_user_bpammoindexPrimaryWpnskLastItemindex ][0] ][ WPN_CSW ], 999 );
    
    if( 
get_pcvar_num(dm_grenades))
    {
        
give_itemindex"weapon_hegrenade" );
        
give_itemindex"weapon_flashbang" );
        
cs_set_user_bpammoindexCSW_HEGRENADE);
        
cs_set_user_bpammoindexCSW_FLASHBANG);
    }
    
    
kWpnindex ] = 2;

(12/03/2014, 08:11 PM)roccoxx escribió: jajajajajajajajajajajajajajajaajajajajajaajajajajajajajajajajajajajajajajajajajajajajajajajjajajjajajajajaja

todo eso elevado a la quinta potencia.
Responder
#2
Código PHP:
new const P_INFO[ ][ ] = { "DeathMatch""beta""kkkk" }; 

brahhhhhh
Responder
#3
(24/03/2020, 05:10 AM)Chema escribió:
Código PHP:
new const P_INFO[ ][ ] = { "DeathMatch""beta""kkkk" }; 

brahhhhhh

??? Cual es el problema? Yo descargue el sma y quiero agregarle la opcion para activar y desactivar el plugin desde consola nada mas.
(12/03/2014, 08:11 PM)roccoxx escribió: jajajajajajajajajajajajajajajaajajajajajaajajajajajajajajajajajajajajajajajajajajajajajajajjajajjajajajajaja

todo eso elevado a la quinta potencia.
Responder
#4
El tutorial se refiere a que lo coloques al principio de cada forward o funcion
Cualquiera de las dos formas que salen ahí deberían funcionar
Código PHP:
public client_putinserverindex )
{
    if(!
get_pcvar_num(p_Enabler)) return FMRES_IGNORED
    kLastItem
index ] = { 0}
    
kWpnindex ] = 0;}

o la que ibas a usar tu
Código PHP:
{
    if(
get_pcvar_num(p_Enabler))
    {
        
kLastItemindex ] = { 0}
        
kWpnindex ] = 0;}
    {

Whatdone
Estoy cansado de este sufrimiento llamado vivir en Venezuela
Okay
Responder
#5
(24/03/2020, 11:59 PM)samueldmq escribió: El tutorial se refiere a que lo coloques al principio de cada forward o funcion
Cualquiera de las dos formas que salen ahí deberían funcionar
Código PHP:
public client_putinserverindex )
{
    if(!
get_pcvar_num(p_Enabler)) return FMRES_IGNORED
    kLastItem
index ] = { 0}
    
kWpnindex ] = 0;}

o la que ibas a usar tu
Código PHP:
{
    if(
get_pcvar_num(p_Enabler))
    {
        
kLastItemindex ] = { 0}
        
kWpnindex ] = 0;}
    {

Whatdone


Como estas Samuel? Gracias por la ayuda. Cn la tan sencilla explicación que me diste:
Cita:El tutorial se refiere a que lo coloques al principio de cada forward o funcion
entendí todo y pude colocar todo bien, y me habilita y deshabilita correctamente el plugin. Lo único que quizás queda cuando esta deshabilitado, es el glow verde protection que queda por 3 segundos. te animas a ayudarme?

Lo puse de esta manera:

Código PHP:
public ham_PlayerSpawnPostindex )
{
    if(
get_pcvar_num(p_Enabler))
        {
        if( !
is_user_aliveindex )) return;
        
kWpnindex ] = 0;
        
strip_user_weaponsindex )
        
give_itemindex"weapon_knife" );
        
cmdWpnsindex );
        
        
set_user_godmodeindex);
        
set_user_renderingindexkRenderFxGlowShell02550kRenderNormal10 );
        
set_taskget_pcvar_float(dm_protectiontime), "RemoveGM"index TASK_PROTECTION );
        }


Y lo ultimo, por ejemplo: somos 2 tt y 2ct.. Cualquiera de los tt mata a los 2ct juntos, en teoria termina la ronda y dice "Terrorist win" , como hago para que siga la ronda? Porque se empieza de cero. Gracias
(12/03/2014, 08:11 PM)roccoxx escribió: jajajajajajajajajajajajajajajaajajajajajaajajajajajajajajajajajajajajajajajajajajajajajajajjajajjajajajajaja

todo eso elevado a la quinta potencia.
Responder
#6
(26/03/2020, 01:45 AM)acetatomil escribió: entendí todo y pude colocar todo bien, y me habilita y deshabilita correctamente el plugin. Lo único que quizás queda cuando esta deshabilitado, es el glow verde protection que queda por 3 segundos. te animas a ayudarme?

Lo puse de esta manera:

Código PHP:
public ham_PlayerSpawnPostindex )
{
    if(
get_pcvar_num(p_Enabler))
        {
        if( !
is_user_aliveindex )) return;
        
kWpnindex ] = 0;
        
strip_user_weaponsindex )
        
give_itemindex"weapon_knife" );
        
cmdWpnsindex );
        
        
set_user_godmodeindex);
        
set_user_renderingindexkRenderFxGlowShell02550kRenderNormal10 );
        
set_taskget_pcvar_float(dm_protectiontime), "RemoveGM"index TASK_PROTECTION );
        }

Pues no debería Insecure
no se como ayudarte con esto Whatdone

(26/03/2020, 01:45 AM)acetatomil escribió: Y lo ultimo, por ejemplo: somos 2 tt y 2ct.. Cualquiera de los tt mata a los 2ct juntos, en teoria termina la ronda y dice "Terrorist win" , como hago para que siga la ronda? Porque se empieza de cero. Gracias

Prueba este plugin
Estoy cansado de este sufrimiento llamado vivir en Venezuela
Okay
Responder
#7
(26/03/2020, 01:45 AM)acetatomil escribió: Y lo ultimo, por ejemplo: somos 2 tt y 2ct.. Cualquiera de los tt mata a los 2ct juntos, en teoria termina la ronda y dice "Terrorist win" , como hago para que siga la ronda? Porque se empieza de cero. Gracias

Prueba este plugin
[/quote]

Justo descargue el de Arkshine y funciona perfecto! Gracias por todo Victory
(12/03/2014, 08:11 PM)roccoxx escribió: jajajajajajajajajajajajajajajaajajajajajaajajajajajajajajajajajajajajajajajajajajajajajajajjajajjajajajajaja

todo eso elevado a la quinta potencia.
Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)