View Single Post
Author Message
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 09-11-2017 , 16:07   Optimization - Global variables vs natives
Reply With Quote #1

Well, here is the big question .

To check for example the player state (Alive or dead) or cvars values in "heavy" functions (OnGameFrame, OnPlayerRunCmd, Timer100ms,...), is it better to remember the value using a global variable (+ Some hooks to detect when the real value has changed) or to use directly the natives (IsPlayerAlive, ...)?

I'm mainly talking in terms of performance (Memory shouldn't be an issue) and in case of a complex server using multiple plugins (Like a zombie mode for example).

------------
Under Amxmodx, lot of developpers were doing like above using global variables, even for "light" functions (OnTakeDamage, OnWeaponSwitch,...), but is it the same for SourceMod?
__________________
micapat is offline