Raised This Month: $12 Target: $400
 3% 

Solved Hide custom entity, Game not loading functions first time, Entity ID problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-21-2018 , 10:00   Hide custom entity, Game not loading functions first time, Entity ID problems
Reply With Quote #1

Hi,

1. Is there a way to hide custom entities same as we hide armoury_entity entities? By setting m_iCount to 0? When I mean 'hide' I don't mean remove.

2. Every time I get into the game for the first time and open a listen server, a lot of things don't load properly, such as:
- It doesn't properly load WeaponList, so my weaponbox entities don't get any ammo, until I restart the listen server and it works.
etc..

3.
And last, this code is not glowing the weapons I drop because of entity indexes getting messed up for some reason.
PHP Code:
public RoundStarted( ) // here we glow the weapon that we create
{
    
log_to_file"Rarity.txt""#1 iEnt: %d | Color: %d"WeaponBoxEntityg_iDataWeaponWeapon_Rarity ], g_iDataWeaponRarity_Damage ] );
    
set_pevWeaponBoxEntitypev_iuser2g_iDataWeaponWeapon_Rarity ] );
    
    
GlowWeaponWeaponBoxEntityg_iDataWeaponWeapon_Rarity ] );
}

public @
SetModeliEntszModel[ ] )
{
    if( ! 
pev_validiEnt ) )
    return 
FMRES_IGNORED;

    new 
szClassName32 ];
    
peviEntpev_classnameszClassNamecharsmaxszClassName ) );
    
    if( ! 
equalszClassName"weaponbox" ) )
    return 
FMRES_IGNORED;
    
    new 
iRarity peviEntpev_iuser2 );
    
log_to_file"Rarity.txt""#2 iEnt: %d | Color: %d | Class: %s"iEntiRarityszClassName );
    
    
GlowWeaponiEntiRarity );
    return 
FMRES_IGNORED;

Debug logs:
Quote:
L 07/21/2018 - 15:53:27: #2 iEnt: 544 | Color: 0 | Class: weaponbox
L 07/21/2018 - 15:53:27: #1 iEnt: 544 | Color: 4
L 07/21/2018 - 15:54:05: #2 iEnt: 113 | Color: 0 | Class: weaponbox
So basically this is what happens:

I create a weaponbox whose ID is 544, assign pev_iuser2 a value of 4, then hook FM_SetModel, and for the same weapon, the ID is 113? And of course the value is 0 because it's unassigned. Why does this happen?
__________________

Last edited by edon1337; 07-30-2018 at 18:01.
edon1337 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-21-2018 , 10:07   Re: Hide custom entity, Game not loading functions first time, Entity ID problems
Reply With Quote #2

1. Ef_nodraw?
__________________









Last edited by CrazY.; 07-21-2018 at 10:08. Reason: EF_NODRAW
CrazY. is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-21-2018 , 10:22   Re: Hide custom entity, Game not loading functions first time, Entity ID problems
Reply With Quote #3

Quote:
Originally Posted by CrazY. View Post
1. Ef_nodraw?
Does it disable touch from getting triggered on entity?
__________________
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-21-2018 , 10:33   Re: Hide custom entity, Game not loading functions first time, Entity ID problems
Reply With Quote #4

1. No, but you can check if EF_NODRAW is set and block touch.
3. I'm not sure I see something wrong. The forward can be called for other weaponboxs too, not only the one you created. Explain better or provide more code. 113 is simply another entity.
__________________

Last edited by HamletEagle; 07-21-2018 at 10:34.
HamletEagle is online now
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-21-2018 , 10:48   Re: Hide custom entity, Game not loading functions first time, Entity ID problems
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
3. I'm not sure I see something wrong. The forward can be called for other weaponboxs too, not only the one you created. Explain better or provide more code. 113 is simply another entity.
So here's my case:
- I create a weaponbox entity, and I want it to glow for example GREEN (value=1), also set pev_iuser2 value to GREEN so we can retrieve what color we set later on.

- So now I want weaponboxes to keep that glow even when a player picks it up and drops it, so I hook FM_SetModel and retrieve pev_iuser2, get the color that we set before on the weaponbox and set it again. But unfortunately none of the IDs in FM_SetModel match the IDs of the weaponboxes that I create, as you can see in the debug log.

EDIT: FM_SetModel apparently isn't the right event to do this, but what else can I use?
__________________

Last edited by edon1337; 07-30-2018 at 18:00.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-21-2018 , 11:05   Re: Hide custom entity, Game not loading functions first time, Entity ID problems
Reply With Quote #6

Quote:
- So now I want weaponboxes to keep that glow even when a player picks it up and drops it, so I hook FM_SetModel and retrieve pev_iuser2, get the color that we set before on the weaponbox and set it again. But unfortunately none of the IDs in FM_SetModel match the IDs of the weaponboxes that I create, as you can see in the debug log.

EDIT: FM_SetModel apparently isn't the right event to do this, but what else can I use?
Now I get it. What you don't know is that once a weaponbox is picked up that box is gone and the next time you drop the weapon a new weaponbox is being created. The only thing that remains the same is the weapon entity.

What you can do is when the player will touch the weaponbox apply the same flag from pev_iuser2 to the weapon entity. Next, when player tries to drop check if the item that's being dropped contains the pev_iuser2 flag and if that's true apply the flag to the new weaponbox.
__________________

Last edited by HamletEagle; 07-21-2018 at 11:10.
HamletEagle is online now
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-21-2018 , 12:06   Re: Hide custom entity, Game not loading functions first time, Entity ID problems
Reply With Quote #7

Quote:
Originally Posted by HamletEagle View Post
Now I get it. What you don't know is that once a weaponbox is picked up that box is gone and the next time you drop the weapon a new weaponbox is being created. The only thing that remains the same is the weapon entity.
My bad, didn't know that.

I didn't quite understand this part:

Quote:
Originally Posted by HamletEagle View Post
when player tries to drop check if the item that's being dropped contains the pev_iuser2 flag and if that's true apply the flag to the new weaponbox.
PHP Code:
public plugin_init( )
{
    
register_touch"weaponbox""player""@Touch" );

    
register_forwardFM_SetModel"@SetModel_Pre");
}

public @
TouchiEntid )
{
    new 
iRarity peviEntpev_iuser2 );

    
GlowWeaponiEntiRarity );
}

public @
SetModel_PreiEnt, const szModel[ ] )
{
    new 
iRarity peviEntpev_iuser2 );

    if( 
iRarity )
    {
        
// ?
    
}

__________________

Last edited by edon1337; 07-21-2018 at 12:06.
edon1337 is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-21-2018 , 12:43   Re: Hide custom entity, Game not loading functions first time, Entity ID problems
Reply With Quote #8

Use pev_iuser3 or 4 then if 2 is reserved for rarity.
__________________
stuff
maqi is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-21-2018 , 12:44   Re: Hide custom entity, Game not loading functions first time, Entity ID problems
Reply With Quote #9

Quote:
Originally Posted by maqi View Post
Use pev_iuser3 or 4 then if 2 is reserved for rarity.
What? Why would I use another pev_iuser?
__________________

Last edited by edon1337; 07-21-2018 at 12:44.
edon1337 is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-21-2018 , 13:00   Re: Hide custom entity, Game not loading functions first time, Entity ID problems
Reply With Quote #10

Quote:
Originally Posted by HamletEagle View Post
What you can do is when the player will touch the weaponbox apply the same flag from pev_iuser2 to the weapon entity. Next, when player tries to drop check if the item that's being dropped contains the pev_iuser2 flag and if that's true apply the flag to the new weaponbox.
__________________
stuff
maqi is offline
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 08:10.


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