SA-MP Forums Archive
How To Add More Than One To A 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: How To Add More Than One To A Variable? (/showthread.php?tid=275375)



How To Add More Than One To A Variable? - Tigerbeast11 - 09.08.2011

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;



Re: How To Add More Than One To A Variable? - Sascha - 09.08.2011

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


Re: How To Add More Than One To A Variable? - Wesley221 - 09.08.2011

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


Re: How To Add More Than One To A Variable? - Tigerbeast11 - 09.08.2011

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!