Raised This Month: $ Target: $400
 0% 

[SOLVED] cs_find_ent_by_owner broken?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 05-31-2018 , 21:56   [SOLVED] cs_find_ent_by_owner broken?
Reply With Quote #1

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
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 05-31-2018 at 22:31. Reason: I just find another better way to set weapon silencer, but question still open :D
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:37.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode