kamil2321

Kupowanie itemów walutą itemową :D

Feb 18th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.30 KB | None | 0 0
  1. common/service.h:
  2. #define ENABLE_BUY_WITH_ITEM
  3. common/tables.h:
  4. // Ara:
  5. typedef struct SShopItemTable
  6.  
  7. // İçine ekle:
  8. #ifdef ENABLE_BUY_WITH_ITEM
  9. DWORD witemVnum;
  10. #endif
  11. game/packet.h:
  12. // Ara:
  13. SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY
  14.  
  15. // Altına ekle:
  16. #ifdef ENABLE_BUY_WITH_ITEM
  17. SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM,
  18. #endif
  19.  
  20. // Ara:
  21. struct packet_shop_item
  22.  
  23. // İçine ekle:
  24. #ifdef ENABLE_BUY_WITH_ITEM
  25. DWORD witemVnum;
  26. #endif
  27. game/shop.cpp:
  28. // void CShop::SetShopItems(TShopItemTable * pTable, BYTE bItemCount) Fonksiyonun içinde ara:
  29. item.price = pTable->price; // yada
  30. item.count = pTable->count; // hangisi varsa
  31.  
  32. // Altına ekle:
  33. #ifdef ENABLE_BUY_WITH_ITEM
  34. item.witemVnum = pTable->witemVnum;
  35. #endif
  36.  
  37. // int CShop::Buy( fonksiyonunun içinde ara:
  38. DWORD dwPrice = r_item.price;
  39.  
  40. // Altına ekle:
  41. #ifdef ENABLE_BUY_WITH_ITEM
  42. DWORD dwWItemVnum = r_item.witemVnum;
  43. #endif
  44.  
  45. // Arat:
  46. if (ch->GetGold() < (int) dwPrice)
  47. {
  48. sys_log(1, "Shop::Buy : Not enough money : %s has %d, price %d", ch->GetName(), ch->GetGold(), dwPrice);
  49. return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
  50. }
  51.  
  52. // Değiştir:
  53. #ifdef ENABLE_BUY_WITH_ITEM
  54. if (dwWItemVnum > 0)
  55. if (ch->CountSpecifyItem(dwWItemVnum) < (int)dwPrice)
  56. return SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM;
  57. else if (ch->GetGold() < (int) dwPrice)
  58. #else
  59. if (ch->GetGold() < (int) dwPrice)
  60. #endif
  61.  
  62. // Arat:
  63. ch->PointChange(POINT_GOLD, -dwPrice, false);
  64.  
  65. // Değiştir:
  66. #ifdef ENABLE_BUY_WITH_ITEM
  67. if (dwWItemVnum > 0)
  68. ch->RemoveSpecifyItem(dwWItemVnum, dwPrice);
  69. else
  70. ch->PointChange(POINT_GOLD, -dwPrice, false);
  71. #else
  72. ch->PointChange(POINT_GOLD, -dwPrice, false);
  73. #endif
  74.  
  75. // Arat:
  76. pack2.items[i].price = item.price;
  77.  
  78. // Altına ekle:
  79. #ifdef ENABLE_BUY_WITH_ITEM
  80. pack2.items[i].witemVnum = item.witemVnum;
  81. #endif
  82.  
  83. // Arat:
  84. else if (!m_pkPC && !IsPCShop())
  85.  
  86. // İçine ekle:
  87. #ifdef ENABLE_BUY_WITH_ITEM
  88. pack2.item.witemVnum = m_itemVector[pos].witemVnum;
  89. #endif
  90. game/shop.h:
  91. // Arat:
  92. shop_item()
  93.  
  94. // Üstüne ekle:
  95. #ifdef ENABLE_BUY_WITH_ITEM
  96. DWORD witemVnum;
  97. #endif
  98.  
  99. // Arat:
  100. pkItem = NULL;
  101.  
  102. // Üstüne ekle:
  103. #ifdef ENABLE_BUY_WITH_ITEM
  104. witemVnum = 0;
  105. #endif
  106. db/ClientManagerBoot.cpp:
  107. // Arat:
  108. "shop_item.count "
  109.  
  110. // Altına ekle:
  111. #ifdef ENABLE_BUY_WITH_ITEM
  112. ",shop_item.witemVnum "
  113. #endif
  114.  
  115. // Arat:
  116. str_to_number(pItem->count, data[col++]);
  117.  
  118. // Altına ekle:
  119. #ifdef ENABLE_BUY_WITH_ITEM
  120. str_to_number(pItem->witemVnum, data[col++]);
  121. #endif
  122.  
  123. Client Source:​
  124.  
  125. Locale_inc.h:
  126. #define ENABLE_BUY_WITH_ITEM
  127. GameType.h:
  128. // Arat:
  129. typedef struct packet_shop_item
  130.  
  131. // İçine ekle:
  132. #ifdef ENABLE_BUY_WITH_ITEM
  133. DWORD witemVnum;
  134. #endif
  135. PythonApplicationModule.cpp:
  136. #ifdef ENABLE_BUY_WITH_ITEM
  137. PyModule_AddIntConstant(poModule, "ENABLE_BUY_WITH_ITEM", 1);
  138. #else
  139. PyModule_AddIntConstant(poModule, "ENABLE_BUY_WITH_ITEM", 0);
  140. #endif
  141. PythonNetworkStreamPhaseGame.cpp:
  142. // Arat:
  143. case SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY:
  144. PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnShopError", Py_BuildValue("(s)", "NOT_ENOUGH_MONEY"));
  145. break;
  146.  
  147. // Altına ekle:
  148. #ifdef ENABLE_BUY_WITH_ITEM
  149. case SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM:
  150. PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnShopError", Py_BuildValue("(s)", "NOT_ENOUGH_ITEM"));
  151. break;
  152. #endif
  153. PythonShop.cpp:
  154. // Arat:
  155. PyObject * shopGetItemMetinSocket(PyObject * poSelf, PyObject * poArgs)
  156.  
  157. // Altına ekle:
  158. #ifdef ENABLE_BUY_WITH_ITEM
  159. PyObject * shopGetBuyWithItem(PyObject * poSelf, PyObject * poArgs)
  160. {
  161. int nPos;
  162. if (!PyTuple_GetInteger(poArgs, 0, &nPos))
  163. return Py_BuildException();
  164.  
  165. const TShopItemData * c_pItemData;
  166. if (CPythonShop::Instance().GetItemData(nPos, &c_pItemData))
  167. return Py_BuildValue("i", c_pItemData->witemVnum);
  168.  
  169. return Py_BuildValue("i", 0);
  170. }
  171. #endif
  172.  
  173. // Arat:
  174. { "GetItemMetinSocket", shopGetItemMetinSocket, METH_VARARGS },
  175.  
  176. // Altına ekle:
  177. #ifdef ENABLE_BUY_WITH_ITEM
  178. { "GetBuyWithItem", shopGetBuyWithItem, METH_VARARGS },
  179. #endif
  180. Packet.h:
  181. // Arat:
  182. typedef struct SShopItemTable
  183.  
  184. // İçine ekle:
  185. #ifdef ENABLE_BUY_WITH_ITEM
  186. DWORD witemVnum;
  187. #endif
  188.  
  189. // Arat:
  190. SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY,
  191.  
  192. // Altına ekle:
  193. #ifdef ENABLE_BUY_WITH_ITEM
  194. SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM,
  195. #endif
  196. Python:​
  197. root/localeinfo.py:
  198. # Arat:
  199. SHOP_ERROR_DICT = {
  200.  
  201. # Altına veya üstüne ekle:
  202. if app.ENABLE_BUY_WITH_ITEM:
  203. SHOP_ERROR_DICT.update({
  204. "NOT_ENOUGH_ITEM" : SHOP_NOT_ENOUGH_ITEM,
  205. }
  206. )
  207.  
  208. # Arat:
  209. def NumberToMoneyString(n):
  210.  
  211. # Altına ekle:
  212. if app.ENABLE_BUY_WITH_ITEM:
  213. def NumberToWithItemString(n,c) :
  214. if n <= 0 :
  215. return "0 %s" % (c)
  216. return "%s adet | %s" % ('.'.join([ i-3<0 and str(n)[:i] or str(n)[i-3:i] for i in range(len(str(n))%3, len(str(n))+1, 3) if i ]), c)
  217. root/uishop.py:
  218. # def AskBuyItem(self, slotPos): fonksiyonu içinde ara:
  219. itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
  220.  
  221. # Değiştir:
  222. if app.ENABLE_BUY_WITH_ITEM:
  223. buyItemVnum = shop.GetBuyWithItem(slotPos)
  224. if buyItemVnum != 0:
  225. item.SelectItem(buyItemVnum)
  226. istenenItemAd = item.GetItemName()
  227. itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToWithItemString(itemPrice, istenenItemAd)))
  228. else:
  229. itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
  230. else:
  231. itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
  232. root/uitooltip.py:
  233. # def SetShopItem veya shopEx kullananlar için SetShopExItem fonksiyonu içinde ara:
  234. else:
  235. self.AppendPrice(price)
  236.  
  237. # Değiştir:
  238. elif app.ENABLE_BUY_WITH_ITEM:
  239. buyItemVnum = shop.GetBuyWithItem(slotIndex)
  240. if buyItemVnum != 0:
  241. item.SelectItem(buyItemVnum)
  242. istenenItemAd = item.GetItemName()
  243. istenenItemVnum = item.GetVnum()
  244. self.AppendPrice_WithItem(price, istenenItemVnum, istenenItemAd)
  245. else:
  246. self.AppendPrice(price)
  247. else:
  248. self.AppendPrice(price)
  249.  
  250. # Müsait bir yere ekle:
  251. if app.ENABLE_BUY_WITH_ITEM:
  252. def AppendTextLine_WithItem(self, text, image, color = FONT_COLOR):
  253. ayraC = text.split("|")
  254. resimdenOnce, resimdenSonra = (ayraC[0], ayraC[1])
  255. textLine = ui.TextLine()
  256. textLine.SetParent(self)
  257. textLine.SetFontName(self.defFontName)
  258. textLine.SetPackedFontColor(color)
  259. textLine.SetText(resimdenOnce)
  260. textLine.SetOutline()
  261. textLine.SetFeather(FALSE)
  262.  
  263. itemIcon = ui.ImageBox()
  264. itemIcon.SetParent(self)
  265. itemIcon.LoadImage(image)
  266.  
  267. textLine2 = ui.TextLine()
  268. textLine2.SetParent(self)
  269. textLine2.SetFontName(self.defFontName)
  270. textLine2.SetPackedFontColor(color)
  271. textLine2.SetText(resimdenSonra)
  272. textLine2.SetOutline()
  273. textLine2.SetFeather(FALSE)
  274.  
  275. textLine.Show()
  276. itemIcon.Show()
  277. textLine2.Show()
  278.  
  279. baslangicX_a = self.GetWidth() / 2 - 75
  280. baslangicX_b = textLine.GetTextSize()[0]
  281. baslangicX_c = itemIcon.GetWidth()
  282.  
  283. textLine.SetPosition(baslangicX_a, self.toolTipHeight+6)
  284. itemIcon.SetPosition(baslangicX_a + baslangicX_b, self.toolTipHeight)
  285. textLine2.SetPosition(baslangicX_a + baslangicX_b + baslangicX_c, self.toolTipHeight+6)
  286.  
  287. self.childrenList.append(textLine)
  288. self.childrenList.append(itemIcon)
  289. self.childrenList.append(textLine2)
  290.  
  291. self.toolTipHeight += itemIcon.GetHeight()
  292. self.ResizeToolTip()
  293.  
  294. return textLine
  295. return itemIcon
  296. return textLine2
  297.  
  298. if app.ENABLE_BUY_WITH_ITEM:
  299. def AppendPrice_WithItem(self, price, itemVnum, itemName):
  300. self.AppendSpace(5)
  301. self.AppendTextLine("[Nesne ile satın alınabilir]" , self.SHOP_ITEM_COLOR)
  302. item.SelectItem(itemVnum)
  303. eklenecekIcon = item.GetIconImageFileName()
  304. self.AppendTextLine_WithItem((localeInfo.NumberToWithItemString(price, itemName)), eklenecekIcon, self.GetPriceColor(price))
  305. locale/locale_game.txt:
  306. SHOP_NOT_ENOUGH_ITEM Yeterli Nesne'ye sahip değilsin.
  307.  
  308. #### Pentru a funcționa se face în navicat o coloană nouă în db-ul "player" la shop_item cu numele "witemVnum"
  309. Alte info: Prețul itemului = count eg. dacă ai 1 yang pus ca preț în item_proto la item și pui la witemvnum x5, yang ul va fi x5
Add Comment
Please, Sign In to add comment