Johan™ Posted August 3, 2015 Report Share Posted August 3, 2015 :vPD: antes de comenzar quiero aclarar que la parte del SQLMsg *msg; - msg = xxx la saque de elitepvpers. D: yo solo realize algunos cambios e.e.Abrimos char.cpp y al final ponemos: int CHARACTER::SetCoins(long coins) { SQLMsg *msg; msg = DBManager::instance().DirectQuery("UPDATE account.account SET coins = coins + '%ld' WHERE id = '%d'", coins, GetAID()); if (msg->uiSQLErrno != 0) { sys_err("pc_update_coins query failed"); return false; } return true; } Ahora nos vamos a char.h y abajo de bool ItemProcess_Polymorph(LPITEM item); pegamos esto. public: int SetCoins(long coins = 0); Debe quedar asi D: Ahora abrimos char_item.cpp y buscamos switch (item->GetType()) arriba de eso pegamos lo sigiente e.e switch (item->GetVnum()) { //Coins. case 80014: case 80015: case 80016: case 80017: int idx[4]; idx[0] = 100; idx[1] = 500; idx[2] = 1000; idx[3] = 50; int idxs; if (item->GetVnum() == 80014) idxs = 0; if (item->GetVnum() == 80015) idxs = 1; if (item->GetVnum() == 80016) idxs = 2; if (item->GetVnum() == 80017) idxs = 3; long val; val = idx[idxs]; if (SetCoins(val)) { ChatPacket(CHAT_TYPE_INFO, "Has cargado %ld coins a tu cuenta.",val); item->SetCount(item->GetCount() - 1); } else { ChatPacket(CHAT_TYPE_INFO, "Ha ocurrido un error al intentar cambiar tus coins, contacta con el administrador."); } return 1; break; default: break; } D: tambien pueden usar esta funciona para los lua solo usen el SetCoins(cantidad e.e) mebe, HardMetin2, tierrilopes and 2 others 5 Quote Link to comment Share on other sites More sharing options...
HardMetin2 Posted August 3, 2015 Report Share Posted August 3, 2015 Gracias, es bueno. Me gusta más que uno que vi hace un par de días Johan™ 1 Quote Link to comment Share on other sites More sharing options...
Guest Caes Posted August 3, 2015 Report Share Posted August 3, 2015 Una anotación, no pegar esto public: int SetCoins(long coins = 0); Debería quedar así: public: bool ItemProcess_Polymorph(LPITEM item); int SetCoins(long coins = 0); La razón es que dentro del bloque public: se definen todas las funciones de acceso publico y no hay necesidad de abrir varios bloques. Quote Link to comment Share on other sites More sharing options...
Johan™ Posted August 3, 2015 Author Report Share Posted August 3, 2015 Una anotación, no pegar esto public: int SetCoins(long coins = 0); Debería quedar así: public: bool ItemProcess_Polymorph(LPITEM item); int SetCoins(long coins = 0); La razón es que dentro del bloque public: se definen todas las funciones de acceso publico y no hay necesidad de abrir varios bloques. asi lo puse yo :v queria mantener el orden los feos deymir tienen varios public :v por categorias :3, solo queria ser popular e.e Quote Link to comment Share on other sites More sharing options...
Guest Caes Posted August 3, 2015 Report Share Posted August 3, 2015 Jajaja vale, muy buen aporte, gracias. Johan™ 1 Quote Link to comment Share on other sites More sharing options...
Guest DreamHQ Posted August 4, 2015 Report Share Posted August 4, 2015 Buen aporte , muchas gracias +1 (te daría chamanas , pero... no me quedan T.T) Un saludo. Johan™ 1 Quote Link to comment Share on other sites More sharing options...
Johan™ Posted August 4, 2015 Author Report Share Posted August 4, 2015 Buen aporte , muchas gracias +1 (te daría chamanas , pero... no me quedan T.T) Un saludo. PD; Gracias Jajaja vale, muy buen aporte, gracias. Gracias e.e Gracias, es bueno. Me gusta más que uno que vi hace un par de días :v Gracias Quote Link to comment Share on other sites More sharing options...
VegaS™ Posted October 21, 2016 Report Share Posted October 21, 2016 Thanks xD Small shit from long time ago if someone want: ( sorry for shit code, is from 2014 on my server) /* Ex function call with : * ExternAppendCoins(this, item); * ExternAppendCoins(ch, item); */ bool ExternAppendCoins(LPCHARACTER ch, LPITEM item) { #define MYSQL_MAX_COINS 5000 const int mListVouchers[] = { 80014, 80015, 80016, 80017 }; for (int idx = 0; idx < _countof(mListVouchers); idx++) { if (item->GetVnum() == mListVouchers[idx] && ch->CountSpecifyItem(mListVouchers[idx]) > 0) { if (ch->GetExchange() || ch->IsOpenSafebox() || ch->IsCubeOpen() || ch->GetShop() || ch->GetMyShop()) { ch->ChatPacket(CHAT_TYPE_INFO, "Have a malicious window open, please close it then you can do this."); return false; } int amount = item->GetValue(0); if (!ch->CanWarp()) ch->ChatPacket(CHAT_TYPE_INFO, "You need to wait 10 second."); return false; } if (amount <= 0) { ch->ChatPacket(CHAT_TYPE_INFO, "Not found value in mysql row value."); /* Put value on player.item_proto->vnum->value0*/ return false; } if (amount >= MYSQL_MAX_COINS) { ch->ChatPacket(CHAT_TYPE_INFO, "Mysql = %d - Max allowed = %d.", amount, MYSQL_MAX_COINS); return false; } char buf[CHAT_MAX_LEN + 1]; snprintf(buf, sizeof(buf), "UPDATE account.account SET coins = coins + %u WHERE id = %u", amount, ch->GetDesc()->GetAccountTable().id)); std::auto_ptr<SQLMsg> update(DBManager::instance().DirectQuery(buf)); ch->RemoveSpecifyItem(mListVouchers[idx], 1); } } } Johan™ 1 Quote Link to comment Share on other sites More sharing options...
Shang Posted October 21, 2016 Report Share Posted October 21, 2016 The function to set coins already did by Ymir dudes. VegaS™ 1 Quote Link to comment Share on other sites More sharing options...
VegaS™ Posted February 13, 2017 Report Share Posted February 13, 2017 The function to set coins already did by Ymir dudes. Yeah but not all people was used because name of row is called: "cash" and they are used on website/itemshop etc row "coins", but can change in 1 second but they are so bored xD Here is a small function what used packet of ymir. //@ svn/Server/game/src/char.cpp //1.) Search for: LPITEM CHARACTER::GetInventoryItem(WORD wCell) const { return GetItem(TItemPos(INVENTORY, wCell)); } //2.) Add after: #ifdef ENABLE_TICKET_COINS /* * IF YOU HAVE TYPE QUEST ON ITEM JUST RUN THIS QUERY: * UPDATE player.item_proto set type = 3 WHERE 80014 <= vnum and vnum <= 80017; */ void CHARACTER::InsertCoins(LPITEM item) { typedef std::map<DWORD,DWORD> TMapTicketValues; TMapTicketValues cash; cash[80014] = 100; cash[80015] = 500; cash[80016] = 1000; cash[80017] = 5000; DWORD dwVnum = item->GetVnum(); itertype(cash) iterator = cash.find(dwVnum); if (iterator != cash.end()) { TRequestChargeCash p; p.dwAID = GetDesc()->GetAccountTable().id; p.dwAmount = cash[dwVnum]; p.eChargeType = ERequestCharge_Cash; db_clientdesc->DBPacketHeader(HEADER_GD_REQUEST_CHARGE_CASH, 0, sizeof(TRequestChargeCash)); db_clientdesc->Packet(&p, sizeof(p)); RemoveSpecifyItem(dwVnum, 1); LogManager::instance().CharLog(this, cash[dwVnum], "USE_TICKET_COINS", ""); if (test_server) ChatPacket(CHAT_TYPE_NOTICE, "CHARACTER::InsertCoins: vnum %d | cash %d", dwVnum, cash[dwVnum]); } } #endif //1.) Search for: sys_log(0, "%s: USE_ITEM %s (inven %d, cell: %d)", GetName(), item->GetName(), window_type, wCell); //2.) Add after: #ifdef ENABLE_TICKET_COINS InsertCoins(item); #endif //@ svn/Server/game/src/char.h //1.) Search for: const char * GetName() const; //2.) Add after: #ifdef ENABLE_TICKET_COINS void InsertCoins(LPITEM item); #endif //@ svn/Server/common/service.h #define ENABLE_TICKET_COINS Shang and SzC 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.