[Help] with variable...
#1

Hi!

Код:
something[playerid] + 20;
but the compiler says: expression has no effect so whats wrong
Reply
#2

Im not sure, but i think its something[playerid] += 20;
Reply
#3

Did you make the variable "something" an array?

pawn Код:
new something[MAX_PLAYERS]; // as an example
Reply
#4

When increasing variable's value by more than one (++) or decreasing for more than one (--), you should use += and -=, not only + and -.

pawn Код:
Variable[playerid]++; // Increases the variable's value by one.
Variable[playerid]--; // Decreases the variable's value by one
Variable[playerid] += 28670; // Increases the variable's value by 28 670
Variable[playerid] -= 9737; // Decreases the variable's value by 9 737
Though you can only increase values to integer variables, and not strings!
Reply
#5

ok thx!
Now I have a little little little question so i ask it right here^^

Variable[playerid] += random number between 25 and 50 -> how to do that
Reply
#6

pawn Код:
stock randomEx(minnum = cellmin, maxnum = cellmax) return random(maxnum - minnum + 1) + minnum;
/* i think this function is created by ******, but i'm not sure. */
pawn Код:
Variable[playerid] += randomEx(25, 50);
Reply
#7

Quote:
Originally Posted by Don Correlli
pawn Код:
stock randomEx(minnum = cellmin, maxnum = cellmax) return random(maxnum - minnum + 1) + minnum;
/* i think this function is created by ******, but i'm not sure. */
pawn Код:
Variable[playerid] += randomEx(25, 50);
and how to put the same Random Number between 25 50 from the Variable into a SendClientMessage
Reply
#8

pawn Код:
new string[32];
format(string,sizeof(string),"%d - the variable",Variable[playerid]);
SendClientMessage(playerid,color,string);
Reply
#9

Store it into the other variable and then use it or just display Variable variable.

pawn Код:
new
    myRandomVar;
myRandomVar = randomEx(25, 50);
Variable[playerid] += myRandomVar;
format(...);
SendClientMessage(...);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)