Raised This Month: $ Target: $400
 0% 

[SOLVED] cs_find_ent_by_owner broken?


Post New Thread Reply   
 
Thread Tools Display Modes
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
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-01-2018 , 03:16   Re: [SOLVED] cs_find_ent_by_owner broken?
Reply With Quote #2

Which amx version are you using?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-01-2018 , 05:24   Re: [SOLVED] cs_find_ent_by_owner broken?
Reply With Quote #3

Do you get any logs saying the native is disabled?
__________________
HamletEagle is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-01-2018 , 08:22   Re: [SOLVED] cs_find_ent_by_owner broken?
Reply With Quote #4

Quote:
Originally Posted by HamletEagle View Post
Do you get any logs saying the native is disabled?
@Natsheh is in post

No, thanks for repply i forgot to read small note on this function:

Code:
Note
Unlike other mods CS keeps track of entities using a custom hashtable.
This function utilizes the hasthable and allows for considerably faster
classname lookup compared to the default FindEntityByString (used by
find_ent_by_owner() for example).
Note
This exclusively considers entities in the hashtable, created by the
game itself, using cs_create_entity(), or added via cs_set_ent_class()
IT is for entity created by these functions, it shoud be fine my mistake here

Im using now find_ent_by_owner of engine.inc

Ps. Have other way to find it than engine or fakemeta utils?


Thanks again
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-01-2018 , 10:04   Re: [SOLVED] cs_find_ent_by_owner broken?
Reply With Quote #5

Which is the error that you get with Ham_Item_Deploy?
__________________








CrazY. is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-01-2018 , 10:17   Re: [SOLVED] cs_find_ent_by_owner broken?
Reply With Quote #6

Quote:
Originally Posted by CrazY. View Post
Which is the error that you get with Ham_Item_Deploy?
I did not understand how i can get a weapon entity owner with Ham_Item_Deploy.

But if you talking about register event instead of CurWeapon do not make an difference to me, only just because on Ham_Item_Deploy you will need to hook every weapon, while CurWeapon not.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-01-2018 , 10:26   Re: [SOLVED] cs_find_ent_by_owner broken?
Reply With Quote #7

Quote:
Originally Posted by ^SmileY View Post
I did not understand how i can get a weapon entity owner with Ham_Item_Deploy.

But if you talking about register event instead of CurWeapon do not make an difference to me, only just because on Ham_Item_Deploy you will need to hook every weapon, while CurWeapon not.
You can use m_pPlayer offset and get_pdata_cbase.

Quote:
Im using now find_ent_by_owner of engine.inc

Ps. Have other way to find it than engine or fakemeta utils?
What is wrong with using engine/fakemeta(NOT fakemeta util)?
__________________
HamletEagle is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-01-2018 , 10:31   Re: [SOLVED] cs_find_ent_by_owner broken?
Reply With Quote #8

Quote:
Hi, i tried to put silencer on CurWeapon Event (Ham_Deploy is crashing with podbots)
Quote:
I did not understand how i can get a weapon entity owner with Ham_Item_Deploy.
I still continue without understand, first you said Ham_Item_Deploy crashes your game.
__________________









Last edited by CrazY.; 06-01-2018 at 10:32.
CrazY. is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-01-2018 , 12:10   Re: [SOLVED] cs_find_ent_by_owner broken?
Reply With Quote #9

Quote:
Originally Posted by CrazY. View Post
I still continue without understand, first you said Ham_Item_Deploy crashes your game.
Yes crash duo podbots (Maybe my mistake) but i still using CurWeapon anyway.

"Which is the error that you get with Ham_Item_Deploy?"

@HamletEagle

Nothing wrong, thanks

Ps. I tried to spawn a player with weapon silenced and did not found a reliable way to do it correctly.
If possible, using some new method??

Thanks again
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Reply


Thread Tools
Display Modes

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