[C++]New lingouri din sursa

Avatar utilizator
stilledanger
Mister Just4Metin

Mister Just4Metin
Mesaje: 993
Membru din: 31 Ian 2014, 22:30
Server: somthegame.com
Aprecieri: 5  
Mulţumiri: 100  
 Contact:
Medalii

Salut, deschidem char_item.cpp si cautam bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
Apoi adaugam la finalul functiei urmatorul cod:

Cod: Selectaţi tot

	if (item->GetVnum() >= 80003 && item->GetVnum() <= 80007)
	{
		int  VnumLingouri[] = {80003, 80004, 80005, 80006, 80007};
		long SumaLingouri[] = {10000000, 50000000, 100000000, 500000000, 1000000000};
		
		for (int i = 0; i < _countof(VnumLingouri); i++)
		{
			if (item->GetVnum() == VnumLingouri[i])
			{
				if (GetExchange())
				{
					ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti să deschizi un lingou cât timp negociezi."));
					return false;
				}
				else
				item->SetCount(item->GetCount() - 1);
				PointChange(POINT_GOLD, SumaLingouri[i], true);
				return true;
			}
		}
		return false;
	}
Varianta cu limita de Yang

Cod: Selectaţi tot

	if (item->GetVnum() >= 80003 && item->GetVnum() <= 80007)
	{
		int  VnumLingouri[] = {80003, 80004, 80005, 80006, 80007};
		long SumaLingouri[] = {10000000, 50000000, 100000000, 500000000, 1000000000};
		long MaxiLingouri[] = {1989999999, 1949999999, 1899999999, 1499999999, 999999999};

		for (int i = 0; i < _countof(VnumLingouri); i++)
		{
			if (item->GetVnum() == VnumLingouri[i])
			{
				if (GetExchange())
				{
					ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti s? deschizi un lingou cat timp negociezi."));
					return false;
				}			
				else
				{
					if (item->GetVnum() == VnumLingouri[i] && GetGold()>= MaxiLingouri[i])
					{
						ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul pentru ca ai prea mult yang in inventar !"));
						return false;
					}
					if (item->GetVnum() == VnumLingouri[i+1] && GetGold()>= MaxiLingouri[i+1])
					{
						ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul pentru ca ai prea mult yang in inventar !"));
						return false;
					}
					if (item->GetVnum() == VnumLingouri[i+2] && GetGold()>= MaxiLingouri[i+2])
					{
						ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul pentru ca ai prea mult yang in inventar !"));
						return false;
					}
					if (item->GetVnum() == VnumLingouri[i+3] && GetGold()>= MaxiLingouri[i+3])
					{
						ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul pentru ca ai prea mult yang in inventar !"));
						return false;
					}
					if (item->GetVnum() == VnumLingouri[i+4] && GetGold()>= MaxiLingouri[i+4])
					{
						ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul pentru ca ai prea mult yang in inventar !"));
						return false;
					}
					else
					{
						item->SetCount(item->GetCount() - 1);
						PointChange(POINT_GOLD, SumaLingouri[i], true);
						return true;
					}
				}
			}
		}
		return false;
	}
Bafta!
Ultima oară modificat 12 Iul 2017, 12:17 de către stilledanger, modificat de 2 ori în total.
Player Unknown tot eu sunt
Fost Super Moderator / Moderator / Trial-Moderator la Just4Metin
Fost dezvoltator la Zearth2 & ThunderWorld2
Afișează semnătura
Avatar utilizator
Speachless
Deţinător Server

Deţinător Server
Mesaje: 1895
Membru din: 22 Iul 2014, 00:52
Server: Calliope2
Regat: Shinsoo
Aprecieri: 206  
Mulţumiri: 173  
 Contact:
Medalii

Inca nu am ajuns sa implementez, dar pentru a respira mai usor
merge adaugat si :

Cod: Selectaţi tot

if (IsOpenSafebox() || GetExchange() || GetMyShop() || IsCubeOpen())
Sterge asta ca apare deja de la PointChange.

Cod: Selectaţi tot

 ChatPacket(CHAT_TYPE_INFO, "Ai primit %ld Yang.", SumaLingouri[i]);
Si trebuie facuta verificarea de max yang in inventar.
Like any god, I have my own bible and it is called the terms of use.
Imagine
Afișează semnătura
Avatar utilizator
stilledanger
Mister Just4Metin

Mister Just4Metin
Mesaje: 993
Membru din: 31 Ian 2014, 22:30
Server: somthegame.com
Aprecieri: 5  
Mulţumiri: 100  
 Contact:
Medalii

Dobrescu Sebastian scrie:Inca nu am ajuns sa implementez, dar pentru a respira mai usor
merge adaugat si :

Cod: Selectaţi tot

if (IsOpenSafebox() || GetExchange() || GetMyShop() || IsCubeOpen())
Sterge asta ca apare deja de la PointChange.

Cod: Selectaţi tot

 ChatPacket(CHAT_TYPE_INFO, "Ai primit %ld Yang.", SumaLingouri[i]);
Si trebuie facuta verificarea de max yang in inventar.
Mersi de atentionare :). Am uitat ca POINT_GOLD este definit

Update

Cod: Selectaţi tot

	if (item->GetVnum() >= 80003 && item->GetVnum() <= 80007)
	{
		int  VnumLingouri[] = {80003, 80004, 80005, 80006, 80007};
		long SumaLingouri[] = {10000000, 50000000, 100000000, 500000000, 1000000000};
		long MaxiLingouri[] = {1989999999, 1949999999, 1899999999, 1499999999, 999999999};

		for (int i = 0; i < _countof(VnumLingouri); i++)
		{
			if (item->GetVnum() == VnumLingouri[i])
			{
				if (GetExchange())
				{
					ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti s? deschizi un lingou cat timp negociezi."));
					return false;
				}			
				else
				{
					if (item->GetVnum() == VnumLingouri[i] && GetGold()>= MaxiLingouri[i])
					{
						ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul pentru ca ai prea mult yang in inventar !"));
						return false;
					}
					if (item->GetVnum() == VnumLingouri[i+1] && GetGold()>= MaxiLingouri[i+1])
					{
						ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul pentru ca ai prea mult yang in inventar !"));
						return false;
					}
					if (item->GetVnum() == VnumLingouri[i+2] && GetGold()>= MaxiLingouri[i+2])
					{
						ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul pentru ca ai prea mult yang in inventar !"));
						return false;
					}
					if (item->GetVnum() == VnumLingouri[i+3] && GetGold()>= MaxiLingouri[i+3])
					{
						ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul pentru ca ai prea mult yang in inventar !"));
						return false;
					}
					if (item->GetVnum() == VnumLingouri[i+4] && GetGold()>= MaxiLingouri[i+4])
					{
						ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul pentru ca ai prea mult yang in inventar !"));
						return false;
					}
					else
					{
						item->SetCount(item->GetCount() - 1);
						PointChange(POINT_GOLD, SumaLingouri[i], true);
						return true;
					}
				}
			}
		}
		return false;
	}
Player Unknown tot eu sunt
Fost Super Moderator / Moderator / Trial-Moderator la Just4Metin
Fost dezvoltator la Zearth2 & ThunderWorld2
Afișează semnătura
Avatar utilizator
.Jose
Nivel 1

Nivel 1
Mesaje: 72
Membru din: 08 Apr 2017, 15:35
Aprecieri: 4  
Mulţumiri: 32  
Medalii

Cod: Selectaţi tot

	if (GetGold() + SumaLingouri[i] >= GOLD_MAX)
	{
		ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul pentru ca ai prea mult yang in inventar !"));
		return false;
	}
Imagine
Afișează semnătura
Avatar utilizator
stilledanger
Mister Just4Metin

Mister Just4Metin
Mesaje: 993
Membru din: 31 Ian 2014, 22:30
Server: somthegame.com
Aprecieri: 5  
Mulţumiri: 100  
 Contact:
Medalii

.Jose scrie:

Cod: Selectaţi tot

	if (GetGold() + SumaLingouri[i] >= GOLD_MAX)
	{
		ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul pentru ca ai prea mult yang in inventar !"));
		return false;
	}
Se face bug am incercat si cu asta... poti deschide lingourile, dar nu iti baga banii...
Player Unknown tot eu sunt
Fost Super Moderator / Moderator / Trial-Moderator la Just4Metin
Fost dezvoltator la Zearth2 & ThunderWorld2
Afișează semnătura
Avatar utilizator
.Jose
Nivel 1

Nivel 1
Mesaje: 72
Membru din: 08 Apr 2017, 15:35
Aprecieri: 4  
Mulţumiri: 32  
Medalii

stilledanger scrie:
.Jose scrie:

Cod: Selectaţi tot

	if (GetGold() + SumaLingouri[i] >= GOLD_MAX)
	{
		ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul pentru ca ai prea mult yang in inventar !"));
		return false;
	}
Se face bug am incercat si cu asta... poti deschide lingourile, dar nu iti baga banii...
am sa ma folosesc de ce a postat cataclismo ieri, pentru ca a aratat o metoda mai buna

am mai adagat si verificarile pe care le-a mentionat dobrescu si am verificat sa nu depaseasca yangul maxim
merge totul bine
edit: da e adevarat daca ai sume de ~150kk in sus se face bugul de care zici tu din cauza la overflow, eu nu m-am gandit decat la valorile default cum sunt ele pe lingou
Ultima oară modificat 20 Iul 2017, 17:35 de către .Jose, modificat 1 dată în total.
Imagine
Afișează semnătura
Avatar utilizator
stilledanger
Mister Just4Metin

Mister Just4Metin
Mesaje: 993
Membru din: 31 Ian 2014, 22:30
Server: somthegame.com
Aprecieri: 5  
Mulţumiri: 100  
 Contact:
Medalii

Eu am testat cu functia if (GetGold() + SumaLingouri >= GOLD_MAX) si aveam bug, gen daca era peste disparea lingoul si nu dadeau yang-ul.
Testeaza cu sume mai mari ca o sa ai bug, cel putin eu am avut.
Player Unknown tot eu sunt
Fost Super Moderator / Moderator / Trial-Moderator la Just4Metin
Fost dezvoltator la Zearth2 & ThunderWorld2
Afișează semnătura
Avatar utilizator
Speachless
Deţinător Server

Deţinător Server
Mesaje: 1895
Membru din: 22 Iul 2014, 00:52
Server: Calliope2
Regat: Shinsoo
Aprecieri: 206  
Mulţumiri: 173  
 Contact:
Medalii

Nu trebuie sa fie pe valoare exacta gen daca ai 1 500 000 000 yang sa iti poata da inca 500.000.000 pentru ca nu iti va da, iar lingoul va fi luat. Trebuie.. hai sa zicem un minim de 100 yang scazut din 1 500 000 000 si in felul asta nicio eroare nu va aparea.
Like any god, I have my own bible and it is called the terms of use.
Imagine
Afișează semnătura
Avatar utilizator
stilledanger
Mister Just4Metin

Mister Just4Metin
Mesaje: 993
Membru din: 31 Ian 2014, 22:30
Server: somthegame.com
Aprecieri: 5  
Mulţumiri: 100  
 Contact:
Medalii

Dobrescu Sebastian scrie:Nu trebuie sa fie pe valoare exacta gen daca ai 1 500 000 000 yang sa iti poata da inca 500.000.000 pentru ca nu iti va da, iar lingoul va fi luat. Trebuie.. hai sa zicem un minim de 100 yang scazut din 1 500 000 000 si in felul asta nicio eroare nu va aparea.
Varianta mea merge ok, am testat si este merge bine
Player Unknown tot eu sunt
Fost Super Moderator / Moderator / Trial-Moderator la Just4Metin
Fost dezvoltator la Zearth2 & ThunderWorld2
Afișează semnătura
Avatar utilizator
AlecsG
Nou Venit

Nou Venit
Mesaje: 13
Membru din: 12 Apr 2014, 11:47
Server: Metin2Ery.com
Regat: Jinno
Aprecieri: 4  
Mulţumiri: 0
Medalii

Super!Multumesc
Închis
Răspunsuri
1
Vizualizări
358
Răspunsuri
1
Vizualizări
196
Răspunsuri
9
Vizualizări
825

Înapoi la “Arhivă”

  • Informaţie
  • Cine este conectat

    Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 1 vizitator