Jump to content

Checks won't work


Go to solution Solved by lTz,

Recommended Posts

Hi, today i added the great offline shop to my test sv so i can make one like the one from IKARUS with that base
I fixed all i can about it :
- item dupe
- the core crash
and so on

Now i'm stuck with a problem:
Even if i put some checks so you can;t buy if won price > your won is not working like when i put the same for yang, it allow me to buy with 0 won and then it goes into negative
Same if i put the check for yang/won when getting the money from shop and goldget > maxgold -1 so i don't get them if yang overflow
it should not give me the money and give an lc_text and a return, but it give me the money more like the money disapear

Here are some lines of code where i have the checks :

 

shop.cpp

int CShop::Buy(LPCHARACTER ch, BYTE pos)
{
	if (r_item.price < 0)
	{
		LogManager::instance().HackLog("SHOP_BUY_GOLD_OVERFLOW", ch);
		return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
	}

#ifdef __ENABLE_CHEQUE_SYSTEM__
	if (r_item.cheque < 0)
	{
		LogManager::instance().HackLog("SHOP_BUY_CHEQUE_OVERFLOW", ch);
		return SHOP_SUBHEADER_GC_NOT_ENOUGH_CHEQUE;
	}
#endif
#ifdef __ENABLE_CHEQUE_SYSTEM__
	if ((int)dwPrice>0 && (int)dwCheque > 0) // Yang-Cheque
	{
		if (ch->GetGold() < (int)dwPrice || ch->GetCheque() < (int)dwCheque)
			return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY_CHEQUE;
	}
	else if ((int)dwPrice>0 && (int)dwCheque <= 0) // Yang
	{
		if (ch->GetGold() < (int)dwPrice)
			return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
	}
	else if ((int)dwPrice<=0 && (int)dwCheque > 0) // cheque
	{
		if (ch->GetCheque() < (int)dwCheque)
			return SHOP_SUBHEADER_GC_NOT_ENOUGH_CHEQUE;
	}
#else
	if (ch->GetGold() < r_item.price)
	{
		sys_log(1, "Shop::Buy : Not enough money : %s has %d, price %d", ch->GetName(), ch->GetGold(), dwPrice);
		return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
	}
#endif
}
cmd_general.cpp

bool GetGift(LPCHARACTER ch, DWORD id,bool all=false)
{
#ifdef FULL_YANG
				long long nTotalMoney = ch->GetGold()+count;

				if (nTotalMoney > GOLD_MAX-1)
				{
					sys_err("[OVERFLOW_GOLD] To much (GOLD_MAX) id %u name %s total: %lld", ch->GetPlayerID(), ch->GetName(), nTotalMoney);
					ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have to much yang!."));
					return;
				}
#endif
#ifdef FULL_YANG
				long long nTotalMoney = ch->GetCheque() + count;

				if (CHEQUE_MAX <= nTotalMoney)
				{
					sys_err("[OVERFLOW_CHEQUE] Overflow (CHEQUE_MAX) id %u name %s", ch->GetPlayerID(), ch->GetName());
					ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] You cannot exceed the limit of 99 won."));
					return true;
				}
#endif

}


As you can see from this checks it should work , but not:))
Any idea why ?

Ty all

Link to comment
https://metin2.dev/topic/32068-checks-wont-work/
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

so i fixed the part with the yang and won overflow
 

cmd_general and shop

					long nTotalCheque = ch->GetCheque() + gold;

					if (CHEQUE_MAX <= nTotalCheque)
					{
						sys_err("[OVERFLOW_GOLD] Overflow (GOLD_MAX) id %u name %s", ch->GetPlayerID(), ch->GetName());
						ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("To much won."));
						return true;
					}
					long long nTotalMoney = ch->GetGold()+count;

                    if (nTotalMoney > GOLD_MAX - 1)
                    {
                        sys_err("[OVERFLOW_GOLD] To much yang (GOLD_MAX) id %u name %s sum: %lld", ch->GetPlayerID(), ch->GetName(), 								nTotalMoney);
                        ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("To much yang."));
                        return true;
                    }

but the problem with -won when i buy item with 0 won in inv remain
i added some chat txt to see if the checks work , but i get no reply

ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Not enough yang or won to buy this item."));

Ty
 

Update:

fixed the won problem with this

shop.cpp

if ((long long)dwPrice > 0 && (int)dwCheque > nTotalCheque) // Yang-Cheque
		{
			if (ch->GetGold() < (long long)dwPrice || ch->GetCheque() < (int)dwCheque)
			{
				ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Not enough yang or won to buy this item."));
				return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
			}
		}

	if ((long long)dwPrice > 0 && (int)dwCheque <= nTotalCheque) // Yang
		{
			if (ch->GetGold() < (long long)dwPrice)
			{
				ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Not enough yang to buy this item."));
				return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
			}
		}

	if ((long long)dwPrice <= 0 && (int)dwCheque > nTotalCheque) // cheque
		{
			if (ch->GetCheque() < (int)dwCheque)
				{
					ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Not enough won to buy this item."));
					return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
				}
		}


TY all

Link to comment
https://metin2.dev/topic/32068-checks-wont-work/#findComment-162661
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.