AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] cs_find_ent_by_owner broken? (https://forums.alliedmods.net/showthread.php?t=307947)

^SmileY 05-31-2018 21:56

[SOLVED] cs_find_ent_by_owner broken?
 
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 :D

Natsheh 06-01-2018 03:16

Re: [SOLVED] cs_find_ent_by_owner broken?
 
Which amx version are you using?

HamletEagle 06-01-2018 05:24

Re: [SOLVED] cs_find_ent_by_owner broken?
 
Do you get any logs saying the native is disabled?

^SmileY 06-01-2018 08:22

Re: [SOLVED] cs_find_ent_by_owner broken?
 
Quote:

Originally Posted by HamletEagle (Post 2594783)
Do you get any logs saying the native is disabled?

@Natsheh is in post :D

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 :grrr:

Im using now find_ent_by_owner of engine.inc

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


Thanks again

CrazY. 06-01-2018 10:04

Re: [SOLVED] cs_find_ent_by_owner broken?
 
Which is the error that you get with Ham_Item_Deploy?

^SmileY 06-01-2018 10:17

Re: [SOLVED] cs_find_ent_by_owner broken?
 
Quote:

Originally Posted by CrazY. (Post 2594811)
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.

HamletEagle 06-01-2018 10:26

Re: [SOLVED] cs_find_ent_by_owner broken?
 
Quote:

Originally Posted by ^SmileY (Post 2594818)
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)?

CrazY. 06-01-2018 10:31

Re: [SOLVED] cs_find_ent_by_owner broken?
 
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.

^SmileY 06-01-2018 12:10

Re: [SOLVED] cs_find_ent_by_owner broken?
 
Quote:

Originally Posted by CrazY. (Post 2594822)
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 :D

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


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

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