Raised This Month: $51 Target: $400
 12% 

set_pev & entity_set_string String Allocation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PartialCloning
Senior Member
Join Date: Dec 2015
Old 07-24-2016 , 15:22   set_pev & entity_set_string String Allocation
Reply With Quote #1

set_pev in some cases such as setting pev_weaponmodel2 allocates the string every single time, does entity_set_string do the same? If not does that make entity_set_string better when setting strings?

Last edited by PartialCloning; 07-24-2016 at 15:22.
PartialCloning is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-24-2016 , 15:40   Re: set_pev & entity_set_string String Allocation
Reply With Quote #2

Both set_pev() (with a string entvar) and entity_set_string() allocate a string in the engine each time you call them.

That's why pev_weaponmodel and pev_viewmodel are likely the best ones, because they are actually integers and accept already allocated strings from EngFunc_AllocString. They should operate faster then too.

Last edited by klippy; 07-24-2016 at 15:43.
klippy is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 08-19-2016 , 12:14   Re: set_pev & entity_set_string String Allocation
Reply With Quote #3

EngFunc_SetModel also allocates a string correct? Using pev_model with an allocated string isn't working for entities for me. What would be the best way to set an entity's world model?
PartialCloning is offline
Solokiller
Senior Member
Join Date: Sep 2015
Old 08-19-2016 , 15:44   Re: set_pev & entity_set_string String Allocation
Reply With Quote #4

EngFunc_SetModel allocates a new string. You have to call the engine to set the model since it does some bookkeeping, like setting the model's index and resetting the bounds.
Solokiller is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 08-19-2016 , 17:31   Re: set_pev & entity_set_string String Allocation
Reply With Quote #5

https://forums.alliedmods.net/showthread.php?p=2446291
PartialCloning 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 07:02.


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