Raised This Month: $ Target: $400
 0% 

Hook Entity Removal/Deletion/Killing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-30-2017 , 15:47   Re: Hook Entity Removal/Deletion/Killing
Reply With Quote #1

Quote:
1. is there any empty field on entities to store strings ? like pev_iuser1 ?
I'm not sure and I don't feel like browsing all the pev_* values to find out. You can do that on your own. Anyway, there's a trick you can do by using EngFunc_AllocString and glb_pStringBase/EngFunc_SzFromIndex.

PHP Code:
stock set_string_int(const ent, const field, const string[])
{
    if(
pev_valid(ent))
    {
        if(
string[0] != EOS)
        {
            new 
offset engfunc(EngFunc_AllocStringstring)
            
set_pev(entfieldoffset)
        }
    }
}

stock get_string_int(const ent, const field, const string[], const size)
{
    if(
pev_valid(ent))
    {
        if(
size != 0)
        {
            new 
offset pev(entfield)
            
global_get(glb_pStringBaseoffsetstringsize
        }
    }

Note that allocating a string is an expensive operation and the same string will be allocated multiple times if you call that native for more than once for the same string. What I would recommend you to do, if you use the above method is to allocate only once and remember in a variable or somewhere the allocated value, because it won't change. You can even use a trie, the string is the key and the value is the "offset" obtained.
__________________

Last edited by HamletEagle; 06-30-2017 at 15:48.
HamletEagle is offline
Reply



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 23:11.


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