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

[INFO] Fakemeta & Ham detailed function descriptions and examples


Post New Thread Reply   
 
Thread Tools Display Modes
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 10-16-2009 , 06:16   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #101

Good job!
Keep em coming.
Added all of them to the main post and added a little extra info on Ham_TakeDamage.
So please recheck if interested.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 10-16-2009 at 08:37.
ot_207 is offline
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
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 10-16-2009 , 08:24   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #103

Fakemeta function:
PHP Code:
EngFunc_GetBonePosition 
Description:
The function allows to get the bone positions of an entity. This is best used on getting specific player origin points.

These are the bones that a player has.

Code:
Bone 1 Name: "Bip01"

Bone 2 Name: "Bip01 Pelvis"

Bone 3 Name: "Bip01 Spine"

Bone 4 Name: "Bip01 Spine1"

Bone 5 Name: "Bip01 Spine2"

Bone 6 Name: "Bip01 Spine3"

Bone 7 Name: "Bip01 Neck"

Bone 8 Name: "Bip01 Head"

Bone 9 Name: "Bone01"

Bone 10 Name: "Bip01 L Clavicle"

Bone 11 Name: "Bip01 L UpperArm"

Bone 12 Name: "Bip01 L Forearm"

Bone 13 Name: "Bip01 L Hand"

Bone 14 Name: "Bip01 L Finger0"

Bone 15 Name: "Bip01 L Finger01"

Bone 16 Name: "Bip01 L Finger1"

Bone 17 Name: "Bip01 L Finger11"

Bone 18 Name: "-- L knuckle"

Bone 19 Name: "-- L Forearm twist"

Bone 20 Name: "-- L wrist"

Bone 21 Name: "-- L Elbow"

Bone 22 Name: "-- L bicep twist"

Bone 23 Name: "-- L shoulder outside"

Bone 24 Name: "-- L Shoulder inside"

Bone 25 Name: "Bip01 R Clavicle"

Bone 26 Name: "Bip01 R UpperArm"

Bone 27 Name: "Bip01 R Forearm"

Bone 28 Name: "Bip01 R Hand"

Bone 29 Name: "Bip01 R Finger0"

Bone 30 Name: "Bip01 R Finger01"

Bone 31 Name: "Bip01 R Finger1"

Bone 32 Name: "Bip01 R Finger11"

Bone 33 Name: "-- R knuckle"

Bone 34 Name: "-- R wrist"

Bone 35 Name: "-- R forearm twist"

Bone 36 Name: "-- R Elbow"

Bone 37 Name: "-- R bicep twist"

Bone 38 Name: "-- R Shoulder inside"

Bone 39 Name: "-- R shoulder outside"

Bone 40 Name: "-- Neck smooth"

Bone 41 Name: "-- R Butt"

Bone 42 Name: "-- L butt"

Bone 43 Name: "Bip01 L Thigh"

Bone 44 Name: "Bip01 L Calf"

Bone 45 Name: "Bip01 L Foot"

Bone 46 Name: "Bip01 L Toe0"

Bone 47 Name: "-- L ankle"

Bone 48 Name: "-- L Knee"

Bone 49 Name: "Bip01 R Thigh"

Bone 50 Name: "Bip01 R Calf"

Bone 51 Name: "Bip01 R Foot"

Bone 52 Name: "Bip01 R Toe0"

Bone 53 Name: "-- R Ankle"

Bone 54 Name: "-- R Knee"

Bone 55 Name: "Bomb"
This image shows the locations of the bones, they are marked through blue points. The red point is the player origin.

[IMG]http://img507.**************/img507/7762/playerskeleton.jpg[/IMG]


Usage:
PHP Code:
// ENTITY is the player entity id
// BONE_NUMBER you have to choose from the list above
// bone_origin[3] is the vector where we save the bone origin
// bone_angles[3] the vector that holds the angles of the bone.
engfunc(EngFunc_GetBonePositionENTITYBONE_NUMBERFloat:bone_origin[3], Float:bone_angles[3]) 
Useful Stocks:
These stocks are made for CS/CZ you need to port them to other mods.

This gets the hitgroup of the bone.
PHP Code:
#define BONE_HIT_HEAD              8
#define BONE_HIT_CHEST             6
#define BONE_HIT_STOMACH         4
#define BONE_HIT_LEFTARM        24
#define BONE_HIT_RIGHTARM        39
#define BONE_HIT_LEFTLEG        48
#define BONE_HIT_RIGHTLEG        54
#define HEAD_NECK                40
#define BONE_L_BUTT                41
#define BONE_R_BUTT                42

stock get_bone_hitgroup(number)
{
    switch (
number)
    {
        case 
HEAD_NECK:
        {
            return 
HIT_HEAD
        
}
        case 
BONE_L_BUTT:
        {
            return 
HIT_LEFTLEG
        
}
        case 
BONE_R_BUTT:
        {
            return 
HIT_RIGHTLEG
        
}
    }
    
    if (
<= number <= BONE_HIT_STOMACH)
        return 
HIT_STOMACH
    
    
if (BONE_HIT_STOMACH number <= BONE_HIT_CHEST)
        return 
HIT_CHEST
    
    
if (BONE_HIT_CHEST number <= BONE_HIT_HEAD)
        return 
HIT_HEAD
    
    
if (BONE_HIT_HEAD number <= BONE_HIT_LEFTARM)
        return 
HIT_LEFTARM
    
    
if (BONE_HIT_LEFTARM number <= BONE_HIT_RIGHTARM)
        return 
HIT_RIGHTARM
    
    
if (BONE_HIT_RIGHTARM number <= BONE_HIT_LEFTLEG)
        return 
HIT_LEFTLEG
    
    
if (BONE_HIT_LEFTLEG number <= BONE_HIT_RIGHTLEG)
        return 
HIT_RIGHTLEG
    
    
return HIT_GENERIC

This gets the closest bone to the gunshot [Use this in FM_TraceLine and Ham_TraceAttack
PHP Code:
#define DISTANCE_CLEAR_HIT        2.0

stock find_closest_bone_to_gunshot(victimFloat:endtrace[3])
{
    new 
Float:angles[3], Float:origin[3], Float:dist 9999999.99Float:curorigin[3], bone_nr
    
for (new i=1;i<=54;i++)
    {
        
// Get the bone position
        
engfunc(EngFunc_GetBonePositionvictimicuroriginangles)
        
// Calculate the distance vector
        
xs_vec_sub(curoriginendtraceangles)
        
        
// If this is smaller than the last small distance remember the value!
        
if (xs_vec_len(angles) <= dist)
        {
            
origin curorigin
            dist 
xs_vec_len(angles)
            
bone_nr i
        
}
        
        
// If distance is smaller than CLEARHIT! Break (We accept the last value!)
        
if (dist <= DISTANCE_CLEAR_HIT)
        {
            break
        }
    }
    
    
// Return the bone
    
return bone_nr

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

Back, will come around when I have time.
ot_207 is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 10-16-2009 , 20:19   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #104

Fakemeta function :
Code:
EngFunc_FindClientInPVS

Description :
Return the next "player" entity in someone PVS using a global loop.


Usage :
Code:
iEnt2 = engfunc(EngFunc_FindClientInPVS, iEnt);

Parameters
iEnt = Source entity. Seek someone within of iEnt PVS

Unlike EngFunc_EntitiesInPVS, it does not return a series of chained entities.

It works like a global loop of entities.
No matter which source entity you use, this function maintains the last index used and returns the next entity in source entity PVS.

This function must be called severals times to find every entity in PVS and also can return the source entity but it can't be called twice inside the same function because it will return the same entity.
Notes :
It seems you can call this function once between some forward (maybe UpdateClientData, Think, AddToFullPack or some other).

It's not clear the main purpose of this function because you can get similar results with FindEntitiesInPVS.
CheckVisibility and FindEntitiesInPVS are better functions to use.
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.

Last edited by joropito; 10-17-2009 at 15:17.
joropito is offline
Send a message via MSN to joropito
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 10-17-2009 , 06:29   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #105

I suggest doing an example of that function.
Since it is harder to use than EngFunc_FindEntityByString or FindEntityInSphere
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Starsailor
horrible hahah
Join Date: Aug 2008
Location: Buenos Aires
Old 10-17-2009 , 11:54   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #106

Fakemeta function :
Code:
EngFunc_AlertMessage

Description :
Prints an alert message.


Usage:
Code:
engfunc(EngFunc_AlertMessage, AlertType, const Message)


AlertType can be:
at_notice -
at_console - same as at_notice, but forces a ConPrintf, not a message box, prints output to server console, but only if 'developer' is 1.
at_aiconsole - same as at_console, but only shown if 'developer' is 2.
at_warning -
at_error -
at_logged - prints output to server logs and console.
__________________
Find my plugins here..

Ex - Spanish Moderator.
Starsailor is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 10-17-2009 , 13:29   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #107

Quote:
Originally Posted by ot_207 View Post
I suggest doing an example of that function.
Since it is harder to use than EngFunc_FindEntityByString or FindEntityInSphere
Yes, too complicated to use this function and I can't find a good use of this (why not use EntitiesInPVS instead of this?).

It seems you can call this function once between some forward (maybe UpdateClientData, Think, AddToFullPack).
I'm thinking this based on my tests and what Arkshine said in other post.

If you call this function 1000 times inside a loop, it always returns the same entity.

In fakemeta there's a FM_FindClientInPVS but if you try to forward that call, it's not even called (tried to run, jump, shoot, kill, plant bomb and wait the explosion, drop guns, throw nades, etc).
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 10-17-2009 , 14:27   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #108

Quote:
Originally Posted by joropito View Post
Yes, too complicated to use this function and I can't find a good use of this (why not use EntitiesInPVS instead of this?).

It seems you can call this function once between some forward (maybe UpdateClientData, Think, AddToFullPack).
I'm thinking this based on my tests and what Arkshine said in other post.

If you call this function 1000 times inside a loop, it always returns the same entity.

In fakemeta there's a FM_FindClientInPVS but if you try to forward that call, it's not even called (tried to run, jump, shoot, kill, plant bomb and wait the explosion, drop guns, throw nades, etc).
Ok, then at least add a note that says this function has problems.
CheckVisibility and FindEntsInPVS are better to use.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 10-17-2009 , 15:18   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #109

Quote:
Originally Posted by ot_207 View Post
Ok, then at least add a note that says this function has problems.
CheckVisibility and FindEntsInPVS are better to use.
Updated.
I think it doesn't have problems. I think it's as is
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-17-2009 , 16:58   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #110

Yeah I remember it's just a pain how works this function. If you refer at a post -somewhere- there is a delay between each update, and it matches with the frequency of the "entity-without-classname" ( This entity is created right after max_clients ; if there is entities created in plugin_precache(), this entity will be created after that ). This entity is updated between .25 to 0.3s. It could be used there but it's more easy and efficient to use FindEntsInPVS.
__________________
Arkshine 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 09:16.


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