Raised This Month: $ Target: $400
 0% 

difference between new and static?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-25-2012 , 05:52   Re: difference between new and static?
Reply With Quote #3

Quote:
Originally Posted by claudiuhks View Post
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 1337// YEYEYE
static 1337// NONONO
static i1337// 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.
.Dare Devil. is offline
 



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:47.


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