+ To Variable
#1

Hello.


How to add "more" to a variable, example:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == test)
{
testvariable[playerid] = 0; // How to set here so when you enter the pickup,
it adds "+1" to the variable without using "testvariable[playerid] = 1;"
So, if you come in the pickup twice, it sets it to "testvariable[playerid] = 2;", if you come in the pickup three times, it sets it to
testvariable[playerid] = 3;, and so on. So, how to?
}

Regards,
Assyria
Reply
#2

You mean this?

variable++;
Reply
#3

variable++;

or variable +amount;(example: test = 1 atm "test +3;" and now 4)
Reply
#4

So, for example, this should work for what I explained
Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
  if(pickupid == test)
  {
    testvariable[playerid] = ++; 
  }
Reply
#5

Like this: testvariable[playerid] +1
Reply
#6

Quote:
Originally Posted by Assyria
So, for example, this should work for what I explained
Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
  if(pickupid == test)
  {
    testvariable[playerid] = ++; 
  }
No. Like this:

pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
  if(pickupid == test)
  {
    testvariable[playerid]++;
  }
Reply
#7

Ok, thanks for replys and making this clear for me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)