AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [INFO] Fakemeta & Ham detailed function descriptions and examples (https://forums.alliedmods.net/showthread.php?t=93229)

ot_207 05-26-2009 08:03

[INFO] Fakemeta & Ham detailed function descriptions and examples
 
Fakemeta Func Wiki

I think that we all need to contribute to this topic so let's get it started.

FakeMeta Functions
HamSandWich Functions
Contributors
  • Arkshine
  • Starsailor
  • joropito
  • Nomexous

ot_207 05-26-2009 08:18

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Fakemeta function:
PHP Code:

EngFunc_PointContents 

Description:
This function checks an origin and gives us information of its whearabouts.

The constants that this function returns are these:
Code:

#define        CONTENTS_EMPTY                  -1
#define        CONTENTS_SOLID                  -2
#define        CONTENTS_WATER                  -3
#define        CONTENTS_SLIME                  -4
#define        CONTENTS_LAVA                  -5
#define        CONTENTS_SKY                    -6
#define        CONTENTS_ORIGIN                -7          // Removed at csg time
#define        CONTENTS_CLIP                  -8          // Changed to contents_solid
#define        CONTENTS_CURRENT_0              -9
#define        CONTENTS_CURRENT_90            -10
#define        CONTENTS_CURRENT_180            -11
#define        CONTENTS_CURRENT_270            -12
#define        CONTENTS_CURRENT_UP            -13
#define        CONTENTS_CURRENT_DOWN          -14
#define CONTENTS_TRANSLUCENT            -15
#define        CONTENTS_LADDER                -16
#define        CONTENT_FLYFIELD                -17
#define        CONTENT_GRAVITY_FLYFIELD        -18
#define        CONTENT_FOG                    -19

Usage:
PHP Code:

static Float:origin[3]
static 
result
result 
engfunc(EngFunc_PointContentsorigin)
// if for example result is CONTENTS_SKY
// then the origin that we see is in the sky we can for example use this to see where a player is aming if he is aiming at sky this will be the result! 


Arkshine 05-26-2009 08:26

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
( Nice initiative but I think it should be update on the wiki too because more readable. Also for here creating a list for fakemeta and ham would be interesting. )

joaquimandrade 05-26-2009 08:35

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Nice ot.

ot_207 05-26-2009 08:39

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Quote:

Originally Posted by arkshine (Post 835014)
( Nice initiative but I think it should be update on the wiki too because more readable. Also for here creating a list for fakemeta and ham would be interesting. )

I think that we should update here first and after that do a wiki. :)
And thanks!

Quote:

Originally Posted by joaquimandrade (Post 835016)
Nice ot.

Thanks! If you have functions or constants that are important please post :).

ot_207 05-26-2009 09:08

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Fakemeta function:
PHP Code:

EngFunc_TraceLine 

Description:
This function traces between 2 origins and gives us information about it.

The constants that we can use in flags:
PHP Code:

#define DONT_IGNORE_MONSTERS            0
#define IGNORE_MONSTERS                 1
#define IGNORE_MISSILE                  2
#define IGNORE_GLASS                    0x100 

These constants can be used together.
Ex: IGNORE_MISSILE | IGNORE_MONSTERS | IGNORE_GLASS - This makes the traceline ignore missiles, monsters (players) and glass.

Here is a drawing that will show you how it works!
PHP Code:

engfunc(EngFunc_TraceLinestartendIGNORE_GLASS0tr

[IMG]http://img529.**************/img529/1863/traceline1.jpg[/IMG]

PHP Code:

engfunc(EngFunc_TraceLinestartendDONT_IGNORE_MONSTERS0tr

[IMG]http://img529.**************/img529/1415/traceline2.jpg[/IMG]

PHP Code:

engfunc(EngFunc_TraceLinestartendIGNORE_GLASS0tr

[IMG]http://img529.**************/img529/5815/traceline3.jpg[/IMG]

PHP Code:

engfunc(EngFunc_TraceLinestartendIGNORE_GLASS0tr

[IMG]http://img529.**************/img529/326/traceline4.jpg[/IMG]

Functions that come with the TraceLine pack:
PHP Code:

// Description: This creates a trace handle! 
// It is important to use because we don't want our plugins to mess with eachothers info!
new ptr create_tr2() 

PHP Code:

// Description: This creates a trace handle! 
// It is important to use because we don't want our plugins to mess with each others info!
free_tr2(ptr

PHP Code:

// Description: Gets/Sets information from/in the trace_handle
[g|s]et_tr2(trace_handleCONSTANTnumber_if_needed!) 

CONSTANT Expresion has this posible values:
Code:

enum TraceResult
{
        TR_AllSolid,                // int
        TR_StartSolid,                // int
        TR_InOpen,                // int
        TR_InWater,                // int
        TR_flFraction,                // float
        TR_vecEndPos,                // float array[3]
        TR_flPlaneDist,                // float
        TR_vecPlaneNormal,        // float array[3]
        TR_pHit,                // int (edict_t*)
        TR_iHitgroup,                // int
};

The float and array values need the third argument! Example:

PHP Code:

    new allsolid get_tr2(traceTR_AllSolid)
    new 
startsolid get_tr2(traceTR_StartSolid)
    
// TR_StartSolid is a boolean that says whether you were "inside" something 
    // (usually the world) when the trace started (point A)
    // TR_AllSolid tells you if you ever got out of the "inside" or not.
    
    
new inopen get_tr2(traceTR_InOpen)
    
// TR_InOpen means that the start point is in Open
    // That means in the world and not in an ent or something
    
    
new hit get_tr2(traceTR_pHit)
    
// What was hit by the traceline. It will either be a player index,
    // entity index, 0 (part of map), or -1 (didn't hit anything; 
    // doesn't happen with player tracelines).
    
    
new hitgroup get_tr2(traceTR_iHitgroup)
    
// If the traceline hit another player, returns will be HIT_HEAD,
    // HIT_CHEST, HIT_LEFTLEG... etc. If the traceline hit part of the
    // map, this returns HIT_GENERIC.
    
    
new Float:fraction
    get_tr2
(traceTR_flFractionfraction)
    
// Returns a number between 0.0 and 1.0, indicating how far the
    // traceline traveled start to end before it hit something. Depending
    // on what conditions were passed to this traceline forward function,
    // it could either be a wall or another entity.
    
    
new Float:end_origin[3]
    
get_tr2(traceTR_vecEndPosend_origin)
    
// The official end of the traceline. Not necesarily the same as the
    // second argument passed to this traceline forward function.
    
    
new Float:normal[3]
    
get_tr2(traceTR_vecPlaneNormalnormal)
    
// Returns a 1 unit long vector normal to the spot that it hit. Note
    // that "normal" has a special connotation here. It doesn't mean "regular." 

Example Stock:
PHP Code:

stock is_wall_between_points(Float:start[3], Float:end[3], ignore_ent)
{
    
// Create the trace handle! It is best to create it!
    
new ptr create_tr2()
    
    
// The main traceline function!
    // This function ignores GLASS, MISSILE and MONSTERS!
    // Here is an example of how you should combine all the flags!
    
engfunc(EngFunc_TraceLinestartendIGNORE_GLASS IGNORE_MONSTERS IGNORE_MISSILEignore_entptr)
    
    
// We are interested in the fraction parameter
    
new fraction
    get_tr2
(ptrTR_flFractionfraction)
    
    
// Free the trace handle (don't forget to do this!)
    
free_tr2(ptr)
    
    
// If = 1.0 then it didn't hit anything!
    
return (fraction != 1.0)


Extra info:
Valve - arguments of the trace handle
TraceLine Tutorial (Nomexous)

ot_207 05-26-2009 09:37

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Fakemeta function:
PHP Code:

EngFunc_FindEntityInSphere 

Description:
Find entities within a radius. The function returnes the next entity id after the start entity!

This is a drawing to show how this function works:
[IMG]http://img265.**************/img265/2395/screenshot053.png[/IMG]


If we use
PHP Code:

engfunc(EngFunc_FindEntityInSphere, -1originradius

The function in the situation above will return 1!
PHP Code:

engfunc(EngFunc_FindEntityInSphere20originradius

The function in the situation above will return 30!
PHP Code:

engfunc(EngFunc_FindEntityInSphere100originradius

The function in the situation above will return 0, meaning that it didn't find an entity with an id grater than 100!


Usage:
PHP Code:

engfunc(EngFunc_FindEntityInSphereent_to_startoriginradius


Dr.G 05-26-2009 09:53

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
nice ot. if anyone think a sphere is another word for circle its not -> http://en.wikipedia.org/wiki/File:Sphere_wireframe.svg

ot_207 05-26-2009 09:57

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Quote:

Originally Posted by Dr.G (Post 835050)
nice ot. if anyone think a sphere is another word for circle its not -> http://en.wikipedia.org/wiki/File:Sphere_wireframe.svg

Thanks! That was just as an example. If someone would do a 3d design it would be great :mrgreen:.

Dr.G 05-26-2009 10:46

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
1 Attachment(s)
this is some screenshots from autocad

xPaw 05-26-2009 12:15

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Good job ot, i suggest you add some list at first post

EngFunc_GetBonePosition
EngFunc_PointContents
EngFunc_TraceLine
EngFunc_FindEntityInSphere

ot_207 05-26-2009 12:26

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Quote:

Originally Posted by Dr.G (Post 835089)
this is some screenshots from autocad

Good job but try to make the 3 entities spheres in 3d and give them the same names as I did!

Quote:

Originally Posted by xPaw (Post 835130)
Good job ot, i suggest you add some list at first post

Edit: Added it!

EngFunc_GetBonePosition
EngFunc_PointContents
EngFunc_TraceLine
EngFunc_FindEntityInSphere

Good idea.
This list I will add in the future!
But you should also try to describe some functions or constants. I can't just do all of them...

Arkshine 05-26-2009 12:41

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Quote:

Good idea.
I was my suggestion above. I haven spoken chinese probably. :mrgreen:
I will try to describe some functions too.

Quote:

I can't just do all of them...
I'm sure you can. :p

Arkshine 05-26-2009 14:17

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Fakemeta function :

Quote:

EngFunc_PrecacheModel

Description :

Precaches a model or sprite file.

This should be used only when you would need to postpone the precache processus in plugin_init() or plugin_cfg(), otherwise you should use precache_model() native directly in plugin_precache() forward.
It can be useful for example when you want to manage models with cvars and to avoid registering them in plugin_precache() then getting some trouble, you could manage out of this forward.


Usage :

Code:
engfunc( EngFunc_PrecacheModel, "models/MyModel.mdl" ); engfunc( EngFunc_PrecacheModel, "sprites/MySprite.spr" );
It returns the precached model/sprite index if successful, otherwise 0.

Arkshine 05-26-2009 14:38

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Fakemeta function :

Quote:

EngFunc_PrecacheSound

Description :

Precaches a sound, only *.wav file. ( for mp3, see EngFunc_PrecacheGeneric )

This should be used only when you would need to postpone the precache processus in plugin_init() or plugin_cfg(), otherwise you should use precache_sound() native directly in plugin_precache() forward.
It can be useful for example when you want to manage sounds with cvars and to avoid registering them in plugin_precache() then getting some trouble, you could manage out of this forward.


Usage :

Code:
engfunc( EngFunc_PrecacheSound, "sound/MySound.wav" );
It returns the precached sound index if successful, otherwise 0.

SchlumPF* 05-26-2009 15:50

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
better create some kind of wiki where everyone can contribute like wikipedia, would be more handy than a forum thread.
i would appreciate that very much :D

Arkshine 05-26-2009 15:54

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
What I've suggested in my first post, but ot_207 prefers to do that to start. Someone can give me a good page name, I'm suck to find a good one and I will create the page right away on the wiki.

SchlumPF* 05-26-2009 16:03

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Quote:

Originally Posted by arkshine (Post 835264)
What I've suggested in my first post, but ot_207 prefers to do that to start. Someone can give me a good page name, I'm suck to find a good one and I will create the page right away on the wiki.

sry didnt read the whole thread, i just came home and checked the forum before showering and saw the thread. i simply read the mainpost and posted my idea :D
anyway, im sry but i cant find such a wikicms or whatever i should call it either :(

Starsailor 05-26-2009 18:04

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Fakemeta Function:

EngFunc_MessageBegin

Description:

This function is used to generate client messages.

Usage:

engfunc(EngFunc_MessageBegin,dest,msg_type,or igin[3]={0,0,0},player=0)

PHP Code:

static Float:origin[3// Origin should be a Float
pev(idpev_originorigin// Get user origin
engfunc(EngFunc_MessageBegin,MSG_BROADCAST,SVC_TEMPENTITY,origin,0// Create message 

PHP Code:

//With MSG_ONE_UNRELIABLE
engfunc(EngFunc_MessageBegin,MSG_ONE_UNRELIABLE,SVC_TEMPENTITY,_,id// Create message 

PHP Code:

//With MSG_ALL
 
engfunc(EngFunc_MessageBegin,MSG_ONE_UNRELIABLE,SVC_TEMPENTITY,_,id// Create message 

dest can be :

Code:

#define    MSG_BROADCAST              0        // Unreliable to all, There is not id
#define    MSG_ONE                    1        // Reliable to one (msg_entity)
#define    MSG_ALL                    2        // Reliable to all, There is not origin
#define    MSG_INIT                    3        // Write to the init string
#define    MSG_PVS                    4        // Ents in PVS of org
#define    MSG_PAS                    5        // Ents in PAS of org
#define    MSG_PVS_R                  6        // Reliable to PVS
#define    MSG_PAS_R                  7        // Reliable to PAS
#define    MSG_ONE_UNRELIABLE          8        // Send to one client, but don't put in reliable stream, put in unreliable datagram (could be dropped), There is not origin
#define    MSG_SPEC                    9        // Sends to all spectator proxies

Before calling another EngFunc_MessageBegin you must call message_end()

Starsailor 05-26-2009 18:25

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
List of all functions:

EngFunc_GetBonePosition
EngFunc_PointContents
EngFunc_TraceLine
EngFunc_FindEntityInSphere
EngFunc_PrecacheModel
EngFunc_PrecacheSound
EngFunc_MessageBegin

Arkshine 05-26-2009 18:36

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Your example is wrong. There is not id nor origin for MSG_ALL/MSG_BROADCAST. You should add an example for all.

Starsailor 05-26-2009 20:21

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
oo yes, you are right, i have forgotten that

EDIT: Done

ConnorMcLeod 05-27-2009 01:34

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Quote:

Originally Posted by arkshine (Post 835348)
Your example is wrong. There is not id nor origin for MSG_ALL/MSG_BROADCAST. You should add an example for all.

+ origins have to be floats.

Arkshine 05-27-2009 01:39

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Quote:

Originally Posted by Starsailor (Post 835383)
oo yes, you are right, i have forgotten that

EDIT: Done

It's still wrong.


Code:
engfunc( EngFunc_MessageBegin, MSG_BROADCAST, SVC_TEMPENTITY ); engfunc( EngFunc_MessageBegin, MSG_ALL, SVC_TEMPENTITY ); engfunc( EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id ); engfunc( EngFunc_MessageBegin, MSG_ONE, SVC_TEMPENTITY, _, id ); engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0 ); engfunc( EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, origin, 0 );

You should also comment more each MSG_*.

SchlumPF* 05-27-2009 01:44

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
EngFunc_Message_Beginuses floats, message_begin() doesnt.
if you explain such a function you should add an example when to use EngFunc_Message_Beginand when to use message_begin() because imo is EngFunc_Message_Beginkinda unnecesarry :X
also, you should explain MSG_INIT, PVS and PAS (with a short example ofc). at least because i never was able to find that out xD i mean MSG_ONE and MSG_ALL (+ the unreliable ones of them) are quite common but i guess there are a lot who never used MSG_INIT, MSG_PVS and MSG_PAS.
another thing is the origin, are there a few messages where you need it? i mean most messages need write_coord() to set the origin ^^

Arkshine 05-27-2009 02:10

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
EngFunc_MessageBegin is not unnecessary if you work with float and you use MSG_PVS/MSG_PAS. But it's true except that, message_begin() should be used.

Btw :

MSG_PVS = Potentially Visible Set = The message will be sent only to player who potentially view the provided origin.
MSG_PAS = Potentially Audible Set = The message will be sent only to player who potentially hear the sound from the provided origin.

It's useful to reduce data sent to a client.

MSG_PVS_R and MSG_PAS_R are not used. I think there is a thread about that.

Exolent[jNr] 05-27-2009 02:11

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
This is the most unorganized information tutorial I've ever seen.

Arkshine 05-27-2009 02:16

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
That's why it's better to use directly the wiki. :p

By the way, can you find for me a good page name so I can create it on the wiki, Exolent ? :p

xPaw 05-27-2009 04:08

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Fakemeta functions and their descriptions :mrgreen:

hleV 05-27-2009 04:38

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
"arkshine's Wiki".

Arkshine 05-27-2009 04:46

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
It doesn't help a lot. :mrgreen:

I will try and it can be renamed later anyway.

Arkshine 05-27-2009 05:03

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
You are drunk ?

zwfgdlc 05-27-2009 05:09

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
haha!sorry,my english is very bad.i misunderstand what you say.

Starsailor 05-27-2009 12:11

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
just i'm trying to help :cry::cry::cry::|:|:|

ot_207 05-27-2009 12:43

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Quote:

Originally Posted by Starsailor (Post 835787)
just i'm trying to help :cry::cry::cry::|:|:|

It is good that you are trying to help and you should also receive :crab:'s for that but you must help correctly! Look at the way I did the functions :), if you can do the same it will be great, arkshine is lending you a hand :wink:, try to take into account his advices.

SchlumPF* 05-27-2009 12:47

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Quote:

Originally Posted by ot_207 (Post 835810)
It is good that you are trying to help and you should also receive Karma for that but you must help correctly! Look at the way I did the functions :), if you can do the same it will be great, arkshine is lending you a hand :wink:, try to take into account his advices.

there is no karma anymore, you need to give :crab:'s now :D

ot_207 05-27-2009 12:51

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Quote:

Originally Posted by SchlumPF* (Post 835814)
there is no karma anymore, you need to give :crab:'s now :D

Right! Fixed that :mrgreen:!
Ja! Ich habe das repariert :mrgreen:!

Edit: Wo hat diese geniale idee, um Krabs stattdessen Karma geben?
Who had the idea of giving crabs instead of karma?

Edit2: SnoW the thread is already spammed enough so one post in plus won't make a dif :P.

SnoW 05-27-2009 13:27

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Quote:

Originally Posted by ot_207 (Post 835816)
Who had the idea of giving crabs instead of karma?

You are making spam to your own thread. It was never instead. Guys gave crabs much before the karma system was nuked.

SchlumPF* 05-27-2009 15:21

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Quote:

Originally Posted by ot_207 (Post 835816)
Edit: Wo hat diese geniale idee, um Krabs stattdessen Karma geben?
Who had the idea of giving crabs instead of karma?

Wo = where, who = wer
-> Wer hatte diese geniale Idee (there is no "genial" in your english sentence), Krabben statt Karma zu geben. (falscher Nebensatz).

i love ppl speaking german who learned it barely :D the sentences are most often wrong but you can understand nearly each sentece... this is much harder if someone _tries_ to speak english xD

:crab::crab::crab: to you ot_2007 <3

ot:
as you can see a thread is a really bad assembly of this idea which is really nice. some kind of wikipedia including a thread here at amxx where ppl can complain about erros and give you -:crab:'s!!!

ot_207 08-25-2009 09:41

Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
 
Let's create a wiki with this. These functions will be useful.


All times are GMT -4. The time now is 15:16.

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