someone asked me about something like this.
and I gave you this example
I know very well that it can be improved.
but it is functional.
It consists of blocking GameMaster with the id of your account.
in the example I will place them for commerce, throw items, open store by cmd.
the others can already do them yourself.
Code
- Open Service.h
- //add:
- #define ENABLE_GAMEMASTER_RESTRICTION
- open exchange.cpp
- // Search:
- if (victim->IsBlockMode(BLOCK_EXCHANGE))
- // add:
- #ifdef ENABLE_GAMEMASTER_RESTRICTION
- if (!IsGM())
- {
- if (victim->GetGMLevel() != GM_PLAYER)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't trade a Game Master"));
- return false;
- }
- }
- if (IsGM())
- {
- char szQuery[QUERY_MAX_LEN];
- snprintf(szQuery, sizeof(szQuery), "SELECT * FROM gamemaster_restriction");
- SQLMsg * pMsg = DBManager::instance().DirectQuery(szQuery);
- SQLResult * pRes = pMsg->Get();
- if (pRes->uiNumRows)
- {
- MYSQL_ROW row;
- while ((row = mysql_fetch_row(pRes->pSQLResult)))
- {
- DWORD datos = 0;
- str_to_number(datos, row[0]);
- if (GetPlayerID()==datos)
- {
- ChatPacket(CHAT_TYPE_INFO, "You don't have permission to do this");
- return false;
- }
- }
- }
- }
- #endif
- open char_item.cpp
- //search:
- bool CHARACTER::DropItem(TItemPos Cell, BYTE bCount)
- //add:
- #ifdef ENABLE_GAMEMASTER_RESTRICTION
- if (IsGM())
- {
- char szQuery[QUERY_MAX_LEN];
- snprintf(szQuery, sizeof(szQuery), "SELECT * FROM gamemaster_restriction");
- SQLMsg * pMsg = DBManager::instance().DirectQuery(szQuery);
- SQLResult * pRes = pMsg->Get();
- if (pRes->uiNumRows)
- {
- MYSQL_ROW row;
- while ((row = mysql_fetch_row(pRes->pSQLResult)))
- {
- DWORD datos = 0;
- str_to_number(datos, row[0]);
- if (GetPlayerID()==datos)
- {
- ChatPacket(CHAT_TYPE_INFO, "You don't have permission to do this");
- return false;
- }
- }
- }
- }
- #endif
- open cmd_general.cpp
- //Search:
- ACMD(do_click_safebox)
- // add:
- #ifdef ENABLE_GAMEMASTER_RESTRICTION
- if (ch->IsGM())
- {
- char szQuery[QUERY_MAX_LEN];
- snprintf(szQuery, sizeof(szQuery), "SELECT * FROM gamemaster_restriction");
- SQLMsg * pMsg = DBManager::instance().DirectQuery(szQuery);
- SQLResult * pRes = pMsg->Get();
- if (pRes->uiNumRows)
- {
- MYSQL_ROW row;
- while ((row = mysql_fetch_row(pRes->pSQLResult)))
- {
- DWORD datos = 0;
- str_to_number(datos, row[0]);
- if (ch->GetPlayerID()==datos)
- {
- ch->ChatPacket(CHAT_TYPE_INFO, "You don't have permission to do this");
- return;
- }
- }
- }
- }
- #endif
- add player sql.
- SET NAMES utf8mb4;
- SET FOREIGN_KEY_CHECKS = 0;
- -- ----------------------------
- -- Table structure for gamemaster_restriction
- -- ----------------------------
- DROP TABLE IF EXISTS `gamemaster_restriction`;
- CREATE TABLE `gamemaster_restriction` (
- `gamemaster` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
- PRIMARY KEY (`gamemaster`) USING BTREE
- ) ENGINE = MyISAM CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;
- SET FOREIGN_KEY_CHECKS = 1;
fairly simple and short I hope someone can be useful.
remember is the account id not the character.