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_AllocString, string)
set_pev(ent, field, offset)
}
}
}
stock get_string_int(const ent, const field, const string[], const size)
{
if(pev_valid(ent))
{
if(size != 0)
{
new offset = pev(ent, field)
global_get(glb_pStringBase, offset, string, size)
}
}
}
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.
__________________