Raised This Month: $52 Target: $400
 13% 

Module: Custom Entity Data


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-22-2017 , 00:03   Module: Custom Entity Data
Reply With Quote #1

Description:

This module lets you bind custom user data to entities without dealing with fields like pev_iuser[1-4] or similar. The reason this module is created is that this way you are not limited by the amount of pev_* fields and plugins or the game dll won't interfere with each other (modifying the same pev_* fields).


API:

The API is pretty similar to the Trie API - you can retrieve or set cells, arrays and strings, which are identified by a string key.
When an entity is destroyed, all data bound to it gets destroyed too - that means that you have to free any handles (like Trie, Array, Stack or others) bound to that entity or they will get lost/leaked.

customentdata.inc



Install instructions:

Put customentdata_amxx.dll (Windows) or customentdata_amxx_i386.so (Linux) into $moddir/addons/amxmodx/modules.


Todo:
  • Create an "OnEntityDestroyed" hook or similar to let the user easily free any bound handles.


Downloads:

Source code on GitHub

Last edited by KliPPy; 02-23-2017 at 19:13. Reason: 1.0.1
KliPPy is offline
Gabe Iggy
Veteran Member
Join Date: Mar 2011
Location: Chile
Old 02-22-2017 , 06:12   Re: Module: Custom Entity Data
Reply With Quote #2

Awesome
__________________
Gabe Iggy is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 02-22-2017 , 07:07   Re: Module: Custom Entity Data
Reply With Quote #3

One entity data module to rule them all.
Thank you master Klippy.
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
[email protected]
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 02-22-2017 , 11:50   Re: Module: Custom Entity Data
Reply With Quote #4

Good job, but you can hook OnFreeEntPrivateData from API instead of hooking ED_Free.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-22-2017 , 14:27   Re: Module: Custom Entity Data
Reply With Quote #5

Thank you peeps.

@[email protected]: I just took a look, that would be more proper, thanks, I'll fix that soon.
KliPPy is offline
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-23-2017 , 19:18   Re: Module: Custom Entity Data
Reply With Quote #6

Updated per [email protected]'s suggestion.
KliPPy is offline
[email protected]
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 02-23-2017 , 20:40   Re: Module: Custom Entity Data
Reply With Quote #7

You misunderstood me. I mean hook OnFreeEntPrivateData via NewDLL API. You should uncomment
PHP Code:
#define FN_OnFreeEntPrivateData                OnFreeEntPrivateData 
or
PHP Code:
#define FN_OnFreeEntPrivateData_Post            OnFreeEntPrivateData_Post 
in moduleconfig to use it.
__________________

Last edited by [email protected]; 02-23-2017 at 20:41.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-23-2017 , 21:00   Re: Module: Custom Entity Data
Reply With Quote #8

I am aware of that it exists there, but calls to engine/game dll functions via Metamod plugins aren't propagated to other Metamod plugins IIRC. That's why for example you can't hook FM_PrecacheModel that other AMXX plugin executed. That's why I kept on using CHooker.

Last edited by KliPPy; 02-23-2017 at 21:01.
KliPPy is offline
[email protected]
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 02-23-2017 , 21:17   Re: Module: Custom Entity Data
Reply With Quote #9

There are two kinds of functions in API that you can call (they are located in engfuncs) and that you can hook (events) (I mean original API from engine, not metamod, they are located in EntityAPI(2) and NewDLLFunctions). PrecacheModel is that you can call, so basically you can hook it to customize gamedll behaviour only. FreeEntPrivateData has two versions FreeEntPrivateData that you can call (engfunc) and OnFreeEntPrivateData event (NewDllFunction). FreeEntPrivateData engfunc calls OnFreeEntPrivateData (you can see that in ReHLDS). So, you can hook OnFreeEntPrivateData via API without any problems. Emulating OnFreeEntPrivateData can break some code in gamedll, this is like undefined behaviour (I mean fakecall from some plugin).
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 02-24-2017 , 02:16   Re: Module: Custom Entity Data
Reply With Quote #10

I was thinking on doing something like this, I complained because I thought it would be slow. Good job, this kind of addons will have a big impact if is integrated in the main AMXX package.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:19.


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