AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with FM_AddToFullPack (https://forums.alliedmods.net/showthread.php?t=85725)

xPaw 02-15-2009 05:43

Help with FM_AddToFullPack
 
Hello, i have this code
PHP Code:

public fwdAddToFullPackes_handleeenthosthostflagsplayerpset )
    if( 
player )
        if( 
host != ent )
            
set_eses_handleES_Origin, { 999999999.0999999999.0999999999.0 } ); 

i dont understand how even it works, someone can say some info about it?
and where i should add check - if player is g_Spec[id] (bool) then noone will hear him.

ConnorMcLeod 02-15-2009 06:21

Re: Help with FM_AddToFullPack
 
From HLSDK, client.cpp.
I give you the whole code because some parts may help you, but you could understand what you need just reading the comment.

PHP Code:

/*
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
*/
int AddToFullPackstruct entity_state_s *stateint eedict_t *entedict_t *hostint hostflagsint playerunsigned char *pSet )
{
    
int                    i;

    
// don't send if flagged for NODRAW and it's not the host getting the message
    
if ( ( ent->v.effects == EF_NODRAW ) &&
         ( 
ent != host ) )
        return 
0;

    
// Ignore ents without valid / visible models
    
if ( !ent->v.modelindex || !STRINGent->v.model ) )
        return 
0;

    
// Don't send spectators to other players
    
if ( ( ent->v.flags FL_SPECTATOR ) && ( ent != host ) )
    {
        return 
0;
    }

    
// Ignore if not the host and not touching a PVS/PAS leaf
    // If pSet is NULL, then the test will always succeed and the entity will be added to the update
    
if ( ent != host )
    {
        if ( !
ENGINE_CHECK_VISIBILITY( (const struct edict_s *)entpSet ) )
        {
            return 
0;
        }
    }


    
// Don't send entity to local client if the client says it's predicting the entity itself.
    
if ( ent->v.flags FL_SKIPLOCALHOST )
    {
        if ( ( 
hostflags ) && ( ent->v.owner == host ) )
            return 
0;
    }
    
    if ( 
host->v.groupinfo )
    {
        
UTIL_SetGroupTracehost->v.groupinfoGROUP_OP_AND );

        
// Should always be set, of course
        
if ( ent->v.groupinfo )
        {
            if ( 
g_groupop == GROUP_OP_AND )
            {
                if ( !(
ent->v.groupinfo host->v.groupinfo ) )
                    return 
0;
            }
            else if ( 
g_groupop == GROUP_OP_NAND )
            {
                if ( 
ent->v.groupinfo host->v.groupinfo )
                    return 
0;
            }
        }

        
UTIL_UnsetGroupTrace();
    }

    
memsetstate0sizeof( *state ) );

    
// Assign index so we can track this entity from frame to frame and
    //  delta from it.
    
state->number      e;
    
state->entityType ENTITY_NORMAL;
    
    
// Flag custom entities.
    
if ( ent->v.flags FL_CUSTOMENTITY )
    {
        
state->entityType ENTITY_BEAM;
    }

    
// 
    // Copy state data
    //

    // Round animtime to nearest millisecond
    
state->animtime   = (int)(1000.0 ent->v.animtime ) / 1000.0;

    
memcpystate->originent->v.originsizeof( float ) );
    
memcpystate->anglesent->v.anglessizeof( float ) );
    
memcpystate->minsent->v.minssizeof( float ) );
    
memcpystate->maxsent->v.maxssizeof( float ) );

    
memcpystate->startposent->v.startpossizeof( float ) );
    
memcpystate->endposent->v.endpossizeof( float ) );

    
state->impacttime ent->v.impacttime;
    
state->starttime ent->v.starttime;

    
state->modelindex ent->v.modelindex;
        
    
state->frame      ent->v.frame;

    
state->skin       ent->v.skin;
    
state->effects    ent->v.effects;

    
// This non-player entity is being moved by the game .dll and not the physics simulation system
    //  make sure that we interpolate it's position on the client if it moves
    
if ( !player &&
         
ent->v.animtime &&
         
ent->v.velocity] == && 
         
ent->v.velocity] == && 
         
ent->v.velocity] == )
    {
        
state->eflags |= EFLAG_SLERP;
    }

    
state->scale      ent->v.scale;
    
state->solid      ent->v.solid;
    
state->colormap   ent->v.colormap;

    
state->movetype   ent->v.movetype;
    
state->sequence   ent->v.sequence;
    
state->framerate  ent->v.framerate;
    
state->body       ent->v.body;

    for (
04i++)
    {
        
state->controller[i] = ent->v.controller[i];
    }

    for (
02i++)
    {
        
state->blending[i]   = ent->v.blending[i];
    }

    
state->rendermode    ent->v.rendermode;
    
state->renderamt     ent->v.renderamt
    
state->renderfx      ent->v.renderfx;
    
state->rendercolor.ent->v.rendercolor.x;
    
state->rendercolor.ent->v.rendercolor.y;
    
state->rendercolor.ent->v.rendercolor.z;

    
state->aiment 0;
    if ( 
ent->v.aiment )
    {
        
state->aiment ENTINDEXent->v.aiment );
    }

    
state->owner 0;
    if ( 
ent->v.owner )
    {
        
int owner ENTINDEXent->v.owner );
        
        
// Only care if owned by a player
        
if ( owner >= && owner <= gpGlobals->maxClients )
        {
            
state->owner owner;    
        }
    }

    
// HACK:  Somewhat...
    // Class is overridden for non-players to signify a breakable glass object ( sort of a class? )
    
if ( !player )
    {
        
state->playerclass  ent->v.playerclass;
    }

    
// Special stuff for players only
    
if ( player )
    {
        
memcpystate->basevelocityent->v.basevelocitysizeof( float ) );

        
state->weaponmodel  MODEL_INDEXSTRINGent->v.weaponmodel ) );
        
state->gaitsequence ent->v.gaitsequence;
        
state->spectator ent->v.flags FL_SPECTATOR;
        
state->friction     ent->v.friction;

        
state->gravity      ent->v.gravity;
//        state->team            = ent->v.team;
//        
        
state->usehull      = ( ent->v.flags FL_DUCKING ) ? 0;
        
state->health        ent->v.health;
    }

    return 
1;



xPaw 02-15-2009 06:29

Re: Help with FM_AddToFullPack
 
ok thanks, i understanded from it just a bit
will be this right?
PHP Code:

if( host != ent && g_Spec[host] )
    
//... 


ConnorMcLeod 02-15-2009 07:23

Re: Help with FM_AddToFullPack
 
g_Spec[ent]


host is the player who you send the data (receiver), ent is the player from who you send datas (when player == 0, ent is not a player)

Bad english :(

xPaw 02-15-2009 07:59

Re: Help with FM_AddToFullPack
 
ok thanks, now i will understand it a bit more :D

HOST - Receiver
ENT - Sender


All times are GMT -4. The time now is 17:05.

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