PHP код:
//Add 10 to the player's score.
PlayerInfo[playerid][score] += 10;
which is the same as
PHP код:
//Add 10 to the player's score.
PlayerInfo[playerid][score] = (PlayerInfo[playerid][score] + 10);
So,
a += 1 or
a = (a + 1) is the same as
a++!
The difference here is that
a + b is an arithmetic expression and not a statement.
a + b will yield the result of
a + b, but
a += b will assign the value of
a + b to
a. This means "+=" just adds the value to the variable on the left hand side and stores it.
An example of it in use:
PHP код:
//Declare a and b
new a = 5;
new b = 3;
//Add 3 to 5, put in a
a += b;
//This would print out 8.
printf("%d", a);
Another thing to note about this operator is that like most other operators, it can be "chained" in sequence, which comes in handy sometimes:
PHP код:
//Declare a, b and c.
new a = 5,
b = 3,
c = 6;
//Add C to B, and add B to A
a += b += c;
//Print out result. We should get 14 (5 + (6 + 3))
printf("%d", a);
which is the same as
PHP код:
//Declare a, b and c.
new a = 5,
b = 3,
c = 6;
//Set a to (a + b + c)
a = (a + b + c);
//Print out a. We should get 14 (5 + 3 + 6).
printf("%d", a);