AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [solved] addtofullpack from an entity (https://forums.alliedmods.net/showthread.php?t=92313)

Hunter-Digital 05-13-2009 14:25

[solved] addtofullpack from an entity
 
I want to make an entity that I spawn glow to a single team, but I can't seem to make it working...

PHP Code:

public fw_addtofullpack(es_handleepidhostflagsplayerpSet)
{
    if(
player && iTeam[id] == && !is_player(p))
    {
          static class[
32]
 
          
entity_get_string(pEV_SZ_classname, class, 31)
 
          if(
equal(class, "my_entity_class"))
          {
               
set_es(es_handleES_RenderFxkRenderFxGlowShell)
               
set_es(es_handleES_RenderColor, {01000})
               
set_es(es_handleES_RenderAmt25)
          }
    }
 
    return 
FMRES_IGNORED


Or is this impossible ? :?

xPaw 05-13-2009 14:36

Re: addtofullpack from an entity
 
PHP Code:

new gMyEntity

when creating entity use gMyEntity for id then..
PHP Code:

public fw_addtofullpack(es_handleepidhostflagsplayerpSet) {
    if( !
player && == gMyEntity ) {
        if( 
iTeam[id] == ) {
            
set_eses_handleES_RenderFxkRenderFxGlowShell );
            
set_eses_handleES_RenderColor, {01000} );
            
set_eses_handleES_RenderAmt25 );
        }
    }
    
    return 
FMRES_IGNORED



Hunter-Digital 05-13-2009 18:01

Re: addtofullpack from an entity
 
Ok testing it out, but what does the "player" variable stands for ? if the host is a player or the ent ? :?

also hostflags and pSet, what are those for ? :}

edit: yep, works... it was like my version, but I checked if "player" was positive, I would have cached the ent afterwards anyway :P

SchlumPF* 05-13-2009 18:44

Re: addtofullpack from an entity
 
never do something like retrieving a classname + equal() in addtofullpack, it takes a lot cpu! addtofullpack is called thousands of times within a few seconds! always cache data you need to check in addtofullpack.

Code:

FM_AddToFullPack(entState, e, ent, host, iHostFlags, iPlayer, pSet)

AddToFullPack
Return 1 if the entity state has been filled in for the ent and the entity will be propagated to the client,
0 otherwise state is the server maintained copy of the state info that is transmitted to the client.
A MOD could alter values copied into state to send the "host" a different look for a particular entity update, etc.
e and ent are the entity that is being added to the update, if 1 is returned.
Host is the player's edict of the player whom we are sending the update to.
Player is 1 if the ent/e is a player and 0 otherwise.
pSet is either the PAS or PVS that we previous set up.
We can use it to ask the engine to filter the entity against the PAS or PVS.
We could also use the pas/pvs that we set in SetupVisibility, if we wanted to.
Caching the value is valid in that case, but still only for the current frame.


Hunter-Digital 05-13-2009 18:59

Re: [solved] addtofullpack from an entity
 
Yeah I know, it's like prethink, I used entity_get_string() just to test, so I don't do all the global variables and stuff and then I have the big surprise of not working xD

Hmm, would it help if I skip some frames from it... like so:
PHP Code:

#define SkipFrames 3
 
new iCancel 0
 
public fw_addtofullpack(/* etc */)
{
        if(
iCancel >= SkipFrames)
              
iCancel 0
        
else
        {
              
iCancel++
              return 
FMRES_IGNORED
        
}
 
        
// stuff...


? :}

SchlumPF* 05-13-2009 19:58

Re: [solved] addtofullpack from an entity
 
its not like prethink, test it yourself :X prethink is maybe called 10000 times when addtofullpack is near to 1mio (dont remember my testing values but addtofullpack also depends on the map).

skipping shouldnt be a huge thing to improve the plugins performance since you have to check, increment and reset the var.


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

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