AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Hide custom entity, Game not loading functions first time, Entity ID problems (https://forums.alliedmods.net/showthread.php?t=309323)

edon1337 07-21-2018 10:00

Hide custom entity, Game not loading functions first time, Entity ID problems
 
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?

CrazY. 07-21-2018 10:07

Re: Hide custom entity, Game not loading functions first time, Entity ID problems
 
1. Ef_nodraw?

edon1337 07-21-2018 10:22

Re: Hide custom entity, Game not loading functions first time, Entity ID problems
 
Quote:

Originally Posted by CrazY. (Post 2605269)
1. Ef_nodraw?

Does it disable touch from getting triggered on entity?

HamletEagle 07-21-2018 10:33

Re: Hide custom entity, Game not loading functions first time, Entity ID problems
 
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.

edon1337 07-21-2018 10:48

Re: Hide custom entity, Game not loading functions first time, Entity ID problems
 
Quote:

Originally Posted by HamletEagle (Post 2605272)
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?

HamletEagle 07-21-2018 11:05

Re: Hide custom entity, Game not loading functions first time, Entity ID problems
 
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.

edon1337 07-21-2018 12:06

Re: Hide custom entity, Game not loading functions first time, Entity ID problems
 
Quote:

Originally Posted by HamletEagle (Post 2605274)
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 (Post 2605274)
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 )
    {
        
// ?
    
}



maqi 07-21-2018 12:43

Re: Hide custom entity, Game not loading functions first time, Entity ID problems
 
Use pev_iuser3 or 4 then if 2 is reserved for rarity.

edon1337 07-21-2018 12:44

Re: Hide custom entity, Game not loading functions first time, Entity ID problems
 
Quote:

Originally Posted by maqi (Post 2605282)
Use pev_iuser3 or 4 then if 2 is reserved for rarity.

What? Why would I use another pev_iuser?

maqi 07-21-2018 13:00

Re: Hide custom entity, Game not loading functions first time, Entity ID problems
 
Quote:

Originally Posted by HamletEagle (Post 2605274)
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.



All times are GMT -4. The time now is 01:59.

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