View Single Post
  #1  
Old 01-18-2007, 07:31 PM
Cripp's Avatar
Cripp
Discordant
 
Join Date: Oct 2003
Location: The Shire
Posts: 474
Default Change for serverrules2read from players instead of accounts

Heres changes i make to make it so the server rules are flagged on every character instead of the account so when a player makes a new character they have to accept the rules again.. thought it might be useful to some others.

zone/command.cpp
Code:
--- command.cpp	2006/10/05 21:27:05	1.10
+++ command.cpp	2006/10/13 06:17:18	1.11
@@ -6622,9 +6622,9 @@
 
 void command_acceptrules(Client *c, const Seperator *sep)
 {
-	if(!database.GetAgreementFlag(c->AccountID()))
+	if(!database.GetAgreementFlag(c->CharacterID()))
 	{
-		database.SetAgreementFlag(c->AccountID());
+		database.SetAgreementFlag(c->CharacterID());
 		c->SendAppearancePacket(AT_Anim, ANIM_STAND);
 		c->Message(0,"It is recorded you have agreed to the rules.");
zone/client.cpp
Code:
--- client.cpp	2006/07/10 05:11:48	1.6
+++ client.cpp	2006/07/10 18:45:21	1.7
@@ -3059,7 +3059,7 @@
 
 	if(database.GetVariable("Rules", rules, 4096))
 	{
-		int8 flag = database.GetAgreementFlag(client->AccountID());
+		int8 flag = database.GetAgreementFlag(client->CharacterID());
 		if(!flag)
 		{
 			client->Message(13,"You must agree to the Rules, before you can move. (type #rules to view the rules)");
common/database.cpp
Code:
--- database.cpp	2006/09/25 01:24:25	1.7
+++ database.cpp	2006/10/05 21:38:16	1.8
@@ -1611,16 +1611,16 @@
 
 	return retval;
 }

-int8 Database::GetAgreementFlag(int32 acctid)
+int8 Database::GetAgreementFlag(int32 charid)
 {
 	char errbuf[MYSQL_ERRMSG_SIZE];
 	char* query = 0;
 	MYSQL_RES* result;
 	MYSQL_ROW row;
 	bool ret = false;

-	if (RunQuery(query, MakeAnyLenString(&query, "SELECT rulesflag FROM account WHERE id=%i",acctid), errbuf, &result)) {
+	if (RunQuery(query, MakeAnyLenString(&query, "SELECT rulesflag FROM character_ WHERE id=%i",charid), errbuf, &result)) {

 		safe_delete_array(query);
 		if (mysql_num_rows(result) == 1)
 		{

@@ -1636,14 +1642,14 @@
 	}
 	return 0;
 }

-void Database::SetAgreementFlag(int32 acctid)
+void Database::SetAgreementFlag(int32 charid)
 {
 	char errbuf[MYSQL_ERRMSG_SIZE];
 	char *query = 0;
 	int32	affected_rows = 0;

-	if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET rulesflag=1 where id=%i",acctid), errbuf, 0, &affected_rows)) {
+	if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET rulesflag=1 where id=%i",charid), errbuf, 0, &affected_rows)) {
 		safe_delete_array(query);
 	}
 	else
common/database.h
Code:
--- database.h	2006/09/25 01:24:25	1.6
+++ database.h	2006/10/05 21:38:16	1.7
@@ -151,9 +151,9 @@
 	int32	GetAccountIDFromLSID(int32 iLSID, char* oAccountName = 0, sint16* oStatus = 0);
 	bool	UpdateLiveChar(char* charname,int32 lsaccount_id);
 	bool	GetLiveChar(int32 account_id, char* cname);
- 	int8	GetAgreementFlag(int32 acctid);
- 	void	SetAgreementFlag(int32 acctid);
+	int8	GetAgreementFlag(int32 charid);
+	void	SetAgreementFlag(int32 charid);
	
 	/*
 	 * Groups
 	 */
Also need to add the rulesflag column to character_ with..
Code:
ALTER TABLE `character_` ADD `rulesflag` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0';
and if you want to remove the column from the account table which is not needed, and i didnt myself.. but if you want to heres the command..
Code:
ALTER TABLE `account` DROP rulesflag;
kinda alot of work but thought it could be useful for some..
__________________
Nug Blazers - ServerOP / founder
^^comming... later!

www.nugblazers.com
Reply With Quote