Directly add values to a 2 dimensional array ?
#1

Why will this work:
pawn Код:
new plantgrammy;
        plantgrammy = drugs[playerid][plantgrams] +5;
        drugs[playerid][plantgrams] = plantgrammy;
        dini_IntSet(connect, "plantgrams", drugs[playerid][plantgrams]);
And this not?

pawn Код:
drugs[playerid][plantgrams] + 5;
Thanks for any explanation
Reply
#2

The last piece of code doesn't assign anything. It's just an expression. You'll need to use += for your purpose
pawn Код:
drugs[ playerid ][ plantgrams ] += 5;
Reply
#3

Quote:
Originally Posted by LarzI
Посмотреть сообщение
The last piece of code doesn't assign anything. It's just an expression. You'll need to use += for your purpose
pawn Код:
drugs[ playerid ][ plantgrams ] += 5;
Thanks LarzI You know, i was just trying to play around with arrays, and i found out that it didn't compile, and i found out that arrays does not work like variables

@******:

I was not sure either about what it would do, as it didn't compile. I was just trying to add 5 into the value it was holding. So, i suppose that LarzI's Comment was correct, and that it works somehow better now


Thanks anyways! ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)