View Single Post
Old 12/06/2019, 06:36 AM   #5
Plastikmensch
Huge Clucker
 
Join Date: Aug 2016
Posts: 272
Reputation: 27
Default Re: Price or item does not update

Might be bad math. If I understand your code correctly, you check if PriceCount - ItemPrice is greater than 0.
Code:
if(PlayerInfo[playerid][ItemCache][x])
					{
					    if(GetPVarInt(playerid, "PriceCount") - ReturnItemPrice(PlayerInfo[playerid][ItemCache][index_id]) > 0)//here
					    {
					    	SetPVarInt(playerid, "PriceCount", GetPVarInt(playerid, "PriceCount") - ReturnItemPrice(PlayerInfo[playerid][ItemCache][index_id]));//Also you might want to to + instead of - here
						}
						else
						{
						    SetPVarInt(playerid, "PriceCount", 0);
						}
						PlayerInfo[playerid][ItemCache][index_id] = -1;
					}
But if you select the first item, PriceCount - ItemPrice will be 0 which will execute the else and set PriceCount to 0.
Assuming the PriceCount is the total price of all items, you might want to add and not subtract from it.

The ReturnItemPrice function is fine except you might don't want to return 1 if itemid is not inside switch.
Plastikmensch is offline   Reply With Quote