AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Few Questions (https://forums.alliedmods.net/showthread.php?t=47558)

Drak 11-20-2006 19:34

Few Questions
 
Just some simple questions, what would be better in the functions? (Performance wise)
Code:
new name[33] client_print(id,print_chat,"Name: %s",get_user_name(id,name,32))
Or
Code:
new name[33] get_user_name(id,name,32) client_print(id,print_chat,"Name: %s",name)
Or would they both be the same?

Also, are 'enums' just like defines, but in a struct like form?
Code:
enum {      ONE = 1      TWO = 2      THREE = 3 }
Code:
#define ONE 1 #define TWO 2 #define THREE 3
Would this be the same?

Brad 11-20-2006 20:18

Re: Few Questions
 
Quote:

Originally Posted by SixTwin (Post 405408)
Just some simple questions, what would be better in the functions? (Performance wise)
Code:
new name[33] client_print(id,print_chat,"Name: %s",get_user_name(id,name,32))
Or
Code:
new name[33] get_user_name(id,name,32) client_print(id,print_chat,"Name: %s",name)
Or would they both be the same?

You can't do the first one so your question is invalid.

jim_yang 11-20-2006 22:23

Re: Few Questions
 
enum CsTeams {
CS_TEAM_UNASSIGNED = 0,
CS_TEAM_T = 1,
CS_TEAM_CT = 2,
CS_TEAM_SPECTATOR = 3
};
so when you declare a new var using enum, e.g. new CsTeams:team
so the possible value of team is only 0/1/2/3.
#define is a preprocessor directive, just place a symbol with its defined value when compile.
so new team; the value of team could be any int value in its range.
bad english sry.

Drak 11-20-2006 22:44

Re: Few Questions
 
Okay, and just one more question. When i see stuff like
Code:
new something = (1<<2||1<<3)
and so on. What does "<<" mean?

jim_yang 11-20-2006 22:54

Re: Few Questions
 
my english is really bad to explain that. hope you can understand
3 decimal = 00000011 binary
5 decimal = 00000101 binary

& | ~ << >> these are bit operator.

so 3&5 means
00000011
00000101
result:
00000001

<< means bit left move
1 decimal = 00000001 binary
1<<1 means 1 left move 1 bit result: 00000010 binary = 2 decimal

dutchmeat 11-21-2006 04:43

Re: Few Questions
 
here's how decimal versus binary works:
if your decimal would be 32 it is:
Code:

binary(scale):          1 2 4 8 16 32 64 128 256 512 1024
binary:                  0 0 0 0  0  1

so when your decimal is 52
your binary is:
Code:

binary(scale):          1 2 4 8 16 32 64 128 256 512 1024
binary:                  0 0 1 0  1  1

4 + 16 = 20 + 32 = 52.
Some relative information :) just finished this study last year.


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

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