AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Which is Better? (https://forums.alliedmods.net/showthread.php?t=118191)

AfteR. 02-08-2010 14:55

Which is Better?
 
It's simple, but I want to know which way is better:

PHP Code:

public client_putinserverid )
{
    new 
name[32]
    
get_user_name(idnamesizeof(name) - 1)
    
    
client_print(idprint_chat"%s has entered .."name)


or

PHP Code:

public client_putinserverid )
{
    static 
name[32]
    
get_user_name(idnamesizeof(name) - 1)
    
    
client_print(idprint_chat"%s has entered .."name)


In these case, which is better: static or new? (its just an example, it not necesarily has to be the name) and why..

ConnorMcLeod 02-08-2010 14:59

Re: Which is Better?
 
Both are be fine.
FYI, you can't print anything to player at this moment, you have to delay it a bit.

Bugsy 02-08-2010 15:06

Re: Which is Better?
 
Since its such a small string, you will be fine using either. When working with very large strings it is better to use static.

NiQu 02-08-2010 15:09

Re: Which is Better?
 
Personally i would use "new" and not "static", i got no reason why :P

You have to create a task delay of around 5 seconds or the message wont be printed, or the message will be printed but way to early.(You cant recieve messages before choosing team.).

AfteR. 02-08-2010 15:24

Re: Which is Better?
 
Hahhaa I forgot to change id to 0 :)


All times are GMT -4. The time now is 07:26.

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