Jump to content
metin2dev
Metin2International
Sign in to follow this  
EnKor

[C++] CheckWrongItems

Recommended Posts

Copyright

Spoiler

Somewhere from internet.... i realy cant remember where i found it.

 

What it does?

Everytime player login in game, this function will look in all itens from player inventory. If server detect any item with more bonus then normal (from item_attr table).... the server will replace all bonus from this system.

I hope u understand and sorry for my english!

 

//#input_login.cpp

Spoiler

//1. Search: 
	d->SetPhase(PHASE_GAME);
//1. Add after:
	ch->CheckWrongItems();


 

// #char.cpp

Spoiler

//1. Search: 
int	CHARACTER::GetSkillPowerByLevel(int level, bool bMob) const
{
	return CTableBySkill::instance().GetSkillPowerByLevelFromType(GetJob(), GetSkillGroup(), MINMAX(0, level, SKILL_MAX_LEVEL), bMob);
}

//1. Add after:
void CHARACTER::CheckWrongItems()
{
	
	for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
	{
		LPITEM item;
		
		if (!(item = GetInventoryItem(i)))
			continue;
		
		for (int ia = 0; ia < ITEM_ATTRIBUTE_MAX_NUM; ia++)
		{
			const TPlayerItemAttribute& attr = item->GetAttribute(ia);
			const TItemAttrTable & r = g_map_itemAttr[attr.bType];
			
			if(item->GetAttributeSetIndex() != -1 && attr.sValue > r.lValues[r.bMaxLevelBySet[item->GetAttributeSetIndex()] - 1])
			{
				ChatPacket(CHAT_TYPE_INFO, "Wrong item found : %s, pos = %d, value = %d, max_value = %d", 
											item->GetName(), i, attr.sValue, r.lValues[r.bMaxLevelBySet[item->GetAttributeSetIndex()] - 1]);
				
				DBManager::instance().DirectQuery("INSERT INTO log.wrong_items(player_id, item_id, date, w_b_value) VALUES(%d, %d, NOW(), '%d|%d')", 
													GetPlayerID(), item->GetID(), attr.bType, attr.sValue);
					
				item->ChangeAttribute();
				//item->RemoveFromCharacter();
													
				break;
			}
		}
		
		continue;
	}
}

 

//#char.h

Spoiler

//1. Search: 
		int		GetSkillPowerByLevel(int level, bool bMob = false) const;
//1. Add after:
		void 	CheckWrongItems();

 

 

//#sql to logs

Spoiler

/*
Navicat MySQL Data Transfer

Source Server         : VPS_RANSOM
Source Server Version : 50552
Source Host           : 188.212.103.221:3306
Source Database       : log

Target Server Type    : MYSQL
Target Server Version : 50552
File Encoding         : 65001

Date: 2017-08-06 09:43:37
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for `wrong_items`
-- ----------------------------
DROP TABLE IF EXISTS `wrong_items`;
CREATE TABLE `wrong_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `player_id` int(11) NOT NULL,
  `item_id` int(11) NOT NULL,
  `date` datetime NOT NULL,
  `w_b_value` char(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- ----------------------------
-- Records of wrong_items
-- ----------------------------

 

 

//#Know bugs

items with SKILL_DAMAGE_BONUS or NORMAL_HIT_DAMAGE_BONUS will see bonus replace

this sistem dont detect itens with bónus 6/7

this system will replace bónus from sash system etc....

 

 

If anyone know how to solve this small bugs, reply pleace. Its a nice and simple system to help in Fair Play

  • Sad 1

Share this post


Link to post
Share on other sites
LogManager::instance().WrongItemsLog(GetPlayerID(), item->GetID(), attr.bType, attr.sValue);

-----------------

void LogManager::WrongItemsLog(DWORD dwPlayerID, DWORD dwItemID, BYTE bType, BYTE bValue)
{
    Query("INSERT INTO wrong_items_log%s (player_id, item_id, date, w_b_value) VALUES(%d, %d, NOW(), '%d|%d')", get_table_postfix(), dwPlayerID, dwItemID, bType, bValue);
}

void WrongItemsLog(DWORD dwPlayerID, DWORD dwItemID, BYTE bType, BYTE bValue);

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×