Quote:
Originally Posted by claudiuhks
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:
new i = 1337; // YEYEYE
static i = 1337; // NONONO
static i; i = 1337; // YEYEYE
PHP Code:
public MyFunction( )
{
static msgSayText;
if( !msgSayText )
msgSayText = get_user_msgid( "SayText" );
server_print( "SayText's index is %d", msgSayText );
// Native get_user_msgid will be executed once in this function named MyFunction because msgSayText's value won't be lost.
}
|
that explain somethings...
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
Anyway thanks for that information.