Scriptors come hier!
#1

PHP код:
new K[MAX_PLAYERS] = {0,...}; 
What does this exactly mean?
Reply
#2

The {0, ...} tells the compiler to set all of the array index values to 0.

For example if you accessed the 5th index, the value would be 0. The ... means recurring.

This code is redundant as all index values are already automatically set to 0.
Reply
#3

So it is like doing
PHP код:
new K[MAX_PLAYERS];
for(new 
0MAX_PLAYERSi++)K[i] = 0
?
Reply
#4

Quote:
Originally Posted by kAn3
Посмотреть сообщение
So it is like doing
PHP код:
new K[MAX_PLAYERS];
for(new 
0MAX_PLAYERSi++)K[i] = 0
?
Kind of...

You can only define the code once so you cannot do this more than once:

Код:
new K[MAX_PLAYERS] = {0,...};
You can only do it when declaring the variable array.
So if you wanted to change all values to 0 at anytime then you execute your code above.
Reply
#5

Thanks!
+Rep
Reply
#6

Lol, who ever added that line of code was drunk because it's a null statement to a preexisting statement
Reply
#7

What do you mean?
Reply
#8

Quote:
Originally Posted by Prokill911
Посмотреть сообщение
Lol, who ever added that line of code was drunk because it's a null statement to a preexisting statement
Reply
#9

It means that when you declare a variable which has a type that contain numbers (int, boolean in our case) their default value will be (0). Therefore setting it's default value to (0) is useless. When you declare a variable which has characters in it (string), their values are NULL for each and every character.
Reply
#10

Arrays in PAWN are initialized to zero by default.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)