PDA

View Full Version : [INC] Fakemeta Utilities [last update: 2007/01/08]


VEN
05-11-2006, 13:58
Using this is HIGHLY NOT RECOMMENDED!!! Stick with using Engine, Fun, CStrike, Ham, etc. They do all these functions much quicker and more efficiently. You are only teaching yourself bad coding habits by using these.


"Fakemeta Utilities" is a library of functions for the Fakemeta module. It includes:

almost all engine/fun natives (represented as a marcos/stocks)
engine's stock functions
the below custom functionsbool:fm_is_in_viewcone(index, const Float:point[3])
bool:fm_is_visible(index, const Float:point[3])
fm_set_kvd(entity, const key[], const value[], const class[] = "")
fm_find_ent_by_integer(index, pev_field, value)
fm_find_ent_by_flags(index, pev_field, flags)
Float:fm_distance_to_box(Float:point[3], Float:mins[3], Float:maxs[3])
Float:fm_boxes_distance(Float:mins1[3], Float:maxs1[3], Float:mins2[3], Float:maxs2[3])
Float:fm_distance_to_boxent(ent, boxent)
Float:fm_boxents_distance(boxent1, boxent2)
fm_get_user_weapon_entity(id, wid = 0)
fm_kill_entity(index)
bool:fm_strip_user_gun(index, wid = 0, const wname[] = "")
bool:fm_transfer_user_gun(index1, index2, wid = 0, const wname[] = "")
Float:fm_distance_to_floor(index)
bool:fm_is_ent_visible(index, entity)
fm_get_aim_origin(index, Float:origin[3])
bool:fm_get_user_longjump(index)
fm_set_user_longjump(index, bool:longjump = true, bool:tempicon = true)
bool:fm_get_user_suit(index)
fm_set_user_suit(index, bool:suit = true, bool:sound = true)
fm_cs_remove_decals(index = 0)
bool:fm_is_ent_classname(index, const classname[])
fm_user_kill(index, flag = 0)
Float:fm_get_view_angle_diff(index, const Float:point[3])
fm_get_weaponbox_type(entity)
fm_remove_weaponbox(entity)

fm_is_in_viewcone and fm_is_visible ported from HLSDK/engine module [thanks to PM for his XS Library and to Damaged Soul for the FOV dotproduct method]
fm_create_entity ported by KoST
fm_drop_to_floor, fm_remove_entity, fm_point_contents, fm_remove_entity_name ported by v3x
fm_set_kvd are based on Basic-Master's set_keyvalue
fm_distance_to_floor originally by P34nut, improved
fm_get_aim_origin ported from AMXX's core get_user_origin(..., 3) (suggested by Greenberet)
fm_user_kill ported from AMXX's core user_kill (scoreboard update fix)Feel free to contribute/suggest new functions and report any errors/issues.

Tired of fatal error 100: cannot read from file: "fakemeta_util" reports? Here is the solution for you!#tryinclude <fakemeta_util>

#if !defined _fakemeta_util_included
#assert Fakemeta Utilities function library required! Read the below instructions: \
1. Download it at forums.alliedmods.net/showthread.php?t=28284 \
2. Put it into amxmodx/scripting/include/ folder \
3. Compile this plugin locally, details: wiki.amxmodx.org/index.php/Compiling_Plugins_%28AMX_Mod_X%29 \
4. Install compiled plugin, details: wiki.amxmodx.org/index.php/Configuring_AMX_Mod_X#Installing
#endif

Note: fakemeta_util_171.zip is a version for AMX Mod X v1.71. I stopped updating this version so it is not include some new functions/cnages/fixes/etc. You can try to perform a "backward upgrade" using the regular version, but i can't guarantee a full compatibility.

Zenith77
05-11-2006, 14:56
Aren't these already amxmodx natives?

Greenberet
05-11-2006, 15:00
yes but engine module...

wouter
05-11-2006, 15:26
yes but engine module...
then why do then have to be in FM to?

v3x
05-11-2006, 15:30
For people who like to use FM instead of Engine.

Do these fm_find_ent_by functions work just like Engine's?

Zenith77
05-11-2006, 15:31
Because FM > Engine (uses less resources, but yet has more power)

wouter
05-11-2006, 15:32
Because FM > Engine (uses less resources, but yet has more power)
but i read some were that with fakemeta you can **** your server if you use it wrong...

KoST
05-11-2006, 15:38
stock fm_create_entity(const szClassname[]) {
new classname = engfunc(EngFunc_AllocString, szClassname)
new ent_id = engfunc(EngFunc_CreateNamedEntity,classname)
return ent_id
}

[edit] typ0 fixed !

Greenberet
05-11-2006, 15:39
Because FM > Engine (uses less resources, but yet has more power)
but i read some were that with fakemeta you can **** your server if you use it wrong...
well, just dont use it wrong :P

other example from the real life:
tnt: you can use it right if you use it in mines.
you can use it wrong if you use it in an war.

v3x
05-11-2006, 15:40
KoST, you have a small typo: zsClassname

KoST
05-11-2006, 15:42
thx, v3x :up: [updated]

Cheap_Suit
05-11-2006, 16:01
Nice!

organizedKaoS
05-12-2006, 03:40
So these are basically some engine functions converted to fakemeta, yes?

If so, good job. :up:

Now if only it were easier to learn how to convert all other engine funcs to fakemeta. :oops: :P

v3x
05-12-2006, 04:26
This should work. If not, lemme know:
#include <engine_const>

stock fm_drop_to_floor(entity) {
return engfunc(EngFunc_DropToFloor , entity);
}

stock fm_point_contents(const Float:point[3]) {
return engfunc(EngFunc_PointContents , point);
}

stock fm_remove_entity(entity) {
return engfunc(EngFunc_RemoveEntity , entity);
}

stock fm_remove_entity_name(const classname[]) {
new ent = -1;
while((ent = fm_find_ent_by_class(ent , classname)) != 0)
fm_remove_entity(ent);

return;
}

stock fm_find_ent_by_model(const classname[] , const model[]) {
new ent = -1;
while((ent = fm_find_ent_by_class(ent , classname)) != 0) {
new szModel[84];
pev(ent , pev_model , szModel , 83);
if(equal(model , szModel)
return ent;
}

return -1;
}

VEN
05-12-2006, 12:24
Update.

fm_find_ent_by_model(index, const class[], const model[])
fm_find_ent_in_sphere(index, const Float:origin[3], Float:radius)
fm_find_ent_by_edict(index, value, type = pev_owner)
fm_get_user_weapon_entity(index, weapon = 0)
fm_kill_entity(index)
bool:fm_strip_user_gun(index, wid = 0, const wname[] = "")

fm_strip_user_gun is a port of my strip_user_gun function (slightly modified) which uses some other fm_* functions from the list above.
You can test this and other functions using fakemeta_util_test.sma plugin which can be found at the first post of this thread.

Also i've added a fm_is_in_viewcone note and made insignificant change in this function.


Now replies.

v3x: Yes, fm_find_ent_by_* functions works not exactly but in very similar way as in engine module. And thanks for the contributions, will add that in next edition.

Greenberet: :)

Cheap_Suit: thanks!

organizedKaoS: Not only. Currently we have 2 HLSDK functions, 4 my custom functions and 4 engine-like functions.

VEN
05-14-2006, 11:38
I'm pleased to announce that the "Fakemeta Utilities" is ready to be the part of the AMXX default package! :o)

Currently nearly all what could be ported is ported from engine module to the "Fakemeta Utilities" including engine's stock functions!
Nearly all fun module natives has also been ported.
All compilation issues has also been fixed.

Also i'v done the following custom functions:bool:fm_is_in_viewcone(index, const Float:point[3])
bool:fm_is_visible(index, const Float:point[3])
fm_set_kvd(entity, const key[], const value[], const class[] = "")
fm_find_ent_by_integer(index, pev_field, value)
fm_find_ent_by_flags(index, pev_field, flags)
Float:fm_distance_to_box(Float:point[3], Float:mins[3], Float:maxs[3])
Float:fm_boxes_distance(Float:mins1[3], Float:maxs1[3], Float:mins2[3], Float:maxs2[3])
Float:fm_distance_to_boxent(ent, boxent)
Float:fm_boxents_distance(boxent1, boxent2)
fm_get_user_weapon_entity(id, wid = 0)
fm_kill_entity(index)
bool:fm_strip_user_gun(index, wid = 0, const wname[] = "")

This obviously is the last noticeable update.
But you still can contribute/suggest new functions.

Twilight Suzuka
05-14-2006, 12:23
Should use #defines, not stocks. Stocks add another function call; #define is direct sub, and thus faster.

Like this:

VEN
05-14-2006, 12:56
I think you didn't get the idea. Fakemeta Utilities is the functions which provides the "pseudo" functionality for the fakemeta module. Like engine_const does for the engine but FMU is much more functional.

Cheap_Suit
05-14-2006, 13:01
Nice!

v3x
05-14-2006, 13:18
Nice. I see that you've got a lot of them. You should add some credits for the people who have contributed :P

BAILOPAN
05-14-2006, 14:04
Nicely done.

VEN
05-14-2006, 14:33
Thanks to all for the positive replies!

v3x: of course, thanks for reminder me about that part, i've added comments for the functions which ported by you and KoST, i've decided that fm_create_entity function not that bad, also listed contributed functions in the first post.

Thanks to all who contributed to that project and feel free to contribute more! :)

Twilight Suzuka: is some of your stocks above can be considered as contribution? :P

noob cannon lol
05-14-2006, 14:49
Well, you could take some of the other functions in Engine like VelocityByAim and recreate them using stuff without fakemeta, but then you can't call it "fakemeta utilities" :P

VEN
05-15-2006, 04:45
Polished function headers + some other cosmetic changes, nothing serious.
Also implemented a tiny function + added comment that fm_set_kvd based on Basic-Master's set_keyvalue. :)

v3x
05-15-2006, 07:33
I'll sticky this until the next AMX Mod X release.

VEN
05-15-2006, 09:24
Ok, thanks, already pointed some guy to that sticky. :)

BAILOPAN
05-16-2006, 17:43
FYI, I'm going to hold off on merging this into 1.75 until the very last minute.

This will give you time to clean up anything you'd like to do.

My only suggestion is to move one line stocks into preprocessor macros (#define), as then it becomes inline expansion rather than extra instructions.

Twilight Suzuka
05-16-2006, 19:44
Thanks to all for the positive replies!

v3x: of course, thanks for reminder me about that part, i've added comments for the functions which ported by you and KoST, i've decided that fm_create_entity function not that bad, also listed contributed functions in the first post.

Thanks to all who contributed to that project and feel free to contribute more! :)

Twilight Suzuka: is some of your stocks above can be considered as contribution? :P

Use as many of them as you like.

VEN
05-17-2006, 03:45
BAILOPAN and Twilight Suzuka:

Yes i understand that macros are better because it's processed only on code compilation.
The only reason why i didn't want to use them is readability and understandability of the code.
I've decided to use macros but also leave it's commented stocks so people will have a chance to see what is the first parameter and what is the second, how it would looks as a function, et cetera.
Thanks you for your opinion.

Urahara
05-17-2006, 17:36
Ohayo VEN-san! :D

As long as the name of it is easy to understand, how the code works shouldn't matter. Transparency and encapsulation is the key. ^~

VEN
05-18-2006, 14:39
I've implemented macros + few other optimizations and minor changes, also added fm_playback_event.

Note: If you going to use FMU before 1.75 release, get hlsdk_const.inc from the CVS.

VEN
05-19-2006, 03:33
I've found and reported a bug (http://forums.alliedmods.net/showthread.php?t=28627) in the original get_entity_visibility function so FMU updated with the fixed fm_get_entity_visibility now. :-/

diamond-optic
05-22-2006, 21:46
im getting:

// D:\DoD Server\dod gameserver\dod\addons\amxmodx\scripting\inclu de\fakemeta_util.inc(240) : warning 201: redefinition of constant/macro (symbol "M_PI")

and i did get the hlsdk_const.inc Revision 1.4 off the cvs...

VEN
05-23-2006, 02:12
Comment M_PI in the FMU to avoid this warning. However it's not necessary. Compiler just warn you that you trying to redefine M_PI constant. Since in FMU M_PI declared properly you can leave it as is.

VEN
05-26-2006, 06:32
Added functionbool:fm_transfer_user_gun(index1, index2, wid = 0, const wname[] = "")which also supports CSW_C4 ("weapon_c4").

Function allows to transfer given weapon from player1 to player2.
Returns true on success, false on failure.
It's possible to specify only one of two weapon parameters.
If not specified, weapon to transfer is the player1's active weapon.

VEN
05-26-2006, 13:53
EDIT: i've decided that fm_cs_get_user_bombtarget too specific, excluded

VEN
06-03-2006, 11:42
Added new functionFloat:fm_distance_to_floor(index) // originally by P34nut, improved

Also separated FMU into two files: for AMXX <1.75 and for AMXX 1.75+
The second will be removed after AMXX 1.75 release.

v3x
06-03-2006, 14:29
Use the edit button instead of making quadruple posts.

Do not reply to this, as it is not necessary.

P34nut
06-03-2006, 14:46
Ow i like that!
btw VEN nice improvement of that stock!

VEN
06-03-2006, 15:34
P34nut: Thanks

v3x: But then no one will know that here is an update because only new post can update the time of the last post. I could delete old post and then make mixed post but then some users may be confused, anyway, thanks for the recommendation

SweatyBanana
06-03-2006, 15:47
VEN you just confused me.

Urahara
06-07-2006, 23:05
Ohayo! ^^

I am so confused @_@

Cheap_Suit
06-13-2006, 14:41
For fm_is_visible, most of the time it didnt return the fraction == 1.0 when the target is very visible.

I finally got my trace_line to work. Can you just see if its correct.
stock bool:is_user_visible(id, target)
{
new Float:myOrigin[3]
entity_get_vector(id, EV_VEC_origin, myOrigin)

new Float:fViewOfs[3]
entity_get_vector(id, EV_VEC_view_ofs, fViewOfs)

new Float:targetOrigin[3]
entity_get_vector(target, EV_VEC_origin, targetOrigin)

new Float:EyesPos[3]
xs_vec_add(myOrigin, fViewOfs, EyesPos)

new Float:hitOrigin[3]
new hitIndex = trace_line(id, EyesPos, targetOrigin, hitOrigin)

if(hitIndex == target) {
return true
}
return false
}

VEN
06-14-2006, 03:57
fm_is_visible(index, const Float:point[3])
As you can see that function checks whether given point is visible to an entity/player.
If point is an origin of the other player it's not visible because it's enclosed into the solid box.
So function works as it should work.

Your function should work for all solid target-entities except SOLID_TRIGGER.

EDIT:

I implementedbool:fm_is_ent_visible(index, entity)which compatible with all entity solidity types.
Now you can check for any entity <-> entity visiblity.

Cheap_Suit
06-14-2006, 13:49
I see. I will try this fm_is_ent_visible, thanks.

Cheap_Suit
06-14-2006, 14:22
Works like a charm!

VEN
06-21-2006, 13:47
I've made some changes.

Upgraded fm_find_ent_by_owner, JGHG's type can be passed now like for engine's find_ent_by_owner:fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0)

Upgraded fm_distance_to_floor, ignoremonsters can be passed now, since someone may consider "floor" not literally:Float:fm_distance_to_floor(index, ignoremonsters = 1)

Added fm_strip_user_weapons, which is not a direct port so there are a certain issue which isn't my or fakemeta module fault:// note: get_user_weapon will still return former weapon index
fm_strip_user_weapons(index)

In version for AMXX 1.75+ excluded fm_velocity_by_aim, fm_vector_to_angle, fm_angle_vector, fm_vector_length, fm_vector_distance since it's original engine's functions have been moved to the AMXX core.

Hell Phoenix
07-05-2006, 16:13
I see this didnt make it into amxx 1.75...thats too bad. Which inc file is the correct one on the first page? There are 2 of them and they are different sizes. Thanks for the hard work on this...Its awesome!

diamond-optic
07-05-2006, 19:27
not totally sure... but i think it might be the 1st one.. as the 2nd include file has comments like

//! should be uncommented for 1.75

or

#define M_PI 3.14159265358979323846 //! should be removed for 1.75


and in the 1st one those are gone...

Hell Phoenix
07-06-2006, 10:01
Good catch...I totally missed that somehow. Thanks Diamond =D

VEN
07-06-2006, 15:29
I see this didnt make it into amxx 1.75...thats too badProbably they forgot to include it to the package or maybe don't want to do that anymore.
Which inc file is the correct one on the first page? There are 2 of them and they are different sizes.In the old forums attachments had the different comments, now it's a bit complicated to distinguish versions but i can say that file with the lower size is for 1.75+ since some of the engine's functions moved to the core in 1.75.
Thanks for the hard work on this...Its awesome!I'm glad you like it, thanks!

Hawk552
07-22-2006, 12:40
I needed this so I thought I'd post it, I don't really care whether you want to add it or not:


stock fm_give_item(id,Item[])
{
if(containi(Item,"item_") == -1 && containi(Item,"weapon_") == -1 && containi(Item,"ammo_") == -1 && containi(Item,"tf_weapon_") == -1)
return 0

new Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, Item)),Float:vOrigin[3]

if(!pev_valid(Ent))
return 0

pev(id,pev_origin,vOrigin)
set_pev(Ent,pev_origin,vOrigin)

set_pev(Ent,pev_spawnflags,pev(Ent,pev_spawnf lags)|(1<<30))

dllfunc(DLLFunc_Spawn,Ent)

new Solid = pev(Ent,pev_solid)

dllfunc(DLLFunc_Touch,Ent,id)

if(pev(Ent,pev_solid) == Solid)
engfunc(EngFunc_RemoveEntity,Ent)

return 1
}

Greenberet
07-23-2006, 05:15
here is an function to get the aim origin, i know you could use get_user_origin but you get int's there so here you are
stock UTIL_GetAimOrigin( Client, Float:retOrigin[3] )
{
static Float:origin[3], Float:vec[3], Float:angles[3];
if( !pev_valid( Client ) )
return 0;

pev( Client, pev_origin, origin );
pev( Client, pev_view_ofs, vec );

xs_vec_add( origin, vec, retOrigin );

pev( Client, pev_angles, angles );

engfunc( EngFunc_AngleVectors, angles, vec, origin, origin );
xs_vec_mul_scalar( vec, 9999.0, vec );
xs_vec_add( vec, retOrigin, angles );

fm_trace_line( Client, retOrigin, angles, retOrigin );

return 1;
}

VEN
07-23-2006, 08:52
Hawk552: FMU already contain fm_give_item function, but thanks anyway.
Greenberet: true, plus someone will prefer to be more precise rather than doing float(int), thanks for the contribution.
Also P34nut have ported radius damage function from the engine, will add them both.

Hawk552
07-23-2006, 10:23
Hawk552: FMU already contain fm_give_item function, but thanks anyway.
Greenberet: true, plus someone will prefer to be more precise rather than doing float(int), thanks for the contribution.
Also P34nut have ported radius damage function from the engine, will add them both.
Where, I didn't see it 0_o

EDIT: Ugh, I see it now, sorry.

VEN
07-23-2006, 13:23
Greenberet: we shouldn't check for entity/player validity, this rather should be done outside the function to potentially increase efficiency.

Also not pev_angles but pev_v_angle.
Here is what i've done.

// idea by Greenberet
stock fm_get_aim_origin(index, Float:origin[3]) {
new Float:start[3], Float:view_ofs[3]
pev(index, pev_origin, start)
pev(index, pev_view_ofs, view_ofs)
xs_vec_add(start, view_ofs, start)

new Float:dest[3]
pev(index, pev_v_angle, dest)
engfunc(EngFunc_MakeVectors, dest)
global_get(glb_v_forward, dest)
xs_vec_mul_scalar(dest, 9999.0, dest)
xs_vec_add(start, dest, dest)

engfunc(EngFunc_TraceLine, start, dest, 0, index)
global_get(glb_trace_endpos, origin)
}

VEN
08-28-2006, 05:10
As i said above:In the old forums attachments had the different comments, now it's a bit complicated to distinguish versions but i can say that file with the lower size is for 1.75+ since some of the engine's functions moved to the core in 1.75.

Also make sure that you have the line on the top of your code:
#include <fakemeta_util>


It probably may help if you post the exact text of the error message.

VEN
08-28-2006, 06:20
Seems like you do not have the file
addons\amxmodx\scripting\include\fakemeta_uti l.inc
on your computer.

VEN
08-28-2006, 09:11
Yes of course, you should put it to the
addons\amxmodx\scripting\include\ folder.

VEN
08-29-2006, 13:32
Did you get fakemeta_util.inc with the size of 21.2 KB?
Did you putaddons\amxmodx\scripting\include\fakemeta_ util.incon your PC?
Do you have #include <fakemeta_util> on top of the code of the plugin?
Did you put your plugin in addons\amxmodx\scripting\include on your PC?
Did you run addons\amxmodx\scripting\include\compile.exe on your PC?
Is version of addons\amxmodx\scripting\include\compile.exe on your PC 1.75?

VEN
08-29-2006, 14:26
can you tell me the params for fm_strip_user_gun
bool:fm_strip_user_gun(index, wid = 0, const wname[] = "") First is a player index. Second and third are optional. wid is the weapon index, wname is the weapon name, only one actually needed and if not specified, the current gun will be stripped.


what weapon constants does it use ?http://www.amxmodx.org/funcwiki.php?go=module&id=4#const_cswp


you should right a tutoriol on themI do not really think so. Plugin coders able to just read the source code of the Fakemeta Utilities function to understand how it works. It's much better that any tutorial in my opinion.

VEN
08-29-2006, 16:58
fm_strip_user_gun(id ,CSW_GLOCK18) is fine but as i said here (http://forums.alliedmods.net/showthread.php?p=374120#post374120)

you should also understand that player doesn't have any waeapons on HUD reset yet. So you have to use a bit of delay. I mentioned this in my tutorial but you probably didn't noticed. Next time please read more carefully


Also you should note that CSW constant is only for CS.

So for example for Half-Life itself you would use

#define WEAPON_CROWBAR 1
#define WEAPON_GLOCK 2
#define WEAPON_PYTHON 3
#define WEAPON_MP5 4
#define WEAPON_CHAINGUN 5
#define WEAPON_CROSSBOW 6
#define WEAPON_SHOTGUN 7
#define WEAPON_RPG 8
#define WEAPON_GAUSS 9
#define WEAPON_EGON 10
#define WEAPON_HORNETGUN 11
#define WEAPON_HANDGRENADE 12
#define WEAPON_TRIPMINE 13
#define WEAPON_SATCHEL 14
#define WEAPON_SNARK 15


Of course for the different mods weapon constants is different.

Also to get the weapon name you have to use get_weaponname (http://www.amxmodx.org/funcwiki.php?search=get_weaponname&go=search)

To do backward action, i.e. get the weapon index from the weapon name you will have to use get_weaponid (http://www.amxmodx.org/funcwiki.php?search=
get_weaponid&go=search)

Example: server_print("weapon_usp ID is %d", get_weaponid("weapon_usp"))

VEN
08-30-2006, 20:44
pevs entity variables holds entity properties and the armor one of such things.
Also should be fm_set_user_armor (id , 200), integer value, it's floated by the stock function, that is a direct port of the set_user_armor from the fun module.

Ingram
08-31-2006, 07:21
Just so you know, theres a few mistakes. I tried to point this out for engine, but no one listened. So if your going to argue, I don't care, just don't put them in.

The way to find the origin of an ent is:
new Float:orig [3], Float:mins [3], Float:maxs[3]
entity_get_vector(ent, EV_VEC_origin, orig)
entity_get_vector(ent, EV_VEC_mins, mins)
entity_get_vector(ent, EV_VEC_maxs, maxs)
for(new i = 0; i < 3; i++)
origin [i] = (mins[i] + maxs[i]) / 2 + orig [i]

return origin[0] && origin[1] && origin[2]
Without considering the mins and maxs, you don't allow for most ents that the map puts in. Without adding the origin, you don't allow for other ents the map puts in, players or ents plugins put in. Without doing them both together you don't allow for ents that have moved.
fm_entity_range will only work for some ents the map puts in, players, and ents plugins put in.
fm_get_brush_entity_origin will not work for an ent that has been moved or an ent that plugins create.

Also, in fm_entity_set_origin, what is the point of setting the size?

VEN
08-31-2006, 07:58
Update
Fixed fm_set_user_frags
Improved fm_strip_user_gun
Added fm_get_aim_origin
Excluded the version for 1.71<=AMXX<1.75 (PM me if you need).

JJkiller: the functions you mentioned is a direct port of the corresponding engine natives, i will not fix/change them for the sake of the backward compatibility.

VEN
08-31-2006, 10:54
Changed weaponbox+weapon_entity deletion method for the better/standard one.

Before: fm_kill_entity(ent_box)
fm_kill_entity(ent_weap)
Now: dllfunc(DLLFunc_Think, ent_box)


Technically Think force is the same as changing nextthink to the current time, more info is here: http://forums.alliedmods.net/showthread.php?p=373709#post373709

VEN
08-31-2006, 12:30
As i said i Excluded the version for 1.71<=AMXX<1.75If you really do not wish to upgrade your AMXX to the latest version and want the older FM utilities, tell me.

Edit: added zip file for 1.71<=AMXX<1.75

SweatyBanana
08-31-2006, 22:29
Did you respond to yourself like 5 times?

Hawk552
08-31-2006, 22:48
Did you respond to yourself like 5 times?

LOL, I think it was Raphero, whos posts were BALEETED.

SweatyBanana
08-31-2006, 22:51
Oh that makes perfect sense..

Dancing Bread
09-01-2006, 03:11
ahhaha yeah it was delted . and no thats cool thanks VEN . I think the update is better . I ll use it on my mod :)

Dancing Bread
09-02-2006, 07:21
Ok VEN I have a new problem :cry: I liked this util pack so much i was switching over functions from other modules(plugins), I was switching the fun fucntions i had . and i went to compile it and it wont let me use the

fm_set_user_rendering(id)


It says that it is undefined symbol . but when i had

fm_set_rendering(id)


it would compile . I was wondering if that is a valid way to do it ? If so ill switch it back to the fm_set_user_rendering
thanks VEN!:up:



EDIT : ALSO VEN , I was wondering if you could port

set_user_footsteps(index , <0|1>) //// 0 is normal 1 is silent

becasue this is the only fucntion left from FUN thats you hadnt ported to the util yet . I wanted to use only fakemeta_util instead of a bunch of dif modules
:cry:

VEN
09-02-2006, 12:35
fm_set_user_rendering and fm_set_rendering is absolutely the same functions
fm_set_user_rendering was represented as a macro that redirect call to the fm_set_rendering. The problem was that the macro doesn't support optional parameters. So when not all parameters is passed macro wasn't recognized. I solved this by converting macro into the stock function.

I didn't included footsteps functions because it can't be stored into the single function. Just paste the code below into your plugin and then use fm_set_user_footsteps and fm_get_user_footsteps functions, the functionality is the same.

#define STANDARDTIMESTEPSOUND 400
new bool:g_silent[33]

fm_set_user_footsteps(index, set = 1) {
if (set) {
set_pev(index, pev_flTimeStepSound, 999)
g_silent[index] = true
}
else {
set_pev(index, pev_flTimeStepSound, STANDARDTIMESTEPSOUND)
g_silent[index] = false
}

return 1
}

fm_get_user_footsteps(index) {
return g_silent[index]
}

public plugin_init() {
register_forward(FM_PlayerPreThink, "forward_player_prethink")
}

public forward_player_prethink(index) {
if (g_silent[index])
set_pev(index, pev_flTimeStepSound, 999)
}

public client_disconnect(index) {
g_silent[index] = false
}

Dancing Bread
09-02-2006, 13:55
sweeet . your the best VEN! now i can drop the fun module from my code completly and just use the fm_util GJ! :up: +karma

Dancing Bread
09-03-2006, 20:15
hey can you show me how to set_user_money to 0 using the fakemeta util ?this will let me remove cstrike form my code too . im trying to optimize my code by cutting out as many modules as posable.
thanks ven :)

Hawk552
09-03-2006, 20:24
hey can you show me how to set_user_money to 0 using the fakemeta util ?this will let me remove cstrike form my code too . im trying to optimize my code by cutting out as many modules as posable.
thanks ven :)

Taking out as many modules as possible doesn't optimize it. Can you know what modules the user will be running?

Dancing Bread
09-03-2006, 20:29
ok but if my plugin has to call to that module , it will be more of a load then if it didnt call to the module , wether the user is using it or not .

VEN
09-04-2006, 02:46
You can change the user money with the fakemeta with near the same efficiency, look into my "Buy a Helmet" plugin.
(note: don't afraid large block of defines, it's preprocessed so it will not affect on performance).

Dancing Bread
09-04-2006, 03:36
ok well can you tell me who is right , me or Hawk? its more of a load for a plugin to call to a module if tis not necesary right ? so by cutting out other modules im optimizing my script , and cutting down on some possable lag .

VEN
09-04-2006, 04:14
In the whole it's a complicated question. For example with the short functions like fm_set_user_gravity FMU is the winner over FUN because efficiency is the same but FUN has an internal forward hooks for some of his natives which slows module down. The same goes for Cstrike. It may be not a bad idea to use FM instead of Cstrike to change some of the player private properties like money, deaths, ammo etc. But for most coders it doesn't worth to port such natives to the FM.

By disabling modules you can't optimize your script. You can increase AMXX runtime performance. But again if you are not understand what would be more efficient in the different situations you probably shouldn't blindly use FM instead of bunch of other modules. So Hawk's "hint" was reasoned.

Also not the last role play the fact of how often you call your function. So for example if you create some armoury entities only at the map startup, you shouldn't bother that fm_set_kvd is a bit slover than DispatchSpawn.

In the most cases using FMU will not hit the performance so you shouldn't bother, but you should also undersant what you are doing.

watch
09-04-2006, 17:29
L 09/04/2006 - 22:22:51: [FAKEMETA] Invalid return type
L 09/04/2006 - 22:22:51: [AMXX] Displaying debug trace (plugin "entbug.amxx")
L 09/04/2006 - 22:22:51: [AMXX] Run time error 10: native error (native "global_get")
L 09/04/2006 - 22:22:51: [AMXX] [0] fakemeta_util.inc::fm_trace_hull (line 169)
L 09/04/2006 - 22:22:51: [AMXX] [1] entbug.sma::origin_forward (line 24)
^^
Just wondering if im using this right, or is it a bug with fm_trace_hull as it works fine with engine :O

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fakemeta_util>
//#include <engine>

#define PLUGIN "anti-nailbug"
#define VERSION "1.0"
#define AUTHOR "watch"

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward(FM_SetOrigin, "origin_forward")
}

public origin_forward(ent, Float:origin[3])
{
new classname[32]
pev(ent, pev_classname, classname, 31)

if (equal(classname, "tf_weapon_nailgrenade"))
if (fm_trace_hull(origin, HULL_HEAD, pev(ent, pev_owner))) //if (trace_hull(origin, HULL_HEAD, pev(ent, pev_owner)))
return FMRES_SUPERCEDE

return FMRES_IGNORED
}

VEN
09-05-2006, 05:56
UpdateFixed fm_trace_hull (thanks watch)
Improved/fixed fm_trace_normal

k007
10-08-2006, 20:30
realy awesome VEN, i didn't see this thread till yesterday when teame06 told me about it realy nice work

VEN
11-06-2006, 13:33
Update - added:bool:fm_get_user_longjump(index)
fm_set_user_longjump(index, bool:longjump = true, bool:tempicon = true)
bool:fm_get_user_suit(index)
fm_set_user_suit(index, bool:suit = true, bool:sound = true)
fm_cs_remove_decals(index = 0)

Brad
11-06-2006, 13:43
I don't understand what fm_get_user_longjump returns.

VEN
11-06-2006, 14:09
true if the given player has longjump and false otherwise.

Brad
11-06-2006, 15:21
No, I mean I don't understand what "longjump" is.

organizedKaoS
11-06-2006, 15:24
No, I mean I don't understand what "longjump" is.


From halflife.

It is possible to give a player in cs longjump with the function
give_item(id, "item_longjump")

It is what its called...longjump.

While running, press crouch and jump to do a jump that propels you forward.

:up:

VEN
11-06-2006, 15:24
Longjump is an HL item. It allow to jump on the long distance.

It is possible to give a player in cs longjump with the function
It's just a workaround while the above functions operate with the slj data directly and able to get/set/unset it, also more efficient.

The Specialist
11-06-2006, 16:37
No, I mean I don't understand what "longjump" is.

Thank god im not the only one :wink:

VEN
11-08-2006, 11:57
The function gets what weapon type (CSW_*) a "grenade" entity is.
"grenade" entity is either the throwed grenade or the planted C4.

Returns 0 on failure. Win32 only. Provided as is (no warranties).
It's similar to the cs_get_armoury_type which work for "armoury_entity".

This function are useful because the old model check method aren't practical.
1. The model could be changed to the custom one by the 3rd party addon.
2. There are the moments when the grenade doesn't have the model (on explosion).

You shouldn't use the offsets and it's values for altering the grenade type.
This is not the data which controls the actual type, neither i think it's possible
to alter the type that way.

I'm not including this to the fakemeta_util.inc at least because it's win32 only.
I do realise that there are probably the more evident way but at least this work.
If you think something is incorrect or needs to be improved, feel free to post.
stock fm_cs_get_grenade_type(index) {
// you can comment/remove this
// if you are sure that the entity
// with the given index are valid
if (!pev_valid(index))
return 0

// you can comment/remove this
// if you are sure that the entity
// with the given index are "grenade"
new classname[9]
pev(index, pev_classname, classname, 8)
if (!equal(classname, "grenade"))
return 0

if (get_pdata_int(index, 96) & (1<<8))
return CSW_C4

new bits = get_pdata_int(index, 114)
if (bits & (1<<0))
return CSW_HEGRENADE
else if (bits & (1<<1))
return CSW_SMOKEGRENADE
else if (!bits)
return CSW_FLASHBANG

return 0
}

Rolnaaba
11-08-2006, 12:08
VEN you make me happy for making this :D

The Specialist
11-09-2006, 07:16
me too , but BAILOPAN needs to include it into the fakemeta package already :up:

VEN
11-23-2006, 05:21
Update. Added two functions:bool:fm_is_ent_classname(index, const classname[])
fm_user_kill(index, flag = 0)

The first one is especially handy for example in Touch forward. Compare:public forward_touch(ent1, ent2) {
if (!pev_valid(ent1))
return FMRES_IGNORED

new class[32]
pev(ent1, pev_classname, class, sizeof class - 1)
if (!equal(class, "myclass"))
return FMRES_IGNORED

// ...
}andpublic forward_touch(ent1, ent2) {
if (!fm_is_ent_classname(ent1, "myclass"))
return FMRES_IGNORED

// ...
}

The second one is the same as core's user_kill but updates scoreboard immediately if flag is set to 1, while the original user_kill sets --fargs and update the scoreboard only after next respawn.

The Specialist
11-27-2006, 14:48
I dont see any way to get an entitys origin with this . Can you add some please :up:

k007
11-27-2006, 23:30
new Origin[3]
pev(index, pev_origin, Float:Origin)
?

VEN
11-28-2006, 02:33
I will not add engine's pev wrappers, it will just complicate its usage, use pev/set_pev natives as shown in the above post.

diamond-optic
12-01-2006, 00:26
nice little update ven

The Specialist
12-21-2006, 20:29
I wanted to know if you could port cs_set_user_model() please. Or tell me where I can find the source code for that function and possabily port it my self . :|

jim_yang
12-21-2006, 23:34
I wanted to know if you could port cs_set_user_model() please. Or tell me where I can find the source code for that function and possabily port it my self . :|
if you play cs, then use module cstrike.

The Specialist
12-22-2006, 02:45
Yes , but im not a big fan of other modules . Almost all the cs_ functions have been ported by VEN . So my question was could he port this one:)

jim_yang
12-22-2006, 02:59
cs_set_user_model is not a single function just like set_user_footsteps in fun module, so VEN won't port this one to fmu.

The Specialist
12-22-2006, 03:05
:cry:

Alka
12-28-2006, 06:09
how to install this ? I put the .inc in the include folder but the content of the arhive? 10x thx!

VEN
12-29-2006, 12:19
For the latest AMXX version use the attached *.inc
Put it into amxmodx/scripting/include.

VEN
01-05-2007, 18:11
This is mainly a "cleaning"/"polishing" update:

excluded: fm_make_deathmsg, fm_dod_make_deathmsg, fm_user_silentkill, fm_IVecFVec, fm_FVecIVec (see message_stocks.inc and vector.inc for orginal functions)
fm_is_visible and fm_is_ent_visible is accept optional ignoremonsters == 0 parameter now
all trace functions is use a data from the TraceResult structure now
numerous minor optimizations/improvements/etc


Also reorganized the topic and added a note about backward compatibility.

SAMURAI16
01-07-2007, 08:40
i saw on "fm_is_ent_visible" function ignoremonsters == 0 . What mean that ? and for what is it ?

VEN
01-07-2007, 09:43
This is an option that allow to ignore or not ignore the monsters by the trace. "Monsters" are usually all human-like entities, i.e. players/bots/hostages/monsters et cetera.

VEN
01-08-2007, 13:02
Added new functions:// returns a degree angle between player-to-point and player's view vectors
stock Float:fm_get_view_angle_diff(index, const Float:point[3])
// gets a weapon type of the linked to weaponbox weapon_* entity
stock fm_get_weaponbox_type(entity)
// safe removal of weaponbox+weapon_* entity pair (delay =~= 0.03 second)
#define fm_remove_weaponbox(%1) dllfunc(DLLFunc_Think, %1)
/* stock fm_remove_weaponbox(entity) */

Added/updated a few notes for existing functions:// ... accepts an optional classname (a bit more efficient if it is passed)
stock fm_set_kvd(entity, const key[], const value[], const classname[] = "")
// potential to crash (?) if used on weaponbox+weapon_* entity pair (use fm_remove_weaponbox instead)
stock fm_kill_entity(index)
//
// if weapon index isn't passed then assuming that it's the current weapon
stock fm_get_user_weapon_entity(id, wid = 0)
//
// only weapon index or its name can be passed, if neither is passed then the current gun will be stripped
stock bool:fm_strip_user_gun(index, wid = 0, const wname[] = "")
//
// only weapon index or its name can be passed, if neither is passed then the current gun will be transferred
stock bool:fm_transfer_user_gun(index1, index2, wid = 0, const wname[] = "")
//
// the same as AMXX's core user_kill but fixes the issue when the scoreboard doesn't update immediately if flag is set to 1
stock fm_user_kill(index, flag = 0)
//

Rolnaaba
01-09-2007, 12:47
why does the topic name say [last update: 07/01/08]? July 1st, 2008 hasnt happend yet lol...

teame06
01-09-2007, 13:16
It probably means [Year/Month/Date]

VEN
01-09-2007, 13:32
Date formats vary according to culture and nation. While the format month day/year is common in the United States of America, European countries often use the day/month/year format, and technical publications sometimes standardize on the year/month/day format (ISO/IEC 8824).I've decided to use the last one as a compromise format.

Rolnaaba
01-09-2007, 13:52
ahh ok ty

[DOM]Chaos
01-17-2007, 16:48
I am trying to compile the gungame.sma. The web page compiler does not work. There is a link from the gungame mod to this page for compiling however there is no istructions that I can find that tells me how to use this utility to compile a sma file. Anyone have any suggestions?

Emp`
01-17-2007, 18:56
Chaos;428519']I am trying to compile the gungame.sma. The web page compiler does not work. There is a link from the gungame mod to this page for compiling however there is no istructions that I can find that tells me how to use this utility to compile a sma file. Anyone have any suggestions?

Add the fakemeta_util.inc to your scripting/include folder. You should be able to compile now.

[DOM]Chaos
01-17-2007, 19:08
OK so I added the hlsdk_const.inc and fakemeta_util.inc to my
/czero/addons/amxmodx/scripting/include file

how do I compile my sma file into a amxx?

Sorry for my ignorance I just could not find instructions on using this utlility in the 11 pages of the post

Emp`
01-17-2007, 19:58
http://wiki.amxmodx.org/index.php/Compiling_Plugins_%28AMX_Mod_X%29

[DOM]Chaos
01-17-2007, 20:08
perfect that is what I was looking for Emp' thanks :up:

Cheap_Suit
01-18-2007, 00:03
Will you add VelocityByAim from engine? ...Or an code sample will do fine.

Emp`
01-18-2007, 00:10
velocity_by_aim

VEN
01-18-2007, 03:25
Will you add VelocityByAim from engine? ...Or an code sample will do fine.Are you requesting velocity_by_aim wrapper?

Cheap_Suit
01-18-2007, 14:57
No, I just didnt see that. Thnx anyways

VEN
03-21-2007, 03:24
Tired of fatal error 100: cannot read from file: "fakemeta_util" reports? Here is the solution for you!
#tryinclude <fakemeta_util>

#if !defined _fakemeta_util_included
#assert Fakemeta Utilities function library required! Read the below instructions: \
1. Download it at forums.alliedmods.net/showthread.php?t=28284 \
2. Put it into amxmodx/scripting/include/ folder \
3. Compile this plugin locally, details: wiki.amxmodx.org/index.php/Compiling_Plugins_%28AMX_Mod_X%29 \
4. Install compiled plugin, details: wiki.amxmodx.org/index.php/Configuring_AMX_Mod_X#Installing
#endif

Rolnaaba
03-21-2007, 08:35
nice!

SAMURAI16
04-01-2007, 09:31
ops, my fault

VEN
04-01-2007, 10:29
Is it a joke? It's already here, line #331.

3sky
05-03-2007, 00:04
i can't buy revivalkit in the game buyzone....
it's alway said "You need to be in the buyzone."
i wanna ask ...where is the buyzone...??

how to fix the code that on everywhere can buy revivalkit?

VEN
05-03-2007, 05:17
Your question isn't related to this thread at all. I already replied to you in corresponding thread.

Rolnaaba
06-11-2007, 10:28
Cheap Suit made this but I think it should be in your fakemeta_Util, if it was then AlliedModders would have one less thread lol:
stock fm_find_sphere_class(aroundent, const _lookforclassname[], Float:radius, entlist[], maxents, const Float:_origin[3]) {
static Float:origin[3]
if(!pev_valid(aroundent)) {
origin[0] = _origin[0]
origin[1] = _origin[1]
origin[2] = _origin[2]
} else pev(aroundent, pev_origin, origin)

new ent = 0, foundents = 0
while((ent = engfunc(EngFunc_FindEntityInSphere, aroundent, origin, radius)) != 0) {
if(!pev_valid(ent))
continue

if(foundents >= maxents)
break

static classname[32]
pev(ent, pev_classname, classname, 31)

if(equal(classname, _lookforclassname))
entlist[foundents++] = ent
}
return foundents
}

potatis_invalido
07-25-2007, 00:12
I think this inc should be included in the AMXX package.
It's extremly well written and contains a lot of usefull bananas.

Mini_Midget
09-03-2007, 02:45
Is it possible to convert
get_user_hitzones
set_user_hitzones

Would be a lot easier for me as I'm having some difficulties with traceline.

Also, what would be the same to this
entity_set_vector(id, EV_VEC_punchangle, ViewAngle)

I'm trying to make this stock (by Cheap_Suit) into fakemeta as well

stock Punch_View(id, Float:ViewAngle[3])
{
entity_set_vector(id, EV_VEC_punchangle, ViewAngle)
}

Greenberet
09-03-2007, 03:07
Is it possible to convert
get_user_hitzones
set_user_hitzones

Would be a lot easier for me as I'm having some difficulties with traceline.

Also, what would be the same to this
entity_set_vector(id, EV_VEC_punchangle, ViewAngle)

I'm trying to make this stock (by Cheap_Suit) into fakemeta as well

stock Punch_View(id, Float:ViewAngle[3])
{
entity_set_vector(id, EV_VEC_punchangle, ViewAngle)
}



stock Punch_View(id, Float:ViewAngle[3])
{
set_pev( id, pev_punchangle, viewAngle );
}

VEN
09-03-2007, 11:47
Is it possible to convert
get_user_hitzones
set_user_hitzonesIt wouldn't feet into design of FMU which is a stocks/macros library. The similar thing was related to fun's footsteps functions, see http://forums.alliedmods.net/showpost.php?p=376608&postcount=73 for details.

Emp`
01-26-2008, 00:30
/* As above, but returns number of ents stored in entlist. Use to find a specific type of entity classname (specify in _classname) around a
* certain entity specified in ent. All matching ents are stored in entlist. Specify max amount of entities to find in maxents.
* If ent is 0 its origin is not used, but origin in 6th parameter. Ie, do not specify 6th parameter (origin) if you specified an entity
* in ent.
*/
stock fm_find_sphere_class(ent, const _classname[], Float:radius, entlist[], maxents, Float:origin[3]={0.0,0.0,0.0})
{
if( pev_valid(ent) )
pev( ent, pev_origin, origin );
new tempent, tempclass[32], entsfound;
while( (tempent = fm_find_ent_in_sphere(tempent, origin, radius) ) && entsfound < maxents )
{
if( _classname[0] ){
pev(tempent, pev_classname, tempclass, 31);
if( !equal( _classname, tempclass ) )
continue;
}
entlist[entsfound++] = tempent;
}
return entsfound;
}

PrEn1umz
02-14-2008, 07:44
Hi everyone,
Do you think this one could be added to fakemeta_util


#define fm_get_user_origin(%1, %2) pev(%1, pev_origin, %2)


Maybe it's a bit useless because there is already a way to get user's origin with fakemeta so tell me what u think about it.

PS: sorry for my bad english

ConnorMcLeod
02-14-2008, 07:51
This is not very usefull, but here's the code (doesn't support mode = 4, and origin is a float, not an interger) :

fm_get_user_origin(id, Float:origin[3], mode=0)
{
static Float:start[3]
pev(id, pev_origin, start)
if(!mode)
{
xs_vec_copy(start, origin)
return 1
}

if(mode && mode !=2)
{
static Float:view_ofs[3]
pev(id, pev_view_ofs, view_ofs)
xs_vec_add(start, view_ofs, start)
if(mode == 1)
{
xs_vec_copy(start, origin)
return 1
}
}

if(mode > 1)
{
static Float:dest[3]
pev(id, pev_v_angle, dest)
engfunc(EngFunc_MakeVectors, dest)
global_get(glb_v_forward, dest)
xs_vec_mul_scalar(dest, 9999.0, dest)
xs_vec_add(start, dest, dest)
engfunc(EngFunc_TraceLine, start, dest, 0, id, 0)
get_tr2(0, TR_vecEndPos, origin)
}
return 1
}

SAMURAI16
02-15-2008, 14:15
@Mini_Midget: Here is get_user_hitzones and set_user_hitzones ported to Fakemeta
Now are fm_get_user_hitzones and fm_set_user_hitzones

Mini_Midget
02-18-2008, 01:38
Would this also fit with the rest?


#define fm_set_lights(%1) engfunc(EngFunc_LghtStlye, 0, %1)
/* stock fm_set_lights(const Lighting[])
return engfunc(EngFunc_LightStyle, 0, Lighting) */


Just one question with that though. Whats with the 0 in EngFunc_LightStyle?

Oh and thanks SAMURAI16
I'll keep it for reference as I don't need it anymore.

Arkshine
02-18-2008, 01:56
I believe the lighting time. Higher is the number, faster is the lighting.

VEN
02-19-2008, 10:23
It's the light style. 0 - normal (see HLSDK for more info).
Mini_Midget, your port are incorrect. See engine.cpp for details.

Arkshine
02-19-2008, 11:42
That ?

0 - Normal
1 - Flicker (first variety)
2 - Slow strong pulse
3 - Candle (first variety)
4 - Fast strobe
5 - Gentle pulse 1
6 - Flicker (second variety)
7 - Candle (second variety)
8 - Candle (third variety)
9 - Slow strobe (fourth variety)
10 - Fluorescent flicker
11 - Slow pulse not fade to black
12 - Underwater light mutation

( world.cpp )

Alka
02-19-2008, 11:58
Good to know.

v3x
04-02-2008, 04:48
long jump natives aren't in there.

VEN
04-02-2008, 13:23
Did you mean stocks fm_*et_user_longjump()?
If so then here it is: http://forums.alliedmods.net/attachment.php?attachmentid=12081&d=1168279085 (lines #744 ... #772).

mariosimpson
06-26-2008, 10:40
I am having trouble installing this, Can some one walk me through it in a list of steps?

VEN
07-20-2008, 06:36
Download .inc file and place it in your .\amxmodx\scripting\include\ folder.

anakin_cstrike
10-18-2008, 10:15
I like get_grenade_type and fm_transfer_user_gun :D
This is very nice, GJ!

zssz
10-22-2008, 18:25
Hmm, what about fm_get_user_noclip?
Doesn't seem to work. (Yes I know it's commented out in the .inc)

Are there any plans to make it work?

Alka
10-23-2008, 01:02
Hmm ?! It's commenetd the stock func, but is defined as a macro...#define fm_get_user_noclip(%1) pev()... works just fine.

zssz
10-23-2008, 01:05
Hmm, I've tried it and it didn't work for me. Let me try it again and see if it works...

Bugsy
10-29-2008, 01:22
@Mini_Midget: Here is get_user_hitzones and set_user_hitzones ported to Fakemeta
Now are fm_get_user_hitzones and fm_set_user_hitzones

I get this error with your hitzone code:

Line 1062 = if( pev(hit,pev_flags) & (FL_CLIENT | FL_FAKECLIENT) && shooter


L 10/28/2008 - 23:44:38: [FAKEMETA] Invalid entity
L 10/28/2008 - 23:44:38: [AMXX] Displaying debug trace (plugin "aimbotdetect.amxx")
L 10/28/2008 - 23:44:38: [AMXX] Run time error 10: native error (native "pev")
L 10/28/2008 - 23:44:38: [AMXX] [0] aimbotdetect.sma::fw_traceline (line 1062)

ConnorMcLeod
10-29-2008, 01:33
Replace pev(hit,pev_flags) & (FL_CLIENT | FL_FAKECLIENT) with 1 <= id <= maxplayers

Bugsy
11-01-2008, 14:24
Replace pev(hit,pev_flags) & (FL_CLIENT | FL_FAKECLIENT) with 1 <= id <= maxplayers

Now I am getting index out of bounds

L 11/01/2008 - 14:23:06: [AMXX] Displaying debug trace (plugin "aimbotdetect.amxx")
L 11/01/2008 - 14:23:06: [AMXX] Run time error 4: index out of bounds
L 11/01/2008 - 14:23:06: [AMXX] [0] aimbotdetect.sma::fw_traceline (line 1093)

Line 1093:
if( !(g_bodyhits[shooter][hit] & 1<<hitGroup) )


public fw_traceline(Float:v1[3], Float:v2[3], NoMonsters, shooter, ptr)
{
if(!shooter) return FMRES_IGNORED;

new hit = get_tr2(ptr,TR_pHit);

if( (1 <= shooter <= g_MaxPlayers) && (pev(shooter,pev_flags) & (FL_CLIENT | FL_FAKECLIENT)) )
{
new hitGroup = get_tr2(ptr,TR_iHitgroup);

if( !(g_bodyhits[shooter][hit] & 1<<hitGroup) )
set_tr2(ptr,TR_flFraction,1.0);
}

return FMRES_IGNORED;
}

Arkshine
11-01-2008, 14:37
TR_pHit returns -1 if there is no entity ( wordspawn ).

You have probably to check hit, too.

ConnorMcLeod
11-03-2008, 03:07
public fw_traceline(Float:v1[3], Float:v2[3], NoMonsters, shooter, ptr)
{
if( NoMonsters || !( 1 <= shooter <= g_iMaxPlayers) )
return FMRES_IGNORED;

new hit = get_tr2(ptr,TR_pHit);
if( 1 <= hit <= g_iMaxPlayers )
{
if( !( g_bodyhits[shooter][hit] & (1<<get_tr2(ptr,TR_iHitgroup)) ) )
{
set_tr2(ptr,TR_flFraction,1.0);
return FMRES_SUPERCEDE;
}
}
return FMRES_IGNORED;
}

AcidoX
11-10-2008, 19:16
Any news about fakemeta_util updates? :)

Alka
11-11-2008, 06:50
Any news about fakemeta_util updates? :)
for what? >_>

AcidoX
11-20-2008, 10:18
Well, more functions from fun, engine and other :)

danielkza
11-20-2008, 11:04
Well, more functions from fun, engine and other :)
What ones do you need? At least 90% of the most used ones are covered, and the rest can be easily emulated with a few lines of code.

SchlumPF*
11-21-2008, 03:18
the cstrike natives should be converted and added too :P

Alka
11-21-2008, 07:23
It's almost the same thing, but you call them direcly, not through an .dll. Also open cstrike.h, get all the offest and make your own include, or ask connorr.

Hi connorr.

SchlumPF*
11-21-2008, 10:41
i know that and i managed yet to convert all native i need on my own but could be nice to add those to fm_util

otherwise gogo connorr, pvdata_util.inc :D

ConnorMcLeod
11-21-2008, 12:42
I have this, some stock may have to be improved.
This is just for information so people could know how to convert some code, like for cs_s/get_user_team, if you use it in your own plugin, you don't need to use those CsTeams things.
#define EXTRAOFFSET_WEAPONS 4

#define OFFSET_ARMORTYPE 112
#define OFFSET_TEAM 114
#define OFFSET_CSMONEY 115
#define OFFSET_PRIMARYWEAPON 116
#define OFFSET_LASTACTIVITY 124
#define OFFSET_INTERNALMODEL 126
#define OFFSET_NVGOGGLES 129
#define OFFSET_DEFUSE_PLANT 193
#define OFFSET_VIP 209
#define OFFSET_TK 216 // 040926
#define OFFSET_HOSTAGEKILLS 217
#define OFFSET_MAPZONE 235
#define OFFSET_ISDRIVING 350 // 040926
#define OFFSET_STATIONARY 362 // 040927 (363 works also!)
#define OFFSET_ZOOMTYPE 363

#define OFFSET_AWM_AMMO 377 // 041029: All of these *_AMMO:s were changed -5
#define OFFSET_SCOUT_AMMO 378
#define OFFSET_PARA_AMMO 379
#define OFFSET_FAMAS_AMMO 380
#define OFFSET_M3_AMMO 381
#define OFFSET_USP_AMMO 382
#define OFFSET_FIVESEVEN_AMMO 383
#define OFFSET_DEAGLE_AMMO 384
#define OFFSET_P228_AMMO 385
#define OFFSET_GLOCK_AMMO 386
#define OFFSET_FLASH_AMMO 387
#define OFFSET_HE_AMMO 388
#define OFFSET_SMOKE_AMMO 389
#define OFFSET_C4_AMMO 390

#define OFFSET_CSDEATHS 444 // 040926
#define OFFSET_SHIELD 510

// "weapon_*" entities
#define OFFSET_WEAPONTYPE 43
#define OFFSET_CLIPAMMO 51
#define OFFSET_SILENCER_FIREMODE 74

// "hostage_entity" entities
#define OFFSET_HOSTAGEFOLLOW 86
#define OFFSET_HOSTAGE_NEXTUSE 100
#define OFFSET_HOSTAGE_LASTUSE 483
#define OFFSET_HOSTAGEID 487

// "armoury_entity"
#define OFFSET_ARMOURY_TYPE 34

// C4 offsets
#define OFFSET_C4_EXPLODE_TIME 100
#define OFFSET_C4_DEFUSING 0x181

#define HAS_SHIELD (1<<24)

#define M4A1_SILENCED (1<<2)
#define M4A1_ATTACHSILENCEANIM 6
#define M4A1_DETACHSILENCEANIM 13
#define USP_SILENCED (1<<0)
#define USP_ATTACHSILENCEANIM 7
#define USP_DETACHSILENCEANIM 15

#define GLOCK_SEMIAUTOMATIC 0
#define GLOCK_BURSTMODE 2
#define FAMAS_AUTOMATIC 0
#define FAMAS_BURSTMODE 16

#define PLAYER_IS_VIP (1<<8)

#define PLAYER_IN_BUYZONE (1<<0)

#define CS_MAPZONE_BUY (1<<0)
#define CS_MAPZONE_BOMBTARGET (1<<1)
#define CS_MAPZONE_HOSTAGE_RESCUE (1<<2)
#define CS_MAPZONE_ESCAPE (1<<3)
#define CS_MAPZONE_VIP_SAFETY (1<<4)

/*#define TEAM_UNASSIGNED 0
*#define TEAM_T 1
*#define TEAM_CT 2
*#define TEAM_SPECTATOR 3*/

#define CAN_PLANT_BOMB (1<<8) // 256
#define HAS_DEFUSE_KIT (1<<16) // 65536

#define DEFUSER_COLOUR_R 0
#define DEFUSER_COLOUR_G 160
#define DEFUSER_COLOUR_B 0

#define HAS_NVGOGGLES (1<<0)

#define SCOREATTRIB_NOTHING 0
#define SCOREATTRIB_DEAD 1
#define SCOREATTRIB_BOMB 2 // t only
#define SCOREATTRIB_VIP 4

/*#define CS_ARMOR_NONE 0
#define CS_ARMOR_KEVLAR 1*/
#define CS_ARMOR_ASSAULTSUIT 2

#define CS_FIRST_ZOOM 0x28
#define CS_SECOND_AWP_ZOOM 0xA
#define CS_SECOND_NONAWP_ZOOM 0xF
#define CS_AUGSG552_ZOOM 0x37
#define CS_NO_ZOOM 0x5A

#define cs_get_user_buyzone(%1) (get_pdata_int(%1,OFFSET_MAPZONE)&PLAYER_IN_BUYZONE)
#define cs_get_user_hasprim(%1) get_pdata_int(%1,OFFSET_PRIMARYWEAPON)
#define cs_get_user_mapzones(%1) get_pdata_int(%1,OFFSET_MAPZONE)
#define cs_get_user_plant(%1) (get_pdata_int(%1,OFFSET_DEFUSE_PLANT)&CAN_PLANT_BOMB)
#define cs_get_user_tked(%1) get_pdata_int(%1,OFFSET_TK)
#define cs_get_user_deaths(%1) get_pdata_int(%1,OFFSET_CSDEATHS)
#define cs_get_user_defuse(%1) (get_pdata_int(%1,OFFSET_DEFUSE_PLANT)&HAS_DEFUSE_KIT)
#define cs_get_user_driving(%1) get_pdata_int(%1, OFFSET_ISDRIVING)
#define cs_get_user_money(%1) get_pdata_int(%1,OFFSET_CSMONEY)
#define cs_get_user_nvg(%1) (get_pdata_int(%1,OFFSET_NVGOGGLES) & HAS_NVGOGGLES)
#define cs_get_user_shield(%1) (get_pdata_int(%1,OFFSET_SHIELD)&HAS_SHIELD)
#define cs_get_user_stationary(%1) get_pdata_int(%1,OFFSET_STATIONARY)
#define cs_get_user_vip(%1) (get_pdata_int(id, OFFSET_VIP) & PLAYER_IS_VIP)

#define cs_get_weapon_id(%1) get_pdata_int(%1,OFFSET_WEAPONTYPE,EXTRAOFFSE T_WEAPONS)
#define cs_get_weapon_ammo(%1) get_pdata_int(%1,OFFSET_CLIPAMMO,EXTRAOFFSET_ WEAPONS)
#define cs_set_weapon_ammo(%1,%2) set_pdata_int(%1,OFFSET_CLIPAMMO,%2,EXTRAOFFS ET_WEAPONS)

enum CsTeams {
CS_TEAM_UNASSIGNED,
CS_TEAM_T,
CS_TEAM_CT,
CS_TEAM_SPECTATOR
};

enum CS_Internal_Models {
CS_DONTCHANGE = 0,
CS_CT_URBAN = 1,
CS_T_TERROR = 2,
CS_T_LEET = 3,
CS_T_ARCTIC = 4,
CS_CT_GSG9 = 5,
CS_CT_GIGN = 6,
CS_CT_SAS = 7,
CS_T_GUERILLA = 8,
CS_CT_VIP = 9,
CZ_T_MILITIA = 10,
CZ_CT_SPETSNAZ = 11
};

enum
{
CS_RESET_ZOOM = 0,
CS_SET_NO_ZOOM,
CS_SET_FIRST_ZOOM,
CS_SET_SECOND_ZOOM,
CS_SET_AUGSG552_ZOOM,
};

enum CsArmorType {
CS_ARMOR_NONE = 0, // no armor
CS_ARMOR_KEVLAR = 1, // armor
CS_ARMOR_VESTHELM = 2 // armor and helmet
};

stock cs_get_user_armor(id, &CsArmorType:iArmorType)
{
new Float:flArmorValue;
pev(id, pev_armorvalue, flArmorValue);

iArmorType = CsArmorType:get_pdata_int(id, OFFSET_ARMORTYPE);

return floatround(flArmorValue);
}

stock cs_set_user_armor(id, iArmorValue, CsArmorType:iArmorType)
{
set_pdata_int(id , OFFSET_ARMORTYPE, _:iArmorType);
set_pev(id, pev_armorvalue, float(_:iArmorValue));

if ( iArmorType )
{
static iMsgArmorType;
if( !iMsgArmorType )
{
iMsgArmorType = get_user_msgid("ArmorType");
}
message_begin( MSG_ONE_UNRELIABLE , iMsgArmorType , _ , id );
write_byte( iArmorType == CS_ARMOR_VESTHELM ? 1 : 0 );
message_end();
}
}

stock cs_get_user_bpammo(id, iWeapon)
{
new iOffset;
switch(iWeapon)
{
case CSW_AWP: iOffset = OFFSET_AWM_AMMO;
case CSW_SCOUT, CSW_AK47, CSW_G3SG1: iOffset = OFFSET_SCOUT_AMMO;
case CSW_M249: iOffset = OFFSET_PARA_AMMO;
case CSW_FAMAS, CSW_M4A1, CSW_AUG, CSW_SG550, CSW_GALI, CSW_SG552: iOffset = OFFSET_FAMAS_AMMO;
case CSW_M3, CSW_XM1014: iOffset = OFFSET_M3_AMMO;
case CSW_USP, CSW_UMP45, CSW_MAC10: iOffset = OFFSET_USP_AMMO;
case CSW_FIVESEVEN, CSW_P90: iOffset = OFFSET_FIVESEVEN_AMMO;
case CSW_DEAGLE: iOffset = OFFSET_DEAGLE_AMMO;
case CSW_P228: iOffset = OFFSET_P228_AMMO;
case CSW_GLOCK18, CSW_MP5NAVY, CSW_TMP, CSW_ELITE: iOffset = OFFSET_GLOCK_AMMO;
case CSW_FLASHBANG: iOffset = OFFSET_FLASH_AMMO;
case CSW_HEGRENADE: iOffset = OFFSET_HE_AMMO;
case CSW_SMOKEGRENADE: iOffset = OFFSET_SMOKE_AMMO;
case CSW_C4: iOffset = OFFSET_C4_AMMO;
default:return 0;
}
return get_pdata_int(id, iOffset);
}

stock cs_set_user_bpammo(id, iWeapon, iAmount)
{
new iOffset;
switch(iWeapon)
{
case CSW_AWP: iOffset = OFFSET_AWM_AMMO;
case CSW_SCOUT, CSW_AK47, CSW_G3SG1: iOffset = OFFSET_SCOUT_AMMO;
case CSW_M249: iOffset = OFFSET_PARA_AMMO;
case CSW_FAMAS, CSW_M4A1, CSW_AUG, CSW_SG550, CSW_GALI, CSW_SG552: iOffset = OFFSET_FAMAS_AMMO;
case CSW_M3, CSW_XM1014: iOffset = OFFSET_M3_AMMO;
case CSW_USP, CSW_UMP45, CSW_MAC10: iOffset = OFFSET_USP_AMMO;
case CSW_FIVESEVEN, CSW_P90: iOffset = OFFSET_FIVESEVEN_AMMO;
case CSW_DEAGLE: iOffset = OFFSET_DEAGLE_AMMO;
case CSW_P228: iOffset = OFFSET_P228_AMMO;
case CSW_GLOCK18, CSW_MP5NAVY, CSW_TMP, CSW_ELITE: iOffset = OFFSET_GLOCK_AMMO;
case CSW_FLASHBANG: iOffset = OFFSET_FLASH_AMMO;
case CSW_HEGRENADE: iOffset = OFFSET_HE_AMMO;
case CSW_SMOKEGRENADE: iOffset = OFFSET_SMOKE_AMMO;
case CSW_C4: iOffset = OFFSET_C4_AMMO;
default:return;
}
set_pdata_int(id, iOffset, iAmount);
}

stock cs_set_user_plant(id, plant = 1, showbombicon = 1, backpack = 0)
{
static iMsgStatusIcon;
if( !iMsgStatusIcon )
{
iMsgStatusIcon = get_user_msgid("StatusIcon");
}

if( plant )
{
if(backpack)
{
set_pev(id, pev_body, 1);
}

set_pdata_int(id,OFFSET_DEFUSE_PLANT, cs_get_user_plant(id) | CAN_PLANT_BOMB);
if( showbombicon )
{
message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id);
write_byte(1);
write_string("c4");
write_byte(DEFUSER_COLOUR_R);
write_byte(DEFUSER_COLOUR_G);
write_byte(DEFUSER_COLOUR_B);
message_end();
}
}
else
{
set_pdata_int(id,OFFSET_DEFUSE_PLANT, cs_get_user_plant(id) & ~CAN_PLANT_BOMB);
message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id);
write_byte(0);
write_string("c4");
message_end();

if(backpack)
{
set_pev(id, pev_body, 0);
}
}
}

stock cs_set_user_tked(id, tk = 1, subtract = 1)
{
set_pdata_int(id, OFFSET_TK, tk ? 1 : 0);

if( substract )
{
static Float:flFrags;
pev(id, pev_frags, flFrags);
flFrags -= float(subtract);
set_pev(id, pev_frags, flFrags);

static iMsgScoreInfo;
if( iMsgScoreInfo || (iMsgScoreInfo = get_user_msgid("ScoreInfo")) )
{
message_begin(MSG_BROADCAST, iMsgScoreInfo);
write_byte(id);
write_short(floatround(flFrags));
write_short(cs_get_user_deaths(%1));
write_short(0);
write_short(cs_get_user_team(id));
message_end();
}
}
}

stock cs_user_spawn(id)
{
set_pev(id, pev_deadflag, DEAD_RESPAWNABLE);
dllfunc(DLLFunc_Spawn, id);
set_pev(id, pev_iuser1, 0);
}

stock cs_set_user_deaths(id, iDeaths)
{
set_pdata_int(id, OFFSET_CSDEATHS, iDeaths);

static iMsgScoreInfo;

static Float:flFrags;
pev(id, pev_health, flFrags);

if( iMsgScoreInfo || (iMsgScoreInfo = get_user_msgid("ScoreInfo")) )
{
message_begin(MSG_BROADCAST, iMsgScoreInfo);
write_byte(id);
write_short(floatround(flFrags));
write_short(iDeaths);
write_short(0);
write_short(_:cs_get_user_team(id));
message_end();
}
}

stock cs_set_user_defuse(id, iDefusekit = 1, iRed = 0, iGreen = 160, iBlue = 0, icon[] = "defuser", iFlash = 0)
{
static iMsgStatusIcon;
if( iMsgStatusIcon || (iMsgStatusIcon = get_user_msgid("StatusIcon")) )
{

if( iDefusekit )
{
set_pev(id, pev_body, 1);

set_pdata_int(id, OFFSET_DEFUSE_PLANT, get_pdata_int(id, OFFSET_DEFUSE_PLANT) | HAS_DEFUSE_KIT);

message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id);
write_byte(iFlash ? 2 : 1);
write_string(icon);
write_byte(iRed);
write_byte(iGreen);
write_byte(iBlue);
message_end();
}
else
{
set_pdata_int(id, OFFSET_DEFUSE_PLANT, get_pdata_int(id, OFFSET_DEFUSE_PLANT) & ~HAS_DEFUSE_KIT);

message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id);
write_byte(0);
write_string(icon);
message_end();

set_pev(id, pev_body, 0);
}
}
}

stock cs_set_user_money(id, iMoney, iFlash = 0)
{
set_pdata_int(id,OFFSET_CSMONEY,iMoney);

static iMsgMoney;
if( iMsgMoney || (iMsgMoney = get_user_msgid("Money")) )
{
message_begin(MSG_ONE_UNRELIABLE, iMsgMoney, _, id);
write_long(iMoney);
write_byte(iFlash ? 1 : 0);
message_end();
}
}

stock cs_set_user_nvg(id, nvgoggles = 1)
{
if( nvgoggles )
{
set_pdata_int(id, OFFSET_NVGOGGLES, get_pdata_int(id,OFFSET_NVGOGGLES) | HAS_NVGOGGLES);
}
else
{
set_pdata_int(id, OFFSET_NVGOGGLES, get_pdata_int(id,OFFSET_NVGOGGLES) & ~HAS_NVGOGGLES);
}
}

stock CsTeams:cs_get_user_team(id, &{CsInternalModel,_}:iModel = CsInternalModel:CS_DONTCHANGE)
{
iModel = CsInternalModel:get_pdata_int(id, OFFSET_INTERNALMODEL);
return CsTeams:get_pdata_int(id, OFFSET_TEAM);
}

stock cs_set_user_team(id, {CsTeams,_}:iTeam, {CsInternalModel,_}:iModel = CsInternalModel:CS_DONTCHANGE)
{
if( iTeam > CS_TEAM_SPECTATOR )
return;

set_pdata_int(id, OFFSET_TEAM, _:iTeam);

if( iModel )
{
set_pdata_int(id, OFFSET_INTERNALMODEL, _:iModel);
}

dllfunc(DLLFunc_ClientUserInfoChanged, id, engfunc(EngFunc_GetInfoKeyBuffer, id));

static const szTeams[] = { "UNASSIGNED" , "TERRORIST" , "CT" , "SPECTATOR" };

static iMsgTeamInfo;
if( iMsgTeamInfo || (iMsgTeamInfo = get_user_msgid("TeamInfo")) )
{
emessage_begin(MSG_ALL, iMsgTeamInfo);
ewrite_byte(id);
ewrite_string(szTeams[_:iTeam]);
emessage_end();
}
}

stock cs_get_weapon_silen(index)
{
switch( cs_get_weapon_id(index) )
{
case CSW_M4A1:
{
return (get_pdata_int(index,OFFSET_SILENCER_FIREMODE ,EXTRAOFFSET_WEAPONS) & M4A1_SILENCED);
}
case CSW_USP:
{
return (get_pdata_int(index,OFFSET_SILENCER_FIREMODE ,EXTRAOFFSET_WEAPONS) & USP_SILENCED);
}
}
return 0;
}

stock cs_set_weapon_silen(index, silence = 1, draw_animation = 1)
{
switch(cs_get_weapon_id(index))
{
case CSW_M4A1:
{
new silencemode = get_pdata_int(index,OFFSET_SILENCER_FIREMODE, EXTRAOFFSET_WEAPONS);
if(silence)
{
if (!(silencemode & M4A1_SILENCED))
{
silencemode |= M4A1_SILENCED;
set_pdata_int(index,OFFSET_SILENCER_FIREMODE, silencemode,EXTRAOFFSET_WEAPONS);

if (draw_animation)
{
new id = pev(index, pev_owner);
if( id )
{
set_pev(id, pev_weaponanim, M4A1_ATTACHSILENCEANIM);
}
}
}
}
else if(silencemode & M4A1_SILENCED)
{
silencemode &= ~M4A1_SILENCED;
set_pdata_int(index,OFFSET_SILENCER_FIREMODE, silencemode,EXTRAOFFSET_WEAPONS);

if (draw_animation)
{
new id = pev(index, pev_owner);
if( id )
{
set_pev(id, pev_weaponanim, M4A1_DETACHSILENCEANIM);
}
}
}
}
case CSW_USP:
{
new silencemode = get_pdata_int(index,OFFSET_SILENCER_FIREMODE, EXTRAOFFSET_WEAPONS);
if (silence)
{
if (!(silencemode & USP_SILENCED))
{
silencemode |= USP_SILENCED;
set_pdata_int(index,OFFSET_SILENCER_FIREMODE, silencemode,EXTRAOFFSET_WEAPONS);

if (draw_animation)
{
new id = pev(index, pev_owner);
if( id )
{
set_pev(id, pev_weaponanim, USP_ATTACHSILENCEANIM);
}
}
}
}
else if (silencemode & USP_SILENCED)
{
silencemode &= ~USP_SILENCED;
set_pdata_int(index,OFFSET_SILENCER_FIREMODE, silencemode,EXTRAOFFSET_WEAPONS);

if (draw_animation)
{
new id = pev(index, pev_owner);
if( id )
{
set_pev(id, pev_weaponanim, USP_DETACHSILENCEANIM);
}
}
}
}
default:return 0;
}

return 1;
}

stock cs_get_weapon_burstmode(index)
{
switch(cs_get_weapon_id(index))
{
case CSW_GLOCK18:
{
return (get_pdata_int(index,OFFSET_SILENCER_FIREMODE ,EXTRAOFFSET_WEAPONS) == GLOCK_BURSTMODE);
}
case CSW_FAMAS:
{
return (get_pdata_int(index,OFFSET_SILENCER_FIREMODE ,EXTRAOFFSET_WEAPONS) == FAMAS_BURSTMODE);
}
}
return 0;
}

stock cs_set_weapon_burst(index, burstmode = 1)
{
switch (cs_get_weapon_id(index))
{
case CSW_GLOCK18:
{
if (burstmode)
{
if (get_pdata_int(index,OFFSET_SILENCER_FIREMODE ,EXTRAOFFSET_WEAPONS) != GLOCK_BURSTMODE)
{
set_pdata_int(index,OFFSET_SILENCER_FIREMODE, GLOCK_BURSTMODE,EXTRAOFFSET_WEAPONS);

new id = pev(index, pev_owner);
if( id )
{
client_print(id, print_center, "#Switch_To_BurstFire");
}
}
}
else if (get_pdata_int(index,OFFSET_SILENCER_FIREMODE ,EXTRAOFFSET_WEAPONS) != GLOCK_SEMIAUTOMATIC)
{
set_pdata_int(index,OFFSET_SILENCER_FIREMODE, GLOCK_SEMIAUTOMATIC,EXTRAOFFSET_WEAPONS);

new id = pev(index, pev_owner);
if( id )
{
client_print(id, print_center, "#Switch_To_SemiAuto");
}
}
}
case CSW_FAMAS:
{
if (burstmode)
{
if (get_pdata_int(index,OFFSET_SILENCER_FIREMODE ,EXTRAOFFSET_WEAPONS) != FAMAS_BURSTMODE)
{
set_pdata_int(index,OFFSET_SILENCER_FIREMODE, FAMAS_BURSTMODE,EXTRAOFFSET_WEAPONS);

new id = pev(index, pev_owner);
if( id )
{
client_print(id, print_center, "#Switch_To_BurstFire");
}
}
}
else if (get_pdata_int(index,OFFSET_SILENCER_FIREMODE ,EXTRAOFFSET_WEAPONS) != FAMAS_AUTOMATIC)
{
set_pdata_int(index,OFFSET_SILENCER_FIREMODE, FAMAS_AUTOMATIC,EXTRAOFFSET_WEAPONS);

new id = pev(index, pev_owner);
if( id )
{
client_print(id, print_center, "#Switch_To_FullAuto");
}
}
}
default:
{
return 0;
}
}

return 1;
}

stock cs_set_user_vip(index, vip = 1, updateModel = 1, updateScoreboard = 1)
{
if (vip)
{
set_pdata_int(id,OFFSET_VIP, get_pdata_int(id,OFFSET_VIP)|PLAYER_IS_VIP);

if (updateModel)
{
set_pdata_int(id,OFFSET_INTERNALMODEL, _:CS_CT_VIP);
dllfunc(DLLFunc_ClientUserInfoChanged, id, engfunc(EngFunc_GetInfoKeyBuffer, id));
}

if (updateScoreboard)
{
static iMsgScoreAttrib
if( iMsgScoreAttrib || (iMsgScoreAttrib = get_user_msgid("ScoreAttrib")) )
{
message_begin(MSG_BROADCAST, iMsgScoreAttrib);
write_byte(id);
write_byte(SCOREATTRIB_VIP);
message_end();
}
}
}
else
{
set_pdata_int(id,OFFSET_VIP, get_pdata_int(id,OFFSET_VIP) &= ~PLAYER_IS_VIP);

if (updateModel)
{
set_pdata_int(id,OFFSET_INTERNALMODEL, _:CS_CT_GIGN); // hardcoded to gign model
dllfunc(DLLFunc_ClientUserInfoChanged, id, engfunc(EngFunc_GetInfoKeyBuffer, id));
}

if (updateScoreboard)
{
static iMsgScoreAttrib
if( iMsgScoreAttrib || (iMsgScoreAttrib = get_user_msgid("ScoreAttrib")) )
{
message_begin(MSG_BROADCAST, iMsgScoreAttrib);
write_byte(id);
write_byte(is_user_alive(id) ? SCOREATTRIB_NOTHING : SCOREATTRIB_DEAD);
message_end();
}
}
}

return 1;
}

AcidoX
01-26-2009, 19:22
FM util updated.

Edit: Updated
Added cs.inc (Credits ConnorMcLeod (http://forums.alliedmods.net/member.php?u=18946))

Edit2: Update2
Added fakeengine.irc (Credits anakin_cstrike (http://forums.alliedmods.net/member.php?u=32418))
Added chr_engine.inc (Credits GHW_Chronic)

Exolent[jNr]
01-26-2009, 19:30
What did you change/add?

Emp`
01-27-2009, 03:00
He added:#define fm_set_lights(%1) engfunc(EngFunc_LghtStlye, 0, %1)
/* stock fm_set_lights(const Lighting[]) return engfunc(EngFunc_LightStyle, 0, Lighting) */
but it should be#define fm_set_lights(%1) engfunc(EngFunc_LightStyle, 0, %1)
/* stock fm_set_lights(const Lighting[]) return engfunc(EngFunc_LightStyle, 0, Lighting) */

AcidoX
01-27-2009, 06:52
Well, im adding FM util functions from the forum, because no one is updating it.

Updated my post on top.

karceWZROKIEM
10-26-2009, 11:40
The function gets what weapon type (CSW_*) a "grenade" entity is.
"grenade" entity is either the throwed grenade or the planted C4.

Returns 0 on failure. Win32 only. Provided as is (no warranties).
It's similar to the cs_get_armoury_type which work for "armoury_entity".

This function are useful because the old model check method aren't practical.
1. The model could be changed to the custom one by the 3rd party addon.
2. There are the moments when the grenade doesn't have the model (on explosion).

You shouldn't use the offsets and it's values for altering the grenade type.
This is not the data which controls the actual type, neither i think it's possible
to alter the type that way.

I'm not including this to the fakemeta_util.inc at least because it's win32 only.
I do realise that there are probably the more evident way but at least this work.
If you think something is incorrect or needs to be improved, feel free to post.
Code:
stock fm_cs_get_grenade_type(index) { // you can comment/remove this // if you are sure that the entity // with the given index are valid if (!pev_valid(index)) return 0 // you can comment/remove this // if you are sure that the entity // with the given index are "grenade" new classname[9] pev(index, pev_classname, classname, 8) if (!equal(classname, "grenade")) return 0 if (get_pdata_int(index, 96) & (1<<8)) return CSW_C4

new bits = get_pdata_int(index, 114) if (bits & (1<<0)) return CSW_HEGRENADE
else if (bits & (1<<1)) return CSW_SMOKEGRENADE
else if (!bits) return CSW_FLASHBANG

return 0 }


for both get_pdata_int OFFSET should be 5 not (default) 4....

Exolent[jNr]
10-26-2009, 11:48
for both get_pdata_int OFFSET should be 5 not (default) 4....

I would LOVE to see you prove VEN wrong.

Arkshine
10-26-2009, 12:02
By default get_pdata_int uses +5 as extra offset for linux.

Since this offset is related to the weapon, it would be +4.

Connor has tested and confirmed that it works fine with +4.

ConnorMcLeod
10-29-2009, 02:05
And VEN never talked about linux for those offsets.

karceWZROKIEM
10-29-2009, 18:45
By default get_pdata_int uses +5 as extra offset for linux.

Since this offset is related to the weapon, it would be +4.

Connor has tested and confirmed that it works fine with +4.
So there is a problem...
Because i've also tested and offset 4 is the wrong one... even if grenade is a weapon...
but offset is 5 , same as for player !!

;972645']I would LOVE to see you prove VEN wrong.
VEN wasn't wrong...
He made this function for windows... and he didn't checked it for *nix...

Arkshine
10-29-2009, 19:19
Yeah, you're right. ConnorMcLeod sucks we can't trust him. :twisted: . Just tested and it should be 5 indeed.

Hawk552
10-30-2009, 16:46
Either way, people really shouldn't be using this stuff except for the functions that you can't find anywhere else.

Arkshine
08-04-2011, 15:18
The function gets what weapon type (CSW_*) a "grenade" entity is.
"grenade" entity is either the throwed grenade or the planted C4.

[...]
If you think something is incorrect or needs to be improved, feel free to post.
stock fm_cs_get_grenade_type(index) {
// you can comment/remove this
// if you are sure that the entity
// with the given index are valid
if (!pev_valid(index))
return 0

// you can comment/remove this
// if you are sure that the entity
// with the given index are "grenade"
new classname[9]
pev(index, pev_classname, classname, 8)
if (!equal(classname, "grenade"))
return 0

if (get_pdata_int(index, 96) & (1<<8))
return CSW_C4

new bits = get_pdata_int(index, 114)
if (bits & (1<<0))
return CSW_HEGRENADE
else if (bits & (1<<1))
return CSW_SMOKEGRENADE
else if (!bits)
return CSW_FLASHBANG

return 0
}

To clarify what does really theses offsets (and because I've checked today! ) :

96 is related to C4 bomb planting/defusing and a generic name would be : m_fBombStatus


(1<<0) : Start defuse
(1<<8) : Bomb planted


114 is related to grenades events and a generic name would be : m_usEvent


0 : Flashbang : Since there is no event for that, value is null.
1 : HE grenade ; value by default returned from PRECACHE_EVENT( 1, "events/createexplo.sc" )
2 : Smoke grenade : value by default returned from PRECACHE_EVENT( 1, "events/createsmoke.sc" )


114 is also related to smoke grenade specifically but since it's different and hard to find a global name for all flags, we better use another name : m_fSGStatus


(1<<24) : Smoke grenade detonated. (Set just before PlayBackEvent called)
(1<<16) : When a smoke grenade is thrown and when it's going to be detonated, if it finds another smoke grenade in the 250 units and not detonated yet, this flag is set. No idea what is changed, maybe how react the fog) (Used as param in PlayBackEvent)

Exolent[jNr]
08-04-2011, 15:36
Thanks for the clarification! Is it still Win32-only after looking through it, or did you find it can work in Linux as well?

Arkshine
08-04-2011, 15:39
There is no offsets such as windows-only. I mean, if it exists under windows, it exists [obviously] under linux too. For "grenade" (CGrenade), the extra offset for linux is +5.

Exolent[jNr]
08-04-2011, 18:48
There is no offsets such as windows-only. I mean, if it exists under windows, it exists [obviously] under linux too. For "grenade" (CGrenade), the extra offset for linux is +5.

I expected that, but I figured VEN would've known that since he played around with offsets.
Thanks for confirming.