Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/23/16 in all areas

  1. M2 Download Center Download Here ( Internal ) I made this little tutorial with function at his request @Mind Rapist Link download: [Hidden Content] Here is method for check xD (example for game.py) if app.ENABLE_CHECK_IF_SAFEBOX_OPEN: onPressKeyDict[app.DIK_F5] = lambda : self.BINARY_Check_Safebox() if app.ENABLE_CHECK_IF_SAFEBOX_OPEN: def BINARY_Check_Safebox(self): import safebox if safebox.isOpen(): chat.AppendChat(chat.CHAT_TYPE_INFO, "<<Debug from VegaS>> Safebox is open!") else: chat.AppendChat(chat.CHAT_TYPE_INFO, "<<Debug from VegaS>> Safebox is not open!") Have fun
    3 points
  2. M2 Download Center Download Here ( Internal ) Hi everybody! Tired of chaotic servers just because someone broke into a gm account? With the following guide we'll stop that once and for all! 1.) What's the idea behind that? Most systems (I can't imagine any system who doesn't do it at least a little bit like this) allow you to elevate processes or users and temporarily grant them higher permissions. Metin2 doesn't do something like that. If you get into a gm account (and you don't use ip binding which in most cases is useless) you'll most likely get full access to his permissions. Though many admins do limit the rights of their team members, some are left with higher permissions and you never know what happens. So what to do? We implement such an elevation system into metin2. It's nothing that big. We just simply add a new column to our gmlist. This will store a special password for every gamemaster. If there's no special password set, elevation won't have any effect and the user is left with special permissions permanently. If you log in, you'll have to further use the new su-command to elevate yourself. This command takes the password as an argument. If it's the correct password, the player will be elevated for the current session. If he logs out, he'll have to run su again. Without su, he won't be able to use any of his privileges. Most important are IMPLEMENTOR characters. LOW_WIZARD most likely won't need elevation so you can simply leave the password field blank for those guys. Additionally on testing environments you can specify a special passphrase. People can't use gm commands unless they elevate with using su and providing it with your passphrase - but they will be able to have every other feature of your testing environment (e. g. debug logs, shorter waiting times etc..) But enough of that! Let's get the party started! After each section you will be able to compile your game and test it. 2.) What do we need to edit? - char.h - char.cpp - cmd_general.cpp - config.cpp - config.h 3.) Add elevation status In this section we will add the elevation status as a bool variable. Files to be edited: - char.cpp - char.h Open char.h Find DWORD m_dwLastGoldDropTime; and add: bool bIsElevated; Add the following functions in any public-section below: void SetElevation(bool elevate) { bIsElevated = elevate; } bool GetElevation() { return bIsElevated; } Now close char.h and open char.cpp Find m_dwLastGoldDropTime = 0; and add below: bIsElevated = false; That's all! Compile it and you'll notice.. Nothing. We just simply add a new variable. Well. At least it's a beginning! 4.) Manage elevation In this section we will allow people to use the su command for elevation. It won't ask for a password yet, that'll be added in the next section. Files to be edited: - char.cpp - char.h - cmd.cpp - cmd_general.cpp Note: We edit cmd_general because users will get normal privileges when logging in. So restricting the command to gamemaster doesn't make any sense. Though the command will do nothing unless they really have privileges (that's why we need a new command to determine if the player using su actually can receive higher privileges. First open char.cpp and find the following function: BYTE CHARACTER::GetGMLevel() const First remove the const at the end of the declaration (also make sure you remove it at char.h). Add at the beginning of the function the following statement: if(GetElevation() == false) return GM_PLAYER; By now people won't receive the status of a gm anymore. They first have to elevate. But how? Let's do this! First close char.cpp Open cmd.cpp and add the following ACMD anywhere near the ACMD section: ACMD (do_elevate); Now add the following entry to the cmd list: { "su", do_elevate, 0, POS_DEAD, GM_PLAYER }, Close cmd.cpp and open cmd_general.cpp. There you can add the following function: ACMD(do_elevate) { if(ch->GetElevation()==true) return; ch->SetElevation(true); ch->ChatPacket(CHAT_TYPE_INFO, "You have been elevated!"); } That'll allow our players to elevate. But! We don't want normal players to elevate. So we need something to determine if they are worthy at all. We need a true function that displays the gm level without having any impact on the source itself. We'll add that! First open char.cpp and add our new function: BYTE CHARACTER::GetRealGMLevel() const { if (test_server) return GM_IMPLEMENTOR; return m_pointsInstant.gm_level; } Note that this function is const (unlike our new GetGMLevel() function) Also add this function inside a public part of your char.h: BYTE GetRealGMLevel() const; Now we can close char.h and char.cpp. Open cmd_general.cpp and edit our function. Add to the beginning of it: if(ch->GetRealGMLevel() == GM_PLAYER) return; That's all! Compile and Test it. By now the following should occur: At login you won't have gm permission. You will be able to use the su command. By doing so, you'll receive a message that you have been elevated. If you are a normal player, elevation won't work. There's currently no special password or passphrase. 5.) Securing elevation In this part we'll add a passphrase to our gmlist! What we need to edit: - char.cpp - char.h - cmd_general.cpp But first we need to run the following SQL statement: ALTER TABLE common.gmlist ADD passphrase varchar(45) DEFAULT ""; You can now give your gm characters a special passphrase. How you build up your passphrase is up to you (plain text is not recommended! Best solution is something like salt + mysql password function). For this guide I'll just use the mysql password function but you'd adapt it to your needs Example query to set a passphrase: UPDATE common.gmlist SET passphrase=PASSWORD('your_pass') WHERE mName='targetcharactername'; After doing so we'll now write the function to elevate! Add void DoElevate(char* pwd); To your char.h inside a public section. You can close it and open char.cpp There we add our new DoElevate()-function. void CHARACTER::DoElevate(char* pwd) { char szQuery[1024]; snprintf(szQuery, sizeof(szQuery), "SELECT mID FROM common.gmlist WHERE mName='%s' AND (passphrase='' OR passphrase=PASSWORD('%s'))", GetName(), pwd); std::unique_ptr<SQLMsg> result( DBManager::instance().DirectQuery(szQuery) ); if (result->Get()->uiNumRows == 1) { ChatPacket(CHAT_TYPE_INFO, "You have been elevated!"); sys_log(0, "Player %s elevated successful!", GetName()); SetElevation(true); return; } sys_err("Player failed to elevate! %s with %s result %d", GetName(), pwd, result->Get()->uiNumRows); ChatPacket(CHAT_TYPE_INFO, "Failed to elevate!"); } Now we can close char.cpp and open cmd_general.cpp There we navigate to our previously added ACMD sequence and replace it: ACMD(do_elevate) { if(ch->GetRealGMLevel() == GM_PLAYER) return; if(true == ch->GetElevation()) return; char a1[256]; one_argument(argument, a1, sizeof(a1)); if(!*a1) { char safe[] = "nopass"; ch->DoElevate(safe); } else { ch->DoElevate(a1); } } Now we can close everything and compile. Get ready to elevate! 6.) (optional) Elevating with testserver In this section we'll make elevating compatible with testserver. You can simply provide a special key you can change everytime (we'll do that via config, that's the best way!) you want to. People need to elevate themselves by using this key. Note that you'll get everything in your syslog, so no one can do something bad What we need to edit: - char.cpp - config.cpp - config.h First open config.h. We'll declare our variable: extern std::string ElevationKey; Then we can close config.h Let's open config.cpp and add our new variable: string ElevationKey = "testkey"; Now we only need to be able to modify our variable. Let's do that too. Find TOKEN("pk_protect_level") and add under the block our new token: TOKEN("elevation_key") { ElevationKey = value_string; fprintf(stderr, "ELEVATION_KEY: %s", ElevationKey.c_str()); } Close config.cpp too. We can now open char.cpp and edit our DoElevate()-function. Add to the beginning of our function: if(test_server) { extern std::string ElevationKey; if(strcmp(pwd, ElevationKey.c_str()) == 0) { ChatPacket(CHAT_TYPE_INFO, "You have been elevated!"); sys_log(0, "TESTSERVER! Player %s elevated successful!", GetName()); SetElevation(true); return; } } Note that while test server is active, both su-methods are allowed. You can either su with the passphrase or, if you do have a gm account, then you can use your passphrase. 7.) Fixing elevation in quests Thanks to Think I was able to think (joking with words, huh?) about a problem I didn't notice earlier: When logging in, quests requiring gm permissions on login won't work anymore. We first have to elevate before we are registered as a GM. How are we going to fix it? Easy! We just have to edit questlua_pc.cpp Find pc_is_gm() and pc_get_gm_level() Replace the function name GetGMLevel() with our real function: GetRealGMLevel() That's all for fixing that! But wait! We want to be secure, right? For this, we just add two new quest functions! int pc_is_gm_safe(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); lua_pushboolean(L, ch->GetGMLevel() >= GM_HIGH_WIZARD); return 1; } int pc_get_gm_level_safe(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); lua_pushnumber(L, ch->GetGMLevel()); return 1; } They're... well.. they're the same than our old functions. We just changed the old functions to make sure quests will work as they did before. Now we can use the safe equivalent outside of login calls (e. g. when you're using it in a chat-trigger or button/info). Just add them to our list and we're finished! { "is_gm_safe", pc_is_gm_safe }, { "get_gm_level_safe", pc_get_gm_level_safe }, Compile and run the gamefile. Quests will work like they did before! Happy elevating!
    3 points
  3. M2 Download Center Download Here ( Internal ) Hello Excuse me, I do not like introductions Go to: game/src/char.h ------------------------------------------------------------------------------- Go to : game/src/char_item.cpp ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- Note: char_item.cpp > Search: Edit the number of pages inventory
    1 point
  4. M2 Download Center Download Here ( Internal ) Hallo all c++ : open EterPythonLib/PythonSlotWindow.cpp now open EterPythonLib/PythonSlotWindow.h now open : /EterPythonLib/PythonWindowManagerModule.cpp now open: /UserInterface/PythonNetworkStreamPhaseGame.cpp now python part open : root/uiinventory.py ok that's it , have a nice day
    1 point
  5. Hello Metin2dev, I have a problem with my powermount system. Here you can see: powermount: White lion: With the first one the server don't load the mobs. I don't know why.
    1 point
  6. i alredy fixed it and i didn't use any of your source i don't even know you xD #Closed
    1 point
  7. Have you used any fix for "injection" in guild_manager.cpp ? If yes the problem is in CGuildManager::CreateGuild because the input is already checked by function check_name and you don't need any"fix".
    1 point
  8. deleted Because of the Mufti of the Republic misterioso
    1 point
  9. Awesome thanks @VegaS you helped me a lot
    1 point
  10. search in PythonItemMoudle.cpp PyObject * itemSelectItem(PyObject * poSelf, PyObject * poArgs) { int iIndex; if (!PyTuple_GetInteger(poArgs, 0, &iIndex)) return Py_BadArgument(); if (!CItemManager::Instance().SelectItemData(iIndex)) { TraceError("Cannot find item by %d", iIndex); CItemManager::Instance().SelectItemData(60001); } return Py_BuildNone(); } change for: PyObject * itemSelectItem(PyObject * poSelf, PyObject * poArgs) { int iIndex; if (!PyTuple_GetInteger(poArgs, 0, &iIndex)) return Py_BadArgument(); if (!CItemManager::Instance().SelectItemData(iIndex)) { //TraceError("Cannot find item by %d", iIndex); CItemManager::Instance().SelectItemData(60001); } return Py_BuildNone(); } not fix. but does not show the error xD maybe thx ok not ? xD
    1 point
  11. C+ Form Add this function in input_login.cpp static void _send_coins(LPCHARACTER ch) { if (ch) { SQLMsg * pMsg = DBManager::instance().DirectQuery("select coins from account%s WHERE id = %u", get_table_postfix(), ch->GetAID()); if (pMsg->Get()->uiNumRows > 0) { MYSQL_ROW row = mysql_fetch_row(pMsg->Get()->pSQLResult); ch->ChatPacket(CHAT_TYPE_COMMAND, "BINARY_Update_Coins %s", row[0]); delete pMsg; } } } And search ; _send_bonus_info(ch); Add this under that _send_coins(ch); Part of Python ; Add this command under "mall" "mall" : self.__InGameShop_Show, "BINARY_Update_Coins" : self.Binary_Update_Coins like this Add this function in game.py def Binary_Update_Coins(self,coins): self.wndMds.SetText(str(coins)) €dit : why is not work these commands? Open char_change_empire.cpp file and find this DWORD CHARACTER::GetAID() const { char szQuery[1024+1]; DWORD dwAID = 0; snprintf(szQuery, sizeof(szQuery), "SELECT id FROM player_index%s WHERE pid1=%u OR pid2=%u OR pid3=%u OR pid4=%u AND empire=%u", get_table_postfix(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetEmpire()); SQLMsg* pMsg = DBManager::instance().DirectQuery(szQuery); if (pMsg != NULL) { if (pMsg->Get()->uiNumRows == 0) { M2_DELETE(pMsg); return 0; } MYSQL_ROW row = mysql_fetch_row(pMsg->Get()->pSQLResult); str_to_number(dwAID, row[0]); M2_DELETE(pMsg); return dwAID; } else { return 0; } } change via this DWORD CHARACTER::GetAID() const { const TAccountTable pAccountTable = GetDesc()->GetAccountTable(); if (pAccountTable.id) return pAccountTable.id; } Meanwhile add this on top. #include "desc.h" Best Regards Zerelth ~ Ellie
    1 point
×
×
  • 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.