How To Add More Than One To A Variable?
#1

If I create a variable:
pawn Код:
new cookies[MAX_PLAYERS];
I know to add to the variable, you do this:
pawn Код:
cookies[playerid]++;
And to subtract, you do this:
pawn Код:
cookies[playerid]--;
But what do you do if you want to subtract more than one from the variable?

pawn Код:
cookies[playerid]+7;
Reply
#2

pawn Код:
cookies[playerid] -= 7
or
pawn Код:
cookies[playerid] += 7
this adds the value to the current value the variable has
Reply
#3

Im not totally sure, but try this
pawn Код:
cookies[playerid] + (cookies[playerid] + amount);
Edit: Sascha was first + had a better answer
Reply
#4

Quote:
Originally Posted by Sascha
Посмотреть сообщение
pawn Код:
cookies[playerid] -= 7
or
pawn Код:
cookies[playerid] += 7
this adds the value to the current value the variable has
It works! +1 Rep!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)