Difference between revisions of "FakeMeta General Usage (AMX Mod X)"

From AlliedModders Wiki
Jump to: navigation, search
(Current FakeMeta and Old)
(pdata -> entvars, pdata is something different :))
Line 1: Line 1:
 
==Current FakeMeta and Old==
 
==Current FakeMeta and Old==
This FakeMeta article is not to be confused with the old FakeMeta included directly in AMX Mod X, which allowed a fix for a problem that arose due to a Steam update. For this context, see [[FakeMeta_(Old) | FakeMeta (Old)]].
+
FakeMeta used to be an internal mini-metamod inside [[AMX Mod X]].  This was removed in 1.50, and now only the module remains. The module is an entirely different concept, which extends [[Metamod]] HL1 programming powers to scripts.
  
 
==About==
 
==About==
 
FakeMeta is an extremely powerful module for AMX Mod X that effectively allows you to write Metamod plugins in [PAWN].
 
FakeMeta is an extremely powerful module for AMX Mod X that effectively allows you to write Metamod plugins in [PAWN].
  
Unlike Engine, FakeMeta uses no CPU if it is not told to do anything (other than to exist). For this reason, it is recommended to use FakeMeta over Engine. There is nothing in Engine that is not in FakeMeta, some way or another.
+
Unlike Engine, FakeMeta uses no CPU if it is not told to do anything (other than to exist). For this reason, it is recommended to use FakeMeta over Engine. There is nothing in Engine that is not in FakeMeta -- while some functionality might be less [[Abstraction|abstracted]], it is still achievable, and usually with more flexibility.
  
 
==Engine vs. FakeMeta==
 
==Engine vs. FakeMeta==
Line 12: Line 12:
  
 
FakeMeta:
 
FakeMeta:
<pre>
+
<pawn>
 
#include <amxmodx>
 
#include <amxmodx>
 
#include <fakemeta>
 
#include <fakemeta>
Line 29: Line 29:
 
return FMRES_IGNORED;
 
return FMRES_IGNORED;
 
}
 
}
</pre>
+
</pawn>
  
 
Engine:
 
Engine:
<pre>
+
<pawn>
 
#include <amxmodx>
 
#include <amxmodx>
 
#include <engine>
 
#include <engine>
Line 47: Line 47:
 
return;
 
return;
 
}
 
}
</pre>
+
</pawn>
  
 
The "return FMRES_IGNORED" section will be covered later on this page.
 
The "return FMRES_IGNORED" section will be covered later on this page.
Line 55: Line 55:
 
FakeMeta also allows you to do other things, such as retrieve private data (using pev, set_pev / get_pdata_int, get_pdata_float, get_pdata_string, set_pdata_int, set_pdata_float, set_pdata_string), forcing DLL functions to be executed, as well as call Engine (not the module) functions.
 
FakeMeta also allows you to do other things, such as retrieve private data (using pev, set_pev / get_pdata_int, get_pdata_float, get_pdata_string, set_pdata_int, set_pdata_float, set_pdata_string), forcing DLL functions to be executed, as well as call Engine (not the module) functions.
  
==Private Data Collecting==
+
==Entvars==
It is easy to read private data in FakeMeta, however it can sometimes cause problems if not done correctly (which is why Engine is more commonly used).
+
It is easy to read [[Entvars (Half-Life 1)|entvars]] in FakeMeta, however it can sometimes cause problems if not done correctly (which is why Engine is more commonly used).  Entvars are variables in a player's [[Edicts (Half-Life 1)|edict]] structure (an edict is the basis for an entity).
  
Here is an example of how to retrieve private data from an entity in FakeMeta:
+
Here is an example of how to retrieve the armor entvar from an entity in FakeMeta:
<pre>
+
<pawn>
 
#include <amxmodx>
 
#include <amxmodx>
 
#include <fakemeta>
 
#include <fakemeta>
Line 67: Line 67:
 
register_plugin("FakeMeta Test","1.0","Hawk552");
 
register_plugin("FakeMeta Test","1.0","Hawk552");
 
 
register_forward(FM_PlayerPreThink,"PreThink");
+
register_forward(FM_PlayerPreThink, "PreThink");
 
}
 
}
  
Line 78: Line 78:
 
return FMRES_IGNORED;
 
return FMRES_IGNORED;
 
}
 
}
</pre>
+
</pawn>
  
 
==DLL / Engine Function Usage==
 
==DLL / Engine Function Usage==
 
In DLLs and the Engine, there are functions that are called when certain events happen. These can be forced to be called through FakeMeta. Here is a general example:
 
In DLLs and the Engine, there are functions that are called when certain events happen. These can be forced to be called through FakeMeta. Here is a general example:
  
<pre>
+
<pawn>
 
#include <amxmodx>
 
#include <amxmodx>
 
#include <fakemeta>
 
#include <fakemeta>
Line 100: Line 100:
 
return FMRES_IGNORED;
 
return FMRES_IGNORED;
 
}
 
}
</pre>
+
</pawn>
  
 
Refer to the end of the line while viewing the DLLFunc and EngFunc sections, as there is usually some description of paramaters, such as ''edict_t *p_Entity'' or ''void''. ''void'' generally refers to no parameters, while ''edict_t *p_Entity'' means the entity id, so the first parameter in the function would be the entity to call the function onto.
 
Refer to the end of the line while viewing the DLLFunc and EngFunc sections, as there is usually some description of paramaters, such as ''edict_t *p_Entity'' or ''void''. ''void'' generally refers to no parameters, while ''edict_t *p_Entity'' means the entity id, so the first parameter in the function would be the entity to call the function onto.

Revision as of 18:21, 20 January 2006

Current FakeMeta and Old

FakeMeta used to be an internal mini-metamod inside AMX Mod X. This was removed in 1.50, and now only the module remains. The module is an entirely different concept, which extends Metamod HL1 programming powers to scripts.

About

FakeMeta is an extremely powerful module for AMX Mod X that effectively allows you to write Metamod plugins in [PAWN].

Unlike Engine, FakeMeta uses no CPU if it is not told to do anything (other than to exist). For this reason, it is recommended to use FakeMeta over Engine. There is nothing in Engine that is not in FakeMeta -- while some functionality might be less abstracted, it is still achievable, and usually with more flexibility.

Engine vs. FakeMeta

Comparison between Engine and FakeMeta:

FakeMeta:

#include <amxmodx>
#include <fakemeta>
 
public plugin_init()
{
	register_plugin("FakeMeta Test","1.0","Hawk552");
 
	register_forward(FM_PlayerPreThink,"PreThink");
}
 
public PreThink(id)
{
	// here you would insert some code
 
	return FMRES_IGNORED;
}

Engine:

#include <amxmodx>
#include <engine>
 
public plugin_init()
{
	register_plugin("FakeMeta Test","1.0","Hawk552");
}
 
public client_PreThink(id)
{
	// here you would insert some code
 
	return;
}

The "return FMRES_IGNORED" section will be covered later on this page.

General Functionality

FakeMeta also allows you to do other things, such as retrieve private data (using pev, set_pev / get_pdata_int, get_pdata_float, get_pdata_string, set_pdata_int, set_pdata_float, set_pdata_string), forcing DLL functions to be executed, as well as call Engine (not the module) functions.

Entvars

It is easy to read entvars in FakeMeta, however it can sometimes cause problems if not done correctly (which is why Engine is more commonly used). Entvars are variables in a player's edict structure (an edict is the basis for an entity).

Here is an example of how to retrieve the armor entvar from an entity in FakeMeta:

#include <amxmodx>
#include <fakemeta>
 
public plugin_init()
{
	register_plugin("FakeMeta Test","1.0","Hawk552");
 
	register_forward(FM_PlayerPreThink, "PreThink");
}
 
public PreThink(id)
{
	new value = pev(id,pev_armorvalue); // gets armor from client/entity
 
	client_print(id,print_chat,"%i",value); // prints armor value to client
 
	return FMRES_IGNORED;
}

DLL / Engine Function Usage

In DLLs and the Engine, there are functions that are called when certain events happen. These can be forced to be called through FakeMeta. Here is a general example:

#include <amxmodx>
#include <fakemeta>
 
public plugin_init()
{
	register_plugin("FakeMeta Test","1.0","Hawk552");
 
	register_forward(FM_PlayerPreThink,"PreThink");
}
 
public PreThink(id)
{
	dllfunc(DLLFunc_RegisterEncoders);
 
	return FMRES_IGNORED;
}

Refer to the end of the line while viewing the DLLFunc and EngFunc sections, as there is usually some description of paramaters, such as edict_t *p_Entity or void. void generally refers to no parameters, while edict_t *p_Entity means the entity id, so the first parameter in the function would be the entity to call the function onto.

Constants / General

A list of general constants and usage can be found on this page: http://www.amxmodx.org/funcwiki.php?go=module&id=16