15/05/2021, 02:47 PM
Hola buenas tardes, necesito ayuda para modificar los siguientes aspectos de este plugin:
1) Quiero que el menú de armas se vea así
El menú que quiero que sea modificado separa las armas en dos categorías, primaria y secundaria. Sin embargo, quiero que las separe en estas 3 o 4 como en la foto y que, al momento de elegir un arma principal, me lleve al menú de armas de las pistolas o menú secundario según el plugin.
2) Necesito que las armas tengan las municiones por default del cs 1.6, desconozco como arreglar eso y el problema es que cada arma elegida tiene 999 balas.
Muchas gracias de antemano.
CSOMX_DefaultWpns.sma
WpnMenus.sma
csomx_wpn_api.inc
1) Quiero que el menú de armas se vea así
El menú que quiero que sea modificado separa las armas en dos categorías, primaria y secundaria. Sin embargo, quiero que las separe en estas 3 o 4 como en la foto y que, al momento de elegir un arma principal, me lleve al menú de armas de las pistolas o menú secundario según el plugin.
2) Necesito que las armas tengan las municiones por default del cs 1.6, desconozco como arreglar eso y el problema es que cada arma elegida tiene 999 balas.
Muchas gracias de antemano.
CSOMX_DefaultWpns.sma
Código:
#include <amxmodx>
#include <fun>
#include <cstrike>
#include <csomx_wpn_api>
enum _:WPNDATA { NOMBRE[ 30 ], TIPO, COSTO, WPNENT[ 25 ], CSWWPN, ISADMIN }
new const Defaults[][WPNDATA] =
{
{ "Leone 12 Gauge Super", WPN_ESCOPETAS, 700, "weapon_m3", CSW_M3, ADMIN_ALL },
{ "Leone YG1265 Auto Shotgun", WPN_ESCOPETAS, 600, "weapon_xm1014", CSW_XM1014, ADMIN_ALL },
{ "Schmidt Machine Pistol", WPN_AMETRALLADORAS, 700, "weapon_tmp", CSW_TMP, ADMIN_ALL },
{ "Ingram Mac-10", WPN_AMETRALLADORAS, 700, "weapon_mac10", CSW_MAC10, ADMIN_ALL },
{ "KM Sub-Machine Gun", WPN_AMETRALLADORAS, 700, "weapon_mp5navy", CSW_MP5NAVY, ADMIN_ALL },
{ "ES C90", WPN_AMETRALLADORAS, 700, "weapon_p90", CSW_P90, ADMIN_ALL },
{ "KM UMP45", WPN_AMETRALLADORAS, 700, "weapon_ump45", CSW_UMP45, ADMIN_ALL },
{ "Clarion 5.56", WPN_RIFLES, 800, "weapon_famas", CSW_FAMAS, ADMIN_ALL },
{ "IDF Defender", WPN_RIFLES, 900, "weapon_galil", CSW_GALIL, ADMIN_ALL },
{ "Schmidt Scout", WPN_RIFLES, 900, "weapon_scout", CSW_SCOUT, ADMIN_ALL },
{ "Magnum Sniper Rifle", WPN_RIFLES, 900, "weapon_awp", CSW_AWP, ADMIN_ALL },
{ "9x19MM Sidearm", WPN_PISTOLS, 100, "weapon_glock18", CSW_GLOCK18, ADMIN_ALL },
{ "KM .45 Tactical", WPN_PISTOLS, 100, "weapon_usp", CSW_USP, ADMIN_ALL },
{ "228 Compact", WPN_PISTOLS, 100, "weapon_p228", CSW_P228, ADMIN_ALL },
{ "Night Hawk .50C", WPN_PISTOLS, 100, "weapon_deagle", CSW_DEAGLE, ADMIN_ALL },
{ "Five-Seven", WPN_PISTOLS, 120, "weapon_fiveseven", CSW_FIVESEVEN, ADMIN_ALL },
{ ".40 Dual Elites", WPN_PISTOLS, 400, "weapon_elite", CSW_ELITE, ADMIN_ALL }
}
new kItem[ sizeof Defaults];
public plugin_init()
{
register_plugin( "[CSOMX] DefaultWpns", "1.0", "kikizon & FloresMagon" );
static i;
for( i = 0; i < sizeof Defaults; ++i )
kItem[ i ] = csomx_register_weapon( Defaults[ i ][ NOMBRE ], Defaults[ i ][ TIPO ], Defaults[ i ][ COSTO ], Defaults[ i ][ ISADMIN ] );
}
public csomx_wpn_selected( index, wpnid )
{
static i;
for( i = 0; i < sizeof Defaults;++i)
{
if( kItem[i] == wpnid )
{
give_item( index, Defaults[i][WPNENT] );
if( Defaults[i][CSWWPN] == CSW_HEGRENADE || Defaults[i][CSWWPN] == CSW_FLASHBANG )
{
continue;
}
cs_set_user_bpammo( index, Defaults[i][CSWWPN], 999 );
}
}
}
WpnMenus.sma
Código:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>
#include <dhudmessage>
#include <amxmisc>
#define MAXWEAPONS 60
new const Commands[][] =
{
"usp", "glock", "deagle", "p228", "elites",
"fn57", "m3", "xm1014", "mp5", "tmp",
"p90", "mac10", "ump45", "ak47", "galil",
"famas", "sg552", "m4a1", "aug", "scout",
"awp", "g3sg1", "sg550", "m249", "vest",
"vesthelm", "flash", "hegren", "sgren", "defuser",
"nvgs", "shield", "primammo", "secammo", "km45",
"9x19mm", "nighthawk", "228compact", "fiveseven", "12gauge",
"autoshotgun", "mp", "c90", "cv47", "defender",
"clarion", "krieg552", "bullpup", "magnum", "d3au1",
"krieg550", "buy", "cl_autobuy", "cl_rebuy",
"cl_setautobuy", "cl_setrebuy", "client_buy_open"
};
new const BuySound[] = "CSOMX/Normal/BuySound.wav";
new Array:Weapon_Name, Array:Weapon_Type, Array:Weapon_Cost, Array:Weapon_Admin, wpn_counter;
new kFWSelectWpn, kFWShowMenuPre, cvar_inbuyzone;
enum { WPN_RIFLES = 1, WPN_ESCOPETAS, WPN_AMETRALLADORAS, WPN_MACHINE, WPN_PISTOLS, WPN_EQUIPMENT }
enum _:MSGS { BUYCLOSE }
new kMsgs[ MSGS ], kLastItem[ 33 ][ 2 ][ 2 ], kUnLockedWpn[ 33 ][ MAXWEAPONS ];
const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90);
const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE);
/* ============================================================================================== */
public plugin_precache()
{
Weapon_Name = ArrayCreate( 32, 1 );
Weapon_Type = ArrayCreate( 1, 1 );
Weapon_Cost = ArrayCreate( 1, 1 );
Weapon_Admin = ArrayCreate( 1, 1 );
precache_sound( BuySound );
}
public plugin_natives()
{
register_native( "csomx_showmenu", "native_showmenu", 1 );
register_native( "csomx_register_weapon", "native_register_weapon", 1 );
}
public plugin_init()
{
register_plugin( "CSOMX | BUYMENU", "1.4", "FloresMagon & kikizon" );
kFWSelectWpn = CreateMultiForward("csomx_wpn_selected", ET_STOP, FP_CELL, FP_CELL );
kFWShowMenuPre = CreateMultiForward( "csomx_showmenu_pre", ET_STOP, FP_CELL );
RegisterHam( Ham_Spawn, "player", "ham_PlayerSpawnPost", true );
cvar_inbuyzone = register_cvar( "csomx_inbuyzone", "0" );
static c;
for( c = 0 ; c < sizeof Commands ; ++c )
register_clcmd(Commands[ c ], "Block");
register_clcmd( "buyequip", "clmcmdBuyEquip" );
kMsgs[ BUYCLOSE ] = get_user_msgid("BuyClose");
}
public native_register_weapon( const Name[], Type, Cost, Admin )
{
param_convert( 1 );
if ( strlen( Name ) < 1)
{
log_error( AMX_ERR_NATIVE , "[CSOMX] No se puede registrar un arma, sin nombre" )
return -1;
}
static z , Name2[32];
for ( z = 0 ; z < wpn_counter ; ++z )
{
ArrayGetString( Weapon_Name , z , Name2 , charsmax( Name2 ) );
if ( equali( Name , Name2 ) )
{
log_error( AMX_ERR_NATIVE , "[CSOMX] No puede haber 2 armas con el mismo nombre... (%s)" , Name );
return -1;
}
}
ArrayPushString( Weapon_Name, Name );
ArrayPushCell( Weapon_Type, Type );
ArrayPushCell( Weapon_Cost, Cost );
ArrayPushCell( Weapon_Admin, Admin );
++wpn_counter;
return wpn_counter-1;
}
public native_showmenu( index )
{
if( !is_user_alive( index ) )
{
log_error(AMX_ERR_NATIVE, "[ZM] Cliente Muerto (%d)", index);
return;
}
WeaponsMenu( index );
}
public ham_PlayerSpawnPost( index )
{
if( !is_user_alive( index )) return;
set_dhudmessage( 0, 250, 0, 0.30, 0.70, 1 );
show_dhudmessage( index, "Presiona 'B' para abrir el menu de compra" );
}
/* ============================================================================================== */
public Block( index )
{
if( !is_user_alive( index )) return PLUGIN_HANDLED;
if( get_pcvar_num(cvar_inbuyzone) == 1 && !cs_get_user_buyzone(index) ) return PLUGIN_HANDLED;
message_begin(MSG_ONE, kMsgs[ BUYCLOSE ], _, index );
message_end();
WeaponsMenu( index );
return PLUGIN_HANDLED;
}
public client_putinserver( index )
{
kLastItem[ index ][ 0 ][ 0 ] = kLastItem[ index ][ 0 ][ 1 ] = -1;
kLastItem[ index ][ 1 ][ 0 ] = kLastItem[ index ][ 1 ][ 1 ] = -1;
for( new i = 0 ; i < MAXWEAPONS ; ++i )
kUnLockedWpn[ index ][ i ] = false;
}
public clmcmdBuyEquip( index )
{
if( !is_user_alive( index )) return PLUGIN_HANDLED;
if( get_pcvar_num(cvar_inbuyzone) == 1 && !cs_get_user_buyzone(index) ) return PLUGIN_HANDLED;
message_begin(MSG_ONE, kMsgs[ BUYCLOSE ], _, index );
message_end();
ShowWeapons( index, WPN_EQUIPMENT );
return PLUGIN_HANDLED;
}
/* ============================================================================================== */
WeaponsMenu( index )
{
static Result
ExecuteForward(kFWShowMenuPre, Result, index );
if (Result == PLUGIN_HANDLED)
return PLUGIN_HANDLED;
static menu; menu = menu_create( "\yZombie Mod Infection Weapon Menu:", "menu_weapon" );
menu_additem( menu, "Primary", "1" );
menu_additem( menu, "Secondary", "2" );
menu_display( index, menu );
return PLUGIN_HANDLED;
}
public menu_weapon( index, menu, item )
{
if( get_pcvar_num(cvar_inbuyzone) == 1 && !cs_get_user_buyzone(index) ) return PLUGIN_HANDLED;
switch( item )
{
case 0: ShowPrimaryWeapon( index );
case 1: ShowWeapons( index, WPN_PISTOLS );
case 2: ShowWeapons( index, WPN_EQUIPMENT );
case 3:
{
if( kLastItem[index][0][0]>=0 || kLastItem[index][1][0]>=0)
Rebuy( index );
}
case MENU_EXIT: { menu_destroy( menu ); return PLUGIN_HANDLED; }
}
menu_destroy( menu );
return PLUGIN_HANDLED;
}
/* ============================================================================================== */
ShowPrimaryWeapon( index )
{
static menu; menu = menu_create( "\yZombie Mod Infection Weapon Menu \r[Primary]\y:", "menu_pri" );
menu_additem( menu, "Rifles", "1" );
menu_additem( menu, "Shotguns", "2" );
menu_additem( menu, "SMGs", "3" );
menu_display( index, menu );
}
public menu_pri( index, menu, item )
{
if( get_pcvar_num(cvar_inbuyzone) == 1 && !cs_get_user_buyzone(index) ) return PLUGIN_HANDLED;
switch( item )
{
case 0: ShowWeapons( index, WPN_RIFLES );
case 1: ShowWeapons( index, WPN_ESCOPETAS );
case 2: ShowWeapons( index, WPN_AMETRALLADORAS );
case MENU_EXIT: { menu_destroy( menu ); return PLUGIN_HANDLED; }
}
menu_destroy( menu );
return PLUGIN_HANDLED;
}
/* ============================================================================================== */
ShowWeapons( index , wpn )
{
static w, menu, weapon_name[64], cost, admin, item[128], flags, money, pos[4]; money = cs_get_user_money( index );
formatex( weapon_name, charsmax(weapon_name), "\yZombie Mod Infection Weapon Menu \r%s", wpn==WPN_RIFLES?"[Rifles]\y:":wpn==WPN_ESCOPETAS?"[Shotguns]\y:":wpn==WPN_AMETRALLADORAS?"[SMGs]\y:":wpn==WPN_MACHINE?"[Machine Guns]\y:":wpn==WPN_PISTOLS?"[Pistols]\y:":"Equipamiento" );
menu = menu_create( weapon_name, "menu_wpns");
flags = get_user_flags( index );
for(w = 0; w < wpn_counter; ++w)
{
if( GetWpnType( w ) != wpn ) continue;
ArrayGetString(Weapon_Name, w, weapon_name, charsmax(weapon_name));
cost = ArrayGetCell(Weapon_Cost, w);
admin = ArrayGetCell( Weapon_Admin, w );
if( admin == ADMIN_ALL )
{
if( kUnLockedWpn[ index ][ w ] || is_user_admin( index ) )
formatex( item, charsmax( item ), "\w%s", weapon_name );
else
formatex( item, charsmax( item ), "\%s %s \r[ $%d ]", money < cost ? "d":"w", weapon_name, cost );
}
else
{
if( flags & admin )
formatex( item, charsmax( item ), "\w%s", weapon_name );
else
formatex( item, charsmax( item ), "\d%s \r( ADMIN %s )", weapon_name, admin == ADMIN_LEVEL_G ? "VIP":"PREMIUM" );
}
num_to_str( w, pos, 3 );
menu_additem( menu, item, pos );
}
menu_display( index, menu );
}
public menu_wpns( index, menu, item )
{
if( item == MENU_EXIT || !is_user_alive( index ) || !cs_get_user_buyzone(index) )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
static cost, w, money, flags, admin, type;
static data[6], szName[64], acces, callback;
menu_item_getinfo(menu, item, acces, data,charsmax(data), szName,charsmax(szName), callback);
w = str_to_num( data );
cost = ArrayGetCell( Weapon_Cost, w );
admin = ArrayGetCell( Weapon_Admin, w );
type = GetWpnType(w);
money = cs_get_user_money( index );
flags = get_user_flags( index );
if( admin != ADMIN_ALL )
{
if( !(flags & admin) )
{
client_print( index, print_center, "*** Esta arma es para ADMIN %s ***", admin == ADMIN_LEVEL_G ? "VIP":"PREMIUM" );
menu_destroy( menu );
return PLUGIN_HANDLED;
}
}
else
{
if( !is_user_admin( index ) && money < cost)
{
client_print( index, print_center, "*** NO TIENES SUFICIENTE DINERO ***");
menu_destroy( menu );
return PLUGIN_HANDLED;
}
}
switch( type )
{
case WPN_RIFLES..WPN_MACHINE:
{
kLastItem[ index ][ 0 ][ 0 ] = w;
kLastItem[ index ][ 0 ][ 1 ] = type;
drop_weapons( index, 1);
}
case WPN_PISTOLS:
{
kLastItem[ index ][ 1 ][ 0 ] = w;
kLastItem[ index ][ 1 ][ 1 ] = type;
drop_weapons( index, 2);
}
}
GetWpn( index, w, type );
BuyEffect( index, money, cost, w );
menu_destroy( menu );
return PLUGIN_HANDLED;
}
/* ============================================================================================== */
public Rebuy( index )
{
if( !is_user_alive( index ) || get_pcvar_num(cvar_inbuyzone) == 1 && !cs_get_user_buyzone( index ) ) return;
if( kLastItem[ index ][ 0 ][ 0 ] >= 0 )
GetWpn( index, kLastItem[ index ][ 0 ][ 0 ], kLastItem[ index ][ 0 ][ 1 ] );
if( kLastItem[ index ][ 1 ][ 0 ] >= 0 )
GetWpn( index, kLastItem[ index ][ 1 ][0], kLastItem[ index ][ 1 ][ 1 ] );
}
/* ============================================================================================== */
stock BuyEffect( index , money , cost, wpn_id )
{
if( !is_user_alive( index )) return;
if( !is_user_admin(index) && !kUnLockedWpn[index][wpn_id])
cs_set_user_money( index, money-cost );
emit_sound( index, CHAN_ITEM, BuySound, 1.0, ATTN_NORM, 0, PITCH_NORM );
kUnLockedWpn[ index ][ wpn_id ] = true;
}
stock GetWpn( index, wpn_id, type )
{
static fw_dummy;
if( !is_user_alive( index )) return;
if( GetWpnType( wpn_id ) != type ) return;
ExecuteForward( kFWSelectWpn, fw_dummy, index, wpn_id);
}
stock GetWpnType(wpn_id)
{
if(wpn_id > wpn_counter) return 0;
return ArrayGetCell( Weapon_Type, wpn_id );
}
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) { /* keep looping */ }
return entity;
}
stock drop_weapons(id, dropwhat)
{
static weapons[32], num, i, weaponid;
num = 0;
get_user_weapons(id, weapons, num);
for (i = 0; i < num; ++i)
{
weaponid = weapons[i];
if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
|| (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
{
static wname[32], weapon_ent;
get_weaponname(weaponid, wname, charsmax(wname));
weapon_ent = fm_find_ent_by_owner(-1, wname, id);
set_pev(weapon_ent, pev_iuser1, cs_get_user_bpammo(id, weaponid));
engclient_cmd(id, "drop", wname);
cs_set_user_bpammo(id, weaponid, 0);
}
}
}
csomx_wpn_api.inc
Código:
#if defined _csomx_wpn_api_included
#endinput
#endif
#define _csomx_wpn_api_included
enum { WPN_RIFLES = 1, WPN_ESCOPETAS, WPN_AMETRALLADORAS, WPN_MACHINE, WPN_PISTOLS, WPN_EQUIPMENT }
native csomx_register_weapon( const Name[], Type, Cost, Admin )
native csomx_showmenu( index )
forward csomx_wpn_selected( index, wpn_id )
forward csomx_showmenu_pre( index )