[Help] with variable... - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help] with variable... (
/showthread.php?tid=116057)
[Help] with variable... -
BMGP - 27.12.2009
Hi!
Код:
something[playerid] + 20;
but the compiler says: expression has no effect so whats wrong
Re: [Help] with variable... -
Dark_Kostas - 27.12.2009
Im not sure, but i think its something[playerid] += 20;
Re: [Help] with variable... -
Grim_ - 27.12.2009
Did you make the variable "something" an array?
pawn Код:
new something[MAX_PLAYERS]; // as an example
Re: [Help] with variable... -
SpiderPork - 27.12.2009
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!
Re: [Help] with variable... -
BMGP - 27.12.2009
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
Re: [Help] with variable... -
Correlli - 27.12.2009
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);
Re: [Help] with variable... -
BMGP - 27.12.2009
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
Re: [Help] with variable... -
Gamer_Z - 27.12.2009
pawn Код:
new string[32];
format(string,sizeof(string),"%d - the variable",Variable[playerid]);
SendClientMessage(playerid,color,string);
Re: [Help] with variable... -
Correlli - 27.12.2009
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(...);