SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 18/10/2017, 02:46 PM   #1
0x88
Big Clucker
 
0x88's Avatar
 
Join Date: Sep 2017
Posts: 47
Reputation: 26
Default Price or item does not update

This is a item purchase script I'm going to do, when I click on item and it will be added into your cart. ItemCache has ten slots which is max_cart_item but when I click on them, it does not add to your list.

Code:
	if(GetPVarInt(playerid, "UI_Purchase"))
	{
	    new index_id = PlayerCache_GetFree(playerid);
	    for(new x = 0; x < 10; x ++)
	    {
	        if(clickedid == Store_UI[x])
	        {
	            if(PlayerCache_GetFree(playerid))
	            {
	            	PlayerInfo[playerid][ItemCache][index_id] = x;
	            	SetPVarInt(playerid, "PriceCount", GetPVarInt(playerid, "PriceCount") + ReturnItemPrice(x));
					if(PlayerInfo[playerid][ItemCache][x])
					{
					    if(GetPVarInt(playerid, "PriceCount") - ReturnItemPrice(PlayerInfo[playerid][ItemCache][index_id]) > 0)
					    {
					    	SetPVarInt(playerid, "PriceCount", GetPVarInt(playerid, "PriceCount") - ReturnItemPrice(PlayerInfo[playerid][ItemCache][index_id]));
						}
						else
						{
						    SetPVarInt(playerid, "PriceCount", 0);
						}
						PlayerInfo[playerid][ItemCache][index_id] = -1;
					}
				}
				new price[24];
				format(price, 24, "~g~$%s", MoneyFormat(GetPVarInt(playerid, "PriceCount")));
				PlayerTextDrawSetString(playerid, Store_Cart[playerid], price);
	        }
	    }
Code:
stock PlayerCache_GetFree(playerid)
{
	for(new i = 0; i < 10; i ++)
	{
		if(!PlayerInfo[playerid][ItemCache][i])
			return i+1;
	}
	return -1;
}
__________________
#offset
0x88 is offline   Reply With Quote
Old 18/10/2017, 05:06 PM   #2
AndreiWow
High-roller
 
AndreiWow's Avatar
 
Join Date: Nov 2014
Location: Romania, Bucharest
Posts: 1,050
Reputation: 48
Default Re: Price or item does not update

Did you add debug messages inside the if statements to see if the statements are returning true?
AndreiWow is offline   Reply With Quote
Old 18/10/2017, 05:24 PM   #3
0x88
Big Clucker
 
0x88's Avatar
 
Join Date: Sep 2017
Posts: 47
Reputation: 26
Default Re: Price or item does not update

Quote:
Originally Posted by AndreiWow View Post
Did you add debug messages inside the if statements to see if the statements are returning true?
I will PKcheck it out tomorrow then update the topic
__________________
#offset
0x88 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Price Item Biz Help AlexPalermitano97 Scripting Help 4 11/03/2017 10:51 PM
bag system error, item can only replace the item on slop 0 Chrisli520 Scripting Help 0 28/11/2013 08:49 PM
Item selling for $1 and not specified price Phil_Cutcliffe Scripting Help 5 03/06/2013 07:17 PM
/sell [item] [amount] [price] iGetty Scripting Help 2 05/02/2012 09:23 PM


All times are GMT. The time now is 04:58 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.