Hi, i tried to put silencer on CurWeapon Event (Ham_Deploy is crashing with podbots)
but cs_find_ent_by_owner is not working??
Not working code: cs_find_ent_by_owner seems to not found a valid ent, while find_ent_by_owner or
fm_find_ent_by_owner (BAD) seems to work.
Note: I am under localhost test (not HLDS), and using podbots
Code:
register_event("CurWeapon","CurWeapon","be","1=1");
public CurWeapon(id)
{
if(g_Enabled)
{
new Weapon = read_data(2);
new CsWeaponClassType:WeaponClass = cs_get_weapon_class(Weapon);
if(CS_WEAPONCLASS_PISTOL <= WeaponClass <= CS_WEAPONCLASS_SNIPERRIFLE)
{
if(WeaponClass != CS_WEAPONCLASS_GRENADE)
{
if(g_Silenced[id][0] && Weapon == CSW_M4A1)
{
new Ent = cs_find_ent_by_owner(-1,"weapon_m4a1",id); // Always returning 0??
if(Ent)
{
if(!cs_get_weapon_silen(Ent))
{
cs_set_weapon_silen(Ent,1);
}
}
}
new Ammo = cs_get_weapon_info(Weapon,CS_WEAPONINFO_MAX_ROUNDS);
if(cs_get_user_bpammo(id,Weapon) < Ammo)
{
cs_set_user_bpammo(id,Weapon,Ammo);
}
}
}
}
}
Working code:
Code:
register_event("CurWeapon","CurWeapon","be","1=1");
public CurWeapon(id)
{
if(g_Enabled)
{
new Weapon = read_data(2);
new CsWeaponClassType:WeaponClass = cs_get_weapon_class(Weapon);
if(CS_WEAPONCLASS_PISTOL <= WeaponClass <= CS_WEAPONCLASS_SNIPERRIFLE)
{
if(WeaponClass != CS_WEAPONCLASS_GRENADE)
{
if(g_Silenced[id][0] && Weapon == CSW_M4A1)
{
new Ent = fm_find_ent_by_owner(-1,"weapon_m4a1",id); // Always returning 0??
if(Ent)
{
if(!cs_get_weapon_silen(Ent))
{
cs_set_weapon_silen(Ent,1);
}
}
}
new Ammo = cs_get_weapon_info(Weapon,CS_WEAPONINFO_MAX_ROUNDS);
if(cs_get_user_bpammo(id,Weapon) < Ammo)
{
cs_set_user_bpammo(id,Weapon,Ammo);
}
}
}
}
}
Any idea?
Ps. AMX Mod X And meta List
Code:
] meta list
Currently loaded plugins:
description stat pend file vers src load unlod
[ 1] AMX Mod X RUN - amxmodx_mm.dll v1.8.3-d ini Start ANY
[ 2] POD-Bot mm RUN - podbot_mm.dll vV3B23 ini Chlvl ANY
[ 3] CStrike RUN - cstrike_amxx.dll v1.8.3-d pl1 ANY ANY
[ 4] Ham Sandwich RUN - hamsandwich_amxx v1.8.3-d pl1 ANY ANY
[ 5] FakeMeta RUN - fakemeta_amxx.dl v1.8.3-d pl1 ANY ANY
[ 6] Fun RUN - fun_amxx.dll v1.8.3-d pl1 ANY ANY
6 plugins, 6 running
] amxx version
AMX Mod X 1.8.3-dev+5154 (http://www.amxmodx.org)
Authors:
David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
Borja "faluco" Ferrer, Scott "DS" Ehlert
Compiled: Mar 11 2018 07:25:29
Built from: https://github.com/alliedmodders/amxmodx/commit/2559fcf0
Build ID: 5154:2559fcf0
Core mode: JIT+ASM32
EDIT: I just find another better way to set weapon silencer, but question still open
__________________