Harvest question
#3

If the current amount of the player's inventory plus the amount in the plant exceeds the maximum, subtract the current amount the player has from the maximum (50 - 30).

This is the amount that fits in the inventory without exceeding the limit.

Simply add it to the inventory and subtract it from the plant.

50 (limit) - 30 (inventory) = 20 free inventory space

50 (plant) - 20 (free inventory space) = 30 left in the plant

30 (inventory) + 20 (collected) = 50 in inventory

Код:
new transfer = MAX_INVENTORY_SPACE - Player[playerid][MarijuanaGrams]; // Calculate difference

if(transfer < PlantData[plantid][plantDrugs]) // If less than the plant's capacity can be transfered, only transfer what fits into the inventory (which is the difference between the limit and current amount (the transfer variable))
{
    PlantData[plantid][plantDrugs] -= transfer;
    Player[playerid][MarijuanaGrams] += transfer;
}
else // Otherwise transfer all of it.
{
    Player[playerid][MarijuanaGrams] += PlantData[plantid][plantDrugs];
    PlantData[plantid][plantDrugs] = 0;
}
Reply


Messages In This Thread
Harvest question - by KinderClans - 10.09.2018, 17:47
Re: Harvest question - by Undef1ned - 10.09.2018, 23:32
Re: Harvest question - by NaS - 11.09.2018, 01:02
Re: Harvest question - by KinderClans - 11.09.2018, 07:39

Forum Jump:


Users browsing this thread: 1 Guest(s)