Raised This Month: $32 Target: $400
 8% 

Another way to check entity name.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LinLinLin
Senior Member
Join Date: Sep 2021
Old 11-25-2022 , 08:22   Another way to check entity name.
Reply With Quote #1

Sometime we need model name to select the entity we want.
PHP Code:
#define XXX "xx/xx/xx/xx.xx"
// something like:
// bla bla bla
char entity[PLATHFORM_MAX_PATH];
GetClientModel(client,entity,sizeof(entity)); // or GetEntPropString(entity,Prop_Send,"m_ModelName",entity,sizeof(entity));
if( strcmp(xxx,entity) == // i know that if we check client model we can use strncmp() to only check one character.
{
  
// do something...

but now we can do that
PHP Code:
int g_entity_precache_index;

public 
void OnMapStart()
{
  
g_entity_precache_index PrecacheModel("xxx",true);
}

// bla bla bla
if( HasEntProp(entity,Prop_Send,"m_iWorldModelIndex")
  && 
GetEntProp(entity,Prop_Send,"m_iWorldModelIndex") == g_entity_precache_index )
{
 
// do something.

Maybe useful for weapon check or other entity which has worldmodel.
As the same, precache viewmodel of entity we can use "m_iViewModelIndex" prop to check.

Last edited by LinLinLin; 11-26-2022 at 02:00.
LinLinLin 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 19:37.


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