difference between new and static?
Hello!
i still think that they are same things so i use always new, because it is shorter :) I dont see any difference between new and static... what difference between new and static? :):) Thanks! |
Re: difference between new and static?
A static variable couldn't be initialized immediately, then it will take less performance.
Also, it remains unchanged in function and won't be initialized again. Only a new attribution will change the static's variable value. PHP Code:
PHP Code:
|
Re: difference between new and static?
Quote:
Sometimes my static variables get wrong value when i use them like "entity thinking function" i just replaced all static to new and then it worked fine :crab: Anyway thanks for that information. |
Re: difference between new and static?
new creating every time on function call
static creating on plugin start and using (not creating) on function call static is more perfomancy for often calls like shooting |
Re: difference between new and static?
One question
PHP Code:
then y + 10 example and if entity_think is called "entity_think(129)" then that old y + 10 or there come new y because func ent param is different? i think it is a bad explanation :) ( bad english! :crab: ) if the entity_think param is different then what happen to the y? |
Re: difference between new and static?
Quote:
if you want.. make a test in Ham_Spawn using a static |
Re: difference between new and static?
PHP Code:
Quote:
Quote:
Anyway in the entity thinking i must do PHP Code:
I get all information what i want, thanks! |
Re: difference between new and static?
Do :
static hj = 0 to be sure of initialization. For an array, prefer to use a global array, especially if you gonna increment cells : new g_MyGlobalEntArray[512]; You can consider a static variable like a global variable but that you can access only in 1 function. Also, as said GordonFreeman, prefer static when your function is called very often, and especially when variables are strings. |
Re: difference between new and static?
for short 'static' variable operating speeds of the plugin .
|
| All times are GMT -4. The time now is 07:47. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.