04/11/2020, 10:15 AM
(Última modificación: 04/11/2020, 10:15 AM por masacre15. Edited 1 time in total.)
buenos dias gente me ayudan a optimizar el plugins que me ayudaron a crear de menu de arma ya que en " /cstrike/addons/amxmodx/logs/" tiene mas errores el plugins de menu de arma que otros se lo agredeceria muchos
Código PHP:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <fun>
new const g_gzPluginName[] = "Armas (MRA)";
new const g_szPluginVers[] = "v1.0";
new const g_szPluginAuth[] = "Hector y ayuda";
enum _:DATA_WP
{
WP_NAME[32],
WP_ENT[21],
WP_ID,
WP_MODEL_V[96],
WP_MODEL_P[96],
WP_FRAGS
};
new const g_szWeapons[][DATA_WP] =
{
{ "Ak47 - PRIDE", "weapon_ak47", CSW_AK47, "models/marihuana/v_ak47-37.mdl", "models/marihuana/p_ak47-37.mdl", 0 },
{ "Ak47 - DRAGONS", "weapon_ak47", CSW_AK47, "models/marihuana/v_ak47-36.mdl", "models/marihuana/p_ak47-36.mdl", 0 },
{ "Ak47 - BLOODSPORT", "weapon_ak47", CSW_AK47, "models/marihuana/v_ak47-35.mdl", "models/marihuana/p_ak47-35.mdl", 0 },
{ "M4a1 - MUSICA", "weapon_m4a1", CSW_M4A1, "models/marihuana/v_m4a1-50.mdl", "models/marihuana/p_m4a1-50.mdl", 0 },
{ "M4a1 - POSEIDON", "weapon_m4a1", CSW_M4A1, "models/marihuana/v_m4a1-53.mdl", "models/marihuana/p_m4a1-53.mdl", 0 },
{ "M4a1 - HOWL", "weapon_m4a1", CSW_M4A1, "models/marihuana/v_m4a1-52.mdl", "models/marihuana/p_m4a1-52.mdl", 0 },
{ "AWP - JACKAL", "weapon_awp", CSW_AWP, "models/marihuana/v_awp-75.mdl", "models/marihuana/p_awp-75.mdl", 0 },
{ "AWP - DRAGON LORE", "weapon_awp", CSW_AWP, "models/marihuana/v_awp-76.mdl", "models/marihuana/p_awp-76.mdl", 0 },
{ "AWP - HYPER BEST", "weapon_awp", CSW_AWP, "models/marihuana/v_awp-77.mdl", "models/marihuana/p_awp-77.mdl", 0 }
};
new g_iArmaSelect[33];
new g_iFrags[33]
public plugin_init()
{
register_plugin(g_gzPluginName, g_szPluginVers, g_szPluginAuth);
static i;
for (i = 0; i < sizeof(g_szWeapons); i++)
RegisterHam(Ham_Item_Deploy, g_szWeapons[i][WP_ENT], "Ham_Weapons_Deploy_Post", true);
RegisterHam(Ham_TakeDamage, "player", "Ham_PlayerTakeDamage");
RegisterHam(Ham_Killed, "player", "ham_PlayerKilled", true);
//RegisterHam(Ham_Spawn, "weaponbox", "ham_SpawnWeaponbox", true);
register_forward(FM_SetModel, "fw_SetModel", 1)
register_menu( "Normal Menu", 1023, "handled_normal_menu" );
register_clcmd("radio1", "Clcmd_AbrirMenu");
}
public plugin_precache( ) {
for( new i = 0; i < sizeof g_szWeapons; i++ ){
if (equal(g_szWeapons[i][WP_MODEL_V], "default") || equal(g_szWeapons[i][WP_MODEL_P], "default"))
return;
precache_model( g_szWeapons[ i ][ WP_MODEL_V ] )
precache_model( g_szWeapons[ i ][ WP_MODEL_P ] )
}
}
public client_putinserver(id)
{
g_iFrags[id] = 0;
g_iArmaSelect[id] = -1;
}
public Ham_PlayerTakeDamage(iVictim, iWeapon, iAttacker, Float:damage, iDamage_Bits)
{
if (iVictim == iAttacker || !is_user_alive(iAttacker) || !is_user_connected(iAttacker) || g_iArmaSelect[iAttacker] <= -1 )
return HAM_IGNORED;
new Float:newdamage
newdamage = damage + random_float(10.0, 25.0)
SetHamParamFloat(4, get_user_weapon(iAttacker) == CSW_AWP ? damage * 2.0 : newdamage)
return HAM_HANDLED;
}
public Ham_Weapons_Deploy_Post(WeaponEntity)
{
static wOwner;
wOwner = get_pdata_cbase(WeaponEntity, 41, 4);
/** Offset 41 pertenece al Owner del arma **/
if(!pev_valid(wOwner) || !is_user_alive(wOwner))
return;
static iWeaponID;
iWeaponID = cs_get_weapon_id(WeaponEntity);
if (g_iArmaSelect[wOwner] == -1)
return;
if (iWeaponID == g_szWeapons[g_iArmaSelect[wOwner]][WP_ID])
{
if (!equal(g_szWeapons[g_iArmaSelect[wOwner]][WP_MODEL_V] , "default"))
entity_set_string(wOwner, EV_SZ_viewmodel, g_szWeapons[g_iArmaSelect[wOwner]][WP_MODEL_V]);
if (!equal(g_szWeapons[g_iArmaSelect[wOwner]][WP_MODEL_P] , "default"))
entity_set_string(wOwner, EV_SZ_weaponmodel, g_szWeapons[g_iArmaSelect[wOwner]][WP_MODEL_P]);
}
}
public ham_PlayerKilled(victim, inflictor, attacker, shouldgibs)
{
if(!(0 < attacker <= get_maxplayers()) || !is_user_connected(attacker) || attacker == victim)
return HAM_IGNORED;
g_iFrags[attacker]++;
return HAM_IGNORED;
}
public fw_SetModel(entity, model[])
{
if( !pev_valid(entity) )
return FMRES_IGNORED
static Classname[64]; pev(entity, pev_classname, Classname, sizeof(Classname))
if( !equal(Classname, "weaponbox") )
return FMRES_IGNORED
static id; id = pev(entity, pev_owner)
//if(is_user_connected(id))
// return FMRES_IGNORED
if(is_user_admin(id))
{
if(contain(model, "_awp") != -1)
engfunc(EngFunc_RemoveEntity, entity)
if(contain(model, "_ak47") != -1)
engfunc(EngFunc_RemoveEntity, entity)
if(contain(model, "_m4a1") != -1)
engfunc(EngFunc_RemoveEntity, entity)
}
else
return FMRES_IGNORED
return FMRES_IGNORED;
}
/*
public ham_SpawnWeaponbox(entity)
{
new owner = entity_get_edict(entity, EV_ENT_owner);
if (g_iArmaSelect[owner] == -1)
return HAM_IGNORED;
if (get_user_weapon(owner) == g_szWeapons[g_iArmaSelect[owner]][WP_ID])
{
g_iArmaSelect[owner] = -1;
set_pev(entity, pev_flags, FL_KILLME);
dllfunc(DLLFunc_Think, entity);
return HAM_IGNORED;
}
return HAM_IGNORED;
}
*/
public Clcmd_AbrirMenu(id)
{
if (~get_user_flags(id) & ADMIN_RESERVATION)
{
show_normal_menu(id);
return PLUGIN_HANDLED;
}
static iMenu, szText[64];
iMenu = menu_create("Menu de Armas \r[MRA\r]", "HandlerMenu_Armas");
static i;
for (i = 0; i < sizeof(g_szWeapons); i++)
{
/** Adaptalo **/
if (g_iFrags[id] >= g_szWeapons[i][WP_FRAGS])
formatex(szText, charsmax(szText), "\w%s", g_szWeapons[i][WP_NAME]);
else
formatex(szText, charsmax(szText), "\d%s \r(\y%d\d GRATIS\r)", g_szWeapons[i][WP_NAME], g_szWeapons[i][WP_FRAGS]);
menu_additem(iMenu, szText, _, _, menu_makecallback("CallBackMenu_Armas"));
}
menu_additem(iMenu, "Salir")
menu_setprop(iMenu, MPROP_PERPAGE, 0);
menu_display(id, iMenu);
return PLUGIN_HANDLED;
}
public CallBackMenu_Armas(id, iMenu, iItem)
{
if (g_iFrags[id] >= g_szWeapons[iItem][WP_FRAGS])
return ITEM_ENABLED;
return ITEM_DISABLED;
}
public HandlerMenu_Armas(id, iMenu, iItem)
{
if (iItem == MENU_EXIT)
return PLUGIN_HANDLED;
//Strip_User_Primaries(id, iItem);
drop_weapons(id, 1)
g_iArmaSelect[id] = iItem;
give_item(id, g_szWeapons[iItem][WP_ENT]);
cs_set_user_bpammo(id, g_szWeapons[iItem][WP_ID], 90)
chat_color(id, "!g[MRA] !yConseguiste una !g%s!", g_szWeapons[iItem][WP_NAME], g_szWeapons[iItem][WP_FRAGS], g_szWeapons[iItem][WP_FRAGS] > 1 ? "s" : "");
return PLUGIN_HANDLED
}
show_normal_menu(id)
{
static szbuffer[ 1024 ], len, keys;
len = 0;
len += formatex(szbuffer[len], charsmax(szbuffer) - len, "\yMenú de venta^n^n");
len += formatex(szbuffer[len], charsmax(szbuffer) - len, "\wMenu de \yARMA." );
len += formatex(szbuffer[len], charsmax(szbuffer) - len, "\wContacto:\y Hector Guillem" );
len += formatex(szbuffer[len], charsmax(szbuffer) - len, "\r0. \wCerrar" );
keys = (1<<9);
show_menu(id, keys, szbuffer, -1, "Normal Menu" );
return PLUGIN_HANDLED;
}
public handled_normal_menu(id, key)
{
if (key != 9)
client_cmd(id, "spk ^"Ui/buttonclickrelease.wav^"");
return PLUGIN_HANDLED;
}
/*
Strip_User_Primaries(id, item)
{
new iWeapon, iNext, iActiveItem
new
iWeapon = get_pdata_cbase(id, item)
iActiveItem = get_pdata_cbase(id, m_pActiveItem)
while( pev_valid(iWeapon) )
{
iNext = get_pdata_cbase(iWeapon, m_pNext, 4)
if( iActiveItem == iWeapon )
{
ExecuteHam(Ham_Item_Holster, iWeapon)
}
set_pev(iWeapon, pev_flags, pev(iWeapon, pev_flags) | FL_KILLME)
iWeapon = iNext
}
} */
// Weapon bitsums
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)
// Drop primary/secondary weapons
stock drop_weapons(id, dropwhat)
{
// Get user weapons
static weapons[32], num, i, weaponid
num = 0 // reset passed weapons count (bugfix)
get_user_weapons(id, weapons, num)
// Loop through them and drop primaries or secondaries
for (i = 0; i < num; i++)
{
// Prevent re-indexing the array
weaponid = weapons[i]
if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) /*|| (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM))*/ )
{
// Get weapon entity
static wname[32]
get_weaponname(weaponid, wname, charsmax(wname))
engclient_cmd(id, "drop", wname)
cs_set_user_bpammo(id, weaponid, 0)
}
}
}
chat_color(id, const input[], any:...)
{
static message[191];
vformat(message, 190, input, 3);
replace_all(message, 190, "!g", "^4");
replace_all(message, 190, "!t", "^3");
replace_all(message, 190, "!y", "^1");
message_begin((id) ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, get_user_msgid("SayText"), .player = id);
write_byte((id) ? id : 33);
write_string(message);
message_end();
}
![[Imagen: b_560_95_1.png]](https://cache.gametracker.com/server_info/74.91.121.121:27020/b_560_95_1.png)