27.12.2011, 14:05
Quote:
If you want the variable to be for a special purpose for example if you want it to be used by the server or by only one client then you go with
pawn Код:
pawn Код:
|
Declaring a variable such as:
pawn Код:
new Var;
Declaring a variable as:
pawn Код:
new Var[MAX_PLAYERS];
pawn Код:
new Var1;
new Var2;
new Var3;
new Var4;
new Var5;
//etc...
You can access (and set) data from/to an array by knowing the 'slot'. This could be stored in a variable or otherwise. Example:
pawn Код:
Var[playerid] = 1; //Where playerid is declared as an integer.
//Make Var[playerid] become 1.
pawn Код:
Var[0] = 0;
//Make the slot 0 of var equal to 0.
pawn Код:
for(new i; i < sizeof(Var); i++) //In this example, "sizeof(Var)" gets the array size.
{
Var[i] = 100;
}
//This loop will make all the slots in the array called "Var" equal 100.