Jump to content
  • Register Now

    Sign up and take advantage of the features of our community! Some forums are only accessible to our members!

GameMaster restriction


Recommended Posts

  • VIP
Posted (edited)
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;

Someone is selling this for money and our friend Itachi made it free.  Say ty to@Itachi

 

Hellow again, thanks to @Vanilla for code improve


	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 (!test_server && victim->GetGMLevel() != GM_PLAYER)



	{



	ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't trade with a Game Master"));



	return false;



	}



	}



	if (!test_server && IsGM())



	{

	std::unique_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery("SELECT * FROM gamemaster_restriction"));



	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 (!test_server && IsGM())



	{

	std::unique_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery("SELECT * FROM gamemaster_restriction"));



	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 (!test_server && ch->IsGM())



	{

	std::unique_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery("SELECT * FROM gamemaster_restriction"));



	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 utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',



	PRIMARY KEY (`gamemaster`) USING BTREE



	) ENGINE = MyISAM CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;



	SET FOREIGN_KEY_CHECKS = 1;



	[/CODE]
Edited by Vaynz (see edit history)
Link to post

It's nice to see people contributing but the circumstances around this are rather sad ?

Either way I just changed a bit on the code. In this case you'd use smart pointers. If you don't have the most recent std you might wanna swap unique_ptr with auto_ptr in my example.

Also there's no sense in formatting a string with.. well, no format. You can just go ahead and directly use the already finished string.

And there's one thing: You might wanna get into trouble when running in test server since literally everyone is a gm during this. It'll block you from trading etc... So I made a check for test_server.

And lastly I highly recommend not using queries for this. We already have a gm privilege management. Why don't we use the different stages of GM and restrict those? Like e. g. lower GM rank may not be allowed to trade while higher staff can do. This would eliminate a lot of queries since.. yeah, you're going to put unnecessary load if you're running a query every time one of these functions trigger. Might as well either cache the result in the player instance and fetch it once it's already stored ooooor you can, like I said above, just go ahead and use the existing privilege management.

Oh and one tiny thing: The query states utf8mb4 which is indeed quite nice... but it doesn't make sense to specify this and then create a table with latin1. I changed that, too.



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 (!test_server && victim->GetGMLevel() != GM_PLAYER)

{

ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't trade with a Game Master"));

return false;

}

}

if (!test_server && IsGM())

{
std::unique_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery("SELECT * FROM gamemaster_restriction"));

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 (!test_server && IsGM())

{
std::unique_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery("SELECT * FROM gamemaster_restriction"));

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 (!test_server && ch->IsGM())

{
std::unique_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery("SELECT * FROM gamemaster_restriction"));

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 utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',

PRIMARY KEY (`gamemaster`) USING BTREE

) ENGINE = MyISAM CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

[/CODE]
  • Love 1

We are the tortured.
We're not your friends.
As long as we're not visible.
We are unfixable.

Link to post

Do you mean people are selling GM restrictions like you posted (trade, drop, sell,summon, etc) ?

Stuff that been around since the sources first were massively distributed?

Damn, mt2 never ceases to surprise me, it just keeps going lower and lower. 

Soon script kiddies will start selling old pserver clients ?

Share some prints of such selling attempts i can add them to my personal "ahah" list ?

Link to post
  • VIP
Posted (edited)

u can restrict GM without a sql query.....?

e.g 1 of them..

bool CHARACTER::ExchangeStart(LPCHARACTER victim)
{
	...

	if (!IsLowGM() && victim->IsLowGM())
	{
		ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot trade items with a Game Master."));
		return false;
	}
	if (IsLowGM() && !victim->IsLowGM())
	{
		ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Game Masters cannot trade items with players."));
		return false;
	}
	
	...
}

u dont need to restrict all GM grade , but if u want.. just change IsLowGM >> IsGM

Edited by ⚡FlasH⚡ (see edit history)
  • Love 1
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • 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.