![]() |
|
New GM commands for hooking GS for tables t_regen_npc and t_shop - Printable Version +- LCKB (https://lckb.dev/forum) +-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109) +--- Forum: Guides & Help Section (https://lckb.dev/forum/forumdisplay.php?fid=193) +---- Forum: Tutorials & Guides (https://lckb.dev/forum/forumdisplay.php?fid=124) +----- Forum: Ep2 Guides (https://lckb.dev/forum/forumdisplay.php?fid=165) +----- Thread: New GM commands for hooking GS for tables t_regen_npc and t_shop (/showthread.php?tid=4055) |
- Izirayd - 10-04-2014 About command: Command: npc_regen_o .adds monsters in table t_regen_npc Parametr .ID npc .time respawn .ID zone .layer (define 0) Command: npc_shop_r .Adds NPCs with whom you trade Parametr .ID npc .ID zone .layer (define 0) .Rotation angle of the NPC . 0 - 360 Command: npc_regen_r Parametr .ID npc .time respawn .ID zone .layer (define 0) .Rotation angle of the NPC . 0 - 360 Teams should be used for development and it is not necessary to put them on the main server. It is worth remembering that when the NPC team npc_shop_r, must be unique and can not use, otherwise it will not be added to the database. nstallation: In main.h write: MYSQL OriSql; /*do_GM */ typedef void (*tGmEP2)(CPC* , CNetMsg& ;MologieDetours: etour<tGmEP2>* detour_GmEP2= NULL;In main.cpp function itself : void GmEP2(CPC* ch, CNetMsg& msg) { /* Code by Izirayd or Orion Game */ static CLCString buf(1000); msg >> buf; const char* p = buf; char g_buf2[8192]; *g_buf2 = '\0'; p = AnyOneArg((p+1), g_buf2, (true)); if (strcmp(g_buf2, "npc_regen_o") == 0) { p = AnyOneArg(p, g_buf2); int IdNPC = atoi(g_buf2); p = AnyOneArg(p, g_buf2); int RegenNPC = atoi(g_buf2); p = AnyOneArg(p, g_buf2); int iZone = atoi(g_buf2); p = AnyOneArg(p, g_buf2); int iLayer = atoi(g_buf2); sprintf(g_buf2, "INSERT INTO t_npc_regen (a_zone_num, a_npc_idx, a_pos_x, a_pos_z, a_pos_h, a_pos_r, a_y_layer, a_regen_sec, a_total_num) VALUES ( %d, %d, %f , %f, %f, %f, %d, %d, -1)", iZone, IdNPC, ch->m_pos.m_x, ch->m_pos.m_z, ch->m_pos.m_h, ch->m_pos.m_r, iLayer, RegenNPC); if (mysql_query(&OriSql, g_buf2)) { std::cout << "\nError sql: " << g_buf2; } } if (strcmp(g_buf2, "npc_regen_r") == 0) { p = AnyOneArg(p, g_buf2); int IdNPC = atoi(g_buf2); p = AnyOneArg(p, g_buf2); int RegenNPC = atoi(g_buf2); p = AnyOneArg(p, g_buf2); int iZone = atoi(g_buf2); p = AnyOneArg(p, g_buf2); int iLayer = atoi(g_buf2); p = AnyOneArg(p, g_buf2); int iR = atoi(g_buf2); sprintf(g_buf2, "INSERT INTO t_npc_regen (a_zone_num, a_npc_idx, a_pos_x, a_pos_z, a_pos_h, a_pos_r, a_y_layer, a_regen_sec, a_total_num) VALUES ( %d, %d, %f , %f, %f, %d, %d, %d, -1)", iZone, IdNPC, ch->m_pos.m_x, ch->m_pos.m_z, ch->m_pos.m_h, iR, iLayer, RegenNPC); if (mysql_query(&OriSql, g_buf2)) { std::cout << "\nError sql: " << g_buf2; } } if (strcmp(g_buf2, "npc_shop_r") == 0) { p = AnyOneArg(p, g_buf2); int IdNPC = atoi(g_buf2); p = AnyOneArg(p, g_buf2); int iZone = atoi(g_buf2); p = AnyOneArg(p, g_buf2); int iLayer = atoi(g_buf2); p = AnyOneArg(p, g_buf2); int iR = atoi(g_buf2); // Разворот sprintf(g_buf2, "INSERT INTO t_shop (a_zone_num, a_keeper_idx, a_pos_x, a_pos_z, a_pos_h, a_pos_r, a_y_layer, a_sell_rate, a_buy_rate) VALUES ( %d, %d, %f , %f, %f, %d, %d, 40, 100)", iZone, IdNPC, ch->m_pos.m_x, ch->m_pos.m_z, ch->m_pos.m_h, iR, iLayer); if (mysql_query(&OriSql, g_buf2)) { std::cout << "\nError sql: " << g_buf2; } } return detour_GmEP2->GetOriginalFunction()(ch, msg); } And at the beginning of the main function of writing void lib_main() { // ПодключаемÑÑ Ðº бд if (!mysql_init(&OriSql)) { std::cout << "\nError init sql"; return; } if (!mysql_real_connect(&OriSql, "127.0.0.1", "root", "", "e3_data", 3306, NULL, 0)) { std::cout << "\nError connect sql"; return; } try { detour_GmEP2 = simpleHook<tGmEP2>((unsigned int)0x081F5E04, GmEP2); catch(MologieDetours: etourException &e){ std::cout << std::endl << "\nError when hooking function: " << e.what() << std::endl << std::endl; } Address which hammered : 0x081F5E04 - for Ep2, if you want to ep3 looking for function and address do_GM push Thank you for your attention |