23/03/2020, 11:14 PM
(Última modificación: 23/03/2020, 11:16 PM por acetatomil. Edited 2 times in total.)
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:
tambien en el plugin init
pero donde agrego esto? :
Intente seguir el tutorial este y no entiendo. Gracias
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 kWpn[ 33 ], kLastItem[ 33 ][ 2 ];
new dm_timetorespawn, dm_grenades, dm_protectiontime;
/* Cvar Enable-Disable plugin*/
new p_Enabler
enum _:WPNDATA
{
WPN_NAME[ 30 ],
WPN_ENT[ 20 ],
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_forward( FM_Spawn, "fm_SpawnObj" );
public plugin_init()
{
register_plugin( P_INFO[ 0 ], P_INFO[ 1 ], P_INFO[ 2 ] );
RegisterHam( Ham_Spawn, "player", "ham_PlayerSpawnPost", true );
RegisterHam( Ham_Killed, "player", "ham_PlayerKilledPost", true );
register_clcmd( "say /guns", "cmdWpns" );
register_event( "TeamInfo", "WhenJoinTeam", "a")
register_message( get_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_putinserver( index )
{
{
kLastItem[ index ] = { 0, 0 }
kWpn[ index ] = 0;}
}
public client_disconnect( index )
{
remove_task( index + TASK_RESPAWN );
remove_task( index + TASK_PROTECTION );
}
public WhenJoinTeam()
{
{
new index = read_data(1);
if( !is_user_connected( index )) return;
set_task( get_pcvar_float(dm_timetorespawn), "Respawn", index + TASK_RESPAWN );
}
}
public message_statusicon(msg_id, msg_dest, id)
{
static szIcon[8]; get_msg_arg_string(2, szIcon, charsmax(szIcon));
if (equal(szIcon, "buyzone") && get_msg_arg_int(1))
{
set_pdata_int(id, 235, get_pdata_int(id, 235) & ~(1<<0));
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public ham_PlayerSpawnPost( index )
{
if( !is_user_alive( index )) return;
kWpn[ index ] = 0;
strip_user_weapons( index )
give_item( index, "weapon_knife" );
cmdWpns( index );
set_user_godmode( index, 1 );
set_user_rendering( index, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 10 );
set_task( get_pcvar_float(dm_protectiontime), "RemoveGM", index + TASK_PROTECTION );
}
public ham_PlayerKilledPost( victim, attacker, shouldgibs )
{
if( !is_user_connected( attacker )) return;
set_task( get_pcvar_float(dm_timetorespawn), "Respawn", victim + TASK_RESPAWN );
}
public fm_SpawnObj(ent)
{
if (!pev_valid(ent)) return FMRES_IGNORED;
static classname[32], i; pev(ent, pev_classname, classname, sizeof classname - 1);
for (i = 0; i < sizeof objective_ents; ++i)
{
if (equal(classname, objective_ents[i]))
{
engfunc(EngFunc_RemoveEntity, ent);
return FMRES_SUPERCEDE;
}
}
return FMRES_IGNORED;
}
public Respawn( taskid )
{
if( is_user_alive( ID_RESPAWN ) ) return;
ExecuteHamB( Ham_CS_RoundRespawn, ID_RESPAWN );
}
public RemoveGM( taskid )
{
if( !is_user_alive( ID_PROT )) return;
set_user_godmode( ID_PROT, 0 );
set_user_rendering( ID_PROT );
}
public cmdWpns( index )
{
static menu; menu = menu_create( "\y[ \dDeathMatch \y] \wArmamento^n^t^t^t^t\d", "menu_cmd" );
menu_additem( menu, "Elegir armas", "1" );
menu_additem( menu, (kLastItem[ index ][ 0 ] && kLastItem[ index ][ 1 ])?"Repetir":"\dElegir Anterior", "2" );
menu_display( index, menu );
return PLUGIN_HANDLED;
}
public menu_cmd( index, menu, item )
{
switch( item )
{
case 0: ShowWeaponMenu( index );
case 1:
{
if( kLastItem[ index ][ 0 ] && kLastItem[ index ][ 1 ] )
{
Rebuy( index )
return PLUGIN_HANDLED;
}
cmdWpns( index );
}
case MENU_EXIT: { menu_destroy( menu ); return PLUGIN_HANDLED; }
}
menu_destroy( menu );
return PLUGIN_HANDLED;
}
ShowWeaponMenu( index )
{
static menu, i;
if( kWpn[ index ] == 0)
{
menu = menu_create( "\y[ \dDeathMatch \y] \wPrimirias^n^t^t^t^t\d ", "menu_weapon" );
for( i = 0 ; i < sizeof PrimaryWpns ; ++i )
menu_additem( menu, PrimaryWpns[ i ][ WPN_NAME ], "" );
}
else if( kWpn[ index ] == 1 )
{
menu = menu_create( "\y[ \dDeathMatch \y] \wSecundarias^n^t^t^t^t\d", "menu_weapon" );
for( i = 0 ; i < sizeof SecondaryWpns ; ++i )
menu_additem( menu, SecondaryWpns[ i ][ WPN_NAME ], "" );
}
menu_display( index, menu );
}
public menu_weapon( index, menu, item )
{
if( item == MENU_EXIT)
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
if( kWpn[ index ] == 0 )
{
give_item( index, PrimaryWpns[ item ][ WPN_ENT ] );
cs_set_user_bpammo( index, PrimaryWpns[ item ][ WPN_CSW ], 999 );
kLastItem[ index ][ 0 ] = item;
kWpn[ index ] = 1;
ShowWeaponMenu( index );
}
else if (kWpn[ index ] == 1 )
{
give_item( index, SecondaryWpns[ item ][ WPN_ENT ] );
cs_set_user_bpammo( index, SecondaryWpns[ item ][ WPN_CSW ], 999 );
kLastItem[ index ][ 1 ] = item;
kWpn[ index ] = 2;
if( get_pcvar_num(dm_grenades))
{
give_item( index, "weapon_hegrenade" );
give_item( index, "weapon_flashbang" );
cs_set_user_bpammo( index, CSW_HEGRENADE, 3 );
cs_set_user_bpammo( index, CSW_FLASHBANG, 3 );
}
}
menu_destroy( menu );
return PLUGIN_HANDLED;
}
Rebuy( index )
{
if( !is_user_alive( index )) return;
give_item( index, PrimaryWpns[ kLastItem[ index ][0] ][ WPN_ENT ] );
give_item( index, SecondaryWpns[ kLastItem[ index ][1] ][ WPN_ENT ] );
cs_set_user_bpammo( index, SecondaryWpns[ kLastItem[ index ][1] ][ WPN_CSW ], 999 );
cs_set_user_bpammo( index, PrimaryWpns[ kLastItem[ index ][0] ][ WPN_CSW ], 999 );
if( get_pcvar_num(dm_grenades))
{
give_item( index, "weapon_hegrenade" );
give_item( index, "weapon_flashbang" );
cs_set_user_bpammo( index, CSW_HEGRENADE, 3 );
cs_set_user_bpammo( index, CSW_FLASHBANG, 3 );
}
kWpn[ index ] = 2;
}