Raised This Month: $2 Target: $400
 0% 

[TUT] Fakemeta General Usage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 06-24-2006 , 21:30   [TUT] Fakemeta General Usage
Reply With Quote #1

This is a duplicate of the article I made in AMWiki at this URL:
http://wiki.tcwonline.org/index.php/...28AMX_Mod_X%29
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:
Code:
#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:
Code:
#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:
Code:
#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:
Code:
#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.


Return Values

There are 4 return values in FakeMeta:
  • FMRES_HANDLED --> Something was done in this function, but call the one in the DLL / Engine anyways.
  • FMRES_SUPERCEDE --> Prevent function in DLL / Engine from being called.
  • FMRES_IGNORED --> Call original function.
  • FMRES_OVERRIDE --> Call original function, but change return value.

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
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-09-2006 , 15:37   Re: Fakemeta General Usage
Reply With Quote #2

nice hawk this is helpful and has helped me to achieve a higher understanding of something i didn't understand thank you
/bow
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 08-27-2006 , 10:04   Re: Fakemeta General Usage
Reply With Quote #3

Quote:
Originally Posted by nver_been_hit View Post
I want to start scripting in fakemeta , but where can I get some more info on fakemetas useage, and more functions ? The list of the functions dont have much info .
Reading plugins that use it is probably the best way. This is just an introduction and doesn't really cover anything very advanced.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 10-15-2006 , 20:22   Re: Fakemeta General Usage
Reply With Quote #4

So in essence, anything that can be called in engine.inc can be called from fakemeta?

What would be an example of a killblocking function that uses fakemeta instead of client_kill(id)?
Bad_Bud is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-15-2006 , 20:23   Re: Fakemeta General Usage
Reply With Quote #5

Everything and more.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-15-2006 , 21:06   Re: Fakemeta General Usage
Reply With Quote #6

Quote:
Originally Posted by Bad_Bud View Post
So in essence, anything that can be called in engine.inc can be called from fakemeta?

What would be an example of a killblocking function that uses fakemeta instead of client_kill(id)?
Ask somewhere else next time, but for now:

Code:
// in plugin_init:
register_forward(FM_ClientKill,"ForwardClientKill")
Code:
public ForwardClientKill(id)
{
    // return FMRES_IGNORED /* lets kill go through */
    return FMRES_SUPERCEDE /* blocks kill */
}
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 10-15-2006 , 23:03   Re: Fakemeta General Usage
Reply With Quote #7

Fakemeta is quite strange indeed...
Bad_Bud is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 10-16-2006 , 00:46   Re: Fakemeta General Usage
Reply With Quote #8

Don't spam.
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
10Stars
Senior Member
Join Date: Mar 2006
Location: New Jersey
Old 10-16-2006 , 00:47   Re: Fakemeta General Usage
Reply With Quote #9

Quote:
Originally Posted by Bad_Bud View Post
Fakemeta is quite strange indeed...
You dont even know what fakemeta is for.
__________________
www.6o9clan.com

Im 10 $74|2$.
10Stars is offline
Send a message via AIM to 10Stars Send a message via MSN to 10Stars
k007
BANNED
Join Date: Mar 2006
Location: bacon?
Old 10-16-2006 , 20:17   Re: Fakemeta General Usage
Reply With Quote #10

im not sure if this is the right place but is it possible somehow register a touch like in engine or something
k007 is offline
Send a message via MSN to k007
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 15:48.


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