View Single Post
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 10-16-2009 , 08:09   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #102

Fakemeta function:
PHP Code:
EngFunc_CheckVisibility 
Description:
This function is used to check if an entity is in your PVS.
It can be used on all entities except worldspawn!
Here I will show you how to use is, since this function has a paramater that must be obtained in a special way!

What is PVS?
PVS means potentially visible set, this means that the entities that we have in this list can be seen.
PVS does not hold just the entities that we see!
By knowing this we can get to the conclusion that PVS has the role of limiting data transfer for better internet connection/lower amount of data transfer!

So in small words I want to say something like this:
Code:
Entity that is in PVS => Can be seen => Data Transfer about that entity
Entity that it is not in PVS => Can not be seen => No data transfer => Save bandwidth
How does it work?
Well let's say that every room of the map is a cube.
We find ourselves in a room and that also means that we are in the cube of that room.
We can see the entities in the next rooms because the cubes of that room touch with the cube of the room we are in.

How do I use this function?
Well this function has a parameter that must be obtained in a special way. That is the "pset" parameter.
Here is how you obtain that parameter.
Note: The parameter is player only, that means that if you get pset for example for a player that has the id "1". When you use this function on an entity it will check whether that entity is in PVS of the Player id "1".

Example Usage:
PHP Code:
new g_cl_pset[33]

public 
plugin_init(id)
{
    
register_forward(FM_AddToFullPack"pfw_atfp"1)
}

public 
pfw_atfp(eseenthostflagsplayerset)
{
    
g_cl_pset[host] = set
    
    
return FMRES_IGNORED
}

stock is_ent_in_player_pvs(identity)
{
    return 
engfunc(EngFunc_CheckVisibilityentityg_cl_pset[id])
}

stock get_pvs_players(idplayers[32], numflags[], team[])
{
    if (!
is_user_connected(id))
        return 
0    

    get_players
(playersnumflagsteam)
    
    for (new 
i=0;i<num;i++)
    {
        if (!
is_ent_in_player_pvs(idplayers[i]))
        {
            
num--;
            
            for (new 
j=i;j<num;j++)
            {
                
players[j] = players[j+1]
            }
            
            
i--
        }
    }
    
    return 
1

__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline