Jump to content

Ikarus_

Developer
  • Posts

    402
  • Joined

  • Last visited

  • Days Won

    20
  • Feedback

    0%

Posts posted by Ikarus_

  1. no you don't have to do this.....
    take up my method...
    You just have to replace the ChangeGold with the method used in your code to give the yang....
    you don't have to go to replace the information in the database, this would not be able to a real change in game because the information is already into game cache.... understand? 

     

    Possible methods that are used in your code to give yang: 
    ChangeMoney
    SetGold

     

    If the method is SetGold, you need to replace in my method "ChangeGold (dlCount)"  with "SetGold (GetGold () + dlCount)"

  2. I apologise, but your statement suggests that mine is a mistake, so I would like to clarify something.

     

    the use or not of auto_ptr is at the discretion of the programmer....
    the auto_ptr is not better than a normal pointer, it is only safer.

     

    But I hate to see it used if the pointer's life is only 5 lines of code.... it doesn't make much sense.

    The use of the auto_ptr instead of a normal pointer in my code would have no advantage.

    	SQLMsg* pMsg = AccountDB::instance().DirectQuery("UPDATE account.account SET coins = coins + '%ld' WHERE id = '%d'", iCount,GetAID());
    	bool bSucc = (pMsg->uiSQLErrno == 0);
    
    	delete(pMsg);

    as you can see there is no way the pointer could be deleted without deleting the object which he points to...

     

    the use of auto_ptr (which has been deprecated and replaced with unique_ptr IF YOU ARE INTERESTED IN KNOWING IT) 
    is especially recommended when the pointer life is durable, not if you only use it for 2 lines of code....

     

    I don't want to seem bad or attack you, but better say things really as they are:)

  3. I preface that even this code is only written and posted, I have not compilled it and not tested it.

     

    //UseItem / UseItemEx part
    
    	switch (item->GetVnum())
    	{
    		case 80003: // 50kk
    		case 80004: // 100kk
    		case 80005: // 250kk
    		case 80006: // 500kk???
    		case 80007: // 1kkk???
    		{
    			if(ChangeBars(item->GetVnum())
    				item->SetCount(item->GetCount() - 1);
    			
    			else
    				ChatPacket(CHAT_TYPE_INFO , "<SYSTEM> An error occurred while the exchange happened.");
    			
    			return 1;
    		}
    		
    		default:
    			break;
    	}
    	
    	
    	
    	
    	
    	
    	
    	
    	
    //constantsc.cpp
    const DWORD cdwBarsItems[ITEM_BARS_NUM] = 
    {
    	80003,
    	80004,
    	80005,
    	80006,
    	80007,
    }
    
    
    const long long cdlBarsValue[ITEM_BARS_NUM] =
    {
    	50000000,
    	100000000,
    	250000000,
    	500000000,
    	1000000000,
    }
    
    //constants.h
    #define ITEM_BARS_NUM 5
    extern const DWORD cdwBarsItems[ITEM_BARS_NUM];
    extern const long long cdlBarsValue[ITEM_BARS_NUM];
    
    
    
    
    //new methods to add in char.cpp or char_item.cpp
    
    bool CHARACTER::ChangeBars(DWORD dwVnum)
    {
    	long long dlCount = 0;
    	
    	for(int i = 0; i < ITEM_BARS_NUM; i++)
    	{
    		if(cdwBarsItems[i] == dwVnum)
    		{
    			dlCount = cdlBarsValue[i];
    			break;
    		}
    	}
    	
    	if(dlCount == 0)
    		return false;
    	
    	ChangeGold(dlCount);
    	
    	TItemTable* pItemTable = ITEM_MANAGER::instance().GetTable(dwVnum);
    	
    	if(pItemTable)
    		ChatPacket(CHAT_TYPE_INFO , "<SYSTEM> You received [%d] yang for changing [%s]", dlCount,pItemTable->szLocaleName );
    	
    	LogManager::instance().BarsLog(GetAID() , GetPlayerID() , dwVnum , dlCount);
    }
    
    
    //into char.h (under public)
    	bool ChangeBars(DWORD dwVnum);
    	
    	
    	
    	
    	
    //in log.cpp
    void LogManager::BarsLog(DWORD dwAID , DWORD dwPlayerID , DWORD dwVnum , long long dlCount)
    {
    	Query("INSERT INTO bars_log (account_id , id , item_vnum , yang_count , time_stamp ) VALUES('%u', '%u' , '%u' , '%u' , NOW() )" , dwAID , dwPlayerID , dwVnum , dlCount);
    }
    
    
    //in log.h (under public)
    	void BarsLog(DWORD dwAID , DWORD dwPlayerID , DWORD dwVnum , long long dlCount);

     

    it is necessary to add the table in the log database "bars_log"

    account_id (unsigned int)
    id (unsigned int)
    item_vnum (unsigned int)
    yang_count (unsigned big int)
    time_stamp (datetime)

     

    not knowing if you are using bars or cheques I preferred to use the word bars in the code (and for the table) but you can replace it anywhere (you are sure to have replaced it everywhere) with what you want.

     

    • Love 1
  4. usually, when you put the full yang system with the value type long long, you don't use PointChange because the points are an array of long type....I hope you haven't changed the value type of the character point array just to put the full yang....
    you would lose a lot of efficiency at all If you did it...

     

    You usually add an extra long long member to the packet update point and assign the long long m_dlGold value (e. g..). 

     

    If you just want me to optimize what you've posted using character points arrays, I can do it... how you want to do it.

  5.  

    now we should be affixed;)

    Spoiler
    
    /*
     * PLAYER CREATE
     */
    void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerCreatePacket* packet)
    {
    	char	queryStr[QUERY_MAX_LEN];
    	int		queryLen;
    	int		player_id;
    
    	// 한 계정에 X초 내로 캐릭터 생성을 할 수 없다.
    	time_by_id_map_t::iterator it = s_createTimeByAccountID.find(packet->account_id);
    
    	if (it != s_createTimeByAccountID.end())
    	{
    		time_t curtime = time(0);
    
    		if (curtime - it->second < 30)
    		{
    			peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
    			return;
    		}
    	}
    
    	queryLen = snprintf(queryStr, sizeof(queryStr), 
    			"SELECT pid%u FROM player_index%s WHERE id=%d", packet->account_index + 1, GetTablePostfix(), packet->account_id);
    
    	std::auto_ptr<SQLMsg> pMsg0(CDBManager::instance().DirectQuery(queryStr));
    	
    	if (pMsg0->Get()->uiNumRows != 0)
    	{
    		if (!pMsg0->Get()->pSQLResult)
    		{
    			peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
    			return;
    		}
    
    		MYSQL_ROW row = mysql_fetch_row(pMsg0->Get()->pSQLResult);
    
    		DWORD dwPID = 0; str_to_number(dwPID, row[0]);
    		if (row[0] && dwPID > 0)
    		{
    			peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_ALREADY, dwHandle, 0);
    			sys_log(0, "ALREADY EXIST AccountChrIdx %d ID %d", packet->account_index, dwPID);
    			return;
    		}
    	}
    	else
    	{
    		//begin fix no insert into player index
    		if(packet->account_index != 0)
    		{
    			peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
    			return;
    		}
    		
    		else
    		{
    			char szQueryInsert[100] = "\0";
    			
    			snprintf(szQueryInsert , sizeof(szQueryInsert) , "INSERT INTO player_index (id , pid1 , pid2 , pid3 , pid4 ) VALUES( '%u' , 0,0,0,0 )",packet->account_id);
    			delete(CDBManager::instance().DirectQuery(szQueryInsert));
    		}
    		//end fix
    	}
    
    	if (g_stLocale == "sjis")
    		snprintf(queryStr, sizeof(queryStr),
    			"SELECT COUNT(*) as count FROM player%s WHERE name='%s' collate sjis_japanese_ci", 
    			GetTablePostfix(), packet->player_table.name);	
    	else
    	snprintf(queryStr, sizeof(queryStr), 
    			"SELECT COUNT(*) as count FROM player%s WHERE name='%s'", GetTablePostfix(), packet->player_table.name);
    
    	std::auto_ptr<SQLMsg> pMsg1(CDBManager::instance().DirectQuery(queryStr));
    
    	if (pMsg1->Get()->uiNumRows)
    	{
    		if (!pMsg1->Get()->pSQLResult)
    		{
    			peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
    			return;
    		}
    
    		MYSQL_ROW row = mysql_fetch_row(pMsg1->Get()->pSQLResult);
    
    		if (*row[0] != '0')
    		{
    			sys_log(0, "ALREADY EXIST name %s, row[0] %s query %s", packet->player_table.name, row[0], queryStr);
    			peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_ALREADY, dwHandle, 0);
    			return;
    		}
    	}
    	else
    	{
    		peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
    		return;
    	}
    
    	queryLen = snprintf(queryStr, sizeof(queryStr), 
    			"INSERT INTO player%s "
    			"(id,account_id,name,level,st,ht,dx,iq,job,voice,dir,x,y,"
    			"z,hp,mp,random_hp,random_sp,horse_appearance,stat_point,"
    			"stamina,part_base,part_main,part_hair,gold) "
    			"VALUES(0,%u,'%s',%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,"
    			"%d,%d,%d,%d,%d,%d,%d,%d,%d,0,0,0)",
    			GetTablePostfix(),
    			packet->account_id, packet->player_table.name, packet->player_table.level, packet->player_table.st, packet->player_table.ht, packet->player_table.dx, packet->player_table.iq,
    			packet->player_table.job, packet->player_table.voice, packet->player_table.dir, packet->player_table.x, packet->player_table.y, packet->player_table.z,packet->player_table.hp,
    			packet->player_table.sp, packet->player_table.sRandomHP, packet->player_table.sRandomSP, packet->player_table.sHorse_appearance, packet->player_table.stat_point, packet->player_table.stamina,
    			packet->player_table.part_base);
    
    	sys_log(0, "PlayerCreate accountid %d name %s level %d gold %lld, st %d ht %d job %d",
    			packet->account_id, 
    			packet->player_table.name, 
    			packet->player_table.level, 
    			packet->player_table.gold, 
    			packet->player_table.st, 
    			packet->player_table.ht, 
    			packet->player_table.job);
    
    	static char text[4096 + 1];
    
    	CDBManager::instance().EscapeString(text, packet->player_table.skills, sizeof(packet->player_table.skills));
    	queryLen += snprintf(queryStr + queryLen, sizeof(queryStr) - queryLen, "'%s', ", text);
    	if (g_test_server)
    		sys_log(0, "Create_Player queryLen[%d] TEXT[%s]", queryLen, text);
    
    	CDBManager::instance().EscapeString(text, packet->player_table.quickslot, sizeof(packet->player_table.quickslot));
    	queryLen += snprintf(queryStr + queryLen, sizeof(queryStr) - queryLen, "'%s')", text);
    
    	std::auto_ptr<SQLMsg> pMsg2(CDBManager::instance().DirectQuery(queryStr));
    	if (g_test_server)
    		sys_log(0, "Create_Player queryLen[%d] TEXT[%s]", queryLen, text);
    
    	if (pMsg2->Get()->uiAffectedRows <= 0)
    	{
    		peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_ALREADY, dwHandle, 0);
    		sys_log(0, "ALREADY EXIST3 query: %s AffectedRows %lu", queryStr, pMsg2->Get()->uiAffectedRows);
    		return;
    	}
    
    	player_id = pMsg2->Get()->uiInsertID;
    
    	snprintf(queryStr, sizeof(queryStr), "UPDATE player_index%s SET pid%d=%d WHERE id=%d", 
    			GetTablePostfix(), packet->account_index + 1, player_id, packet->account_id);
    	std::auto_ptr<SQLMsg> pMsg3(CDBManager::instance().DirectQuery(queryStr));
    
    	if (pMsg3->Get()->uiAffectedRows <= 0)
    	{
    		sys_err("QUERY_ERROR: %s", queryStr);
    
    		snprintf(queryStr, sizeof(queryStr), "DELETE FROM player%s WHERE id=%d", GetTablePostfix(), player_id);
    		CDBManager::instance().DirectQuery(queryStr);
    
    		peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
    		return;
    	}
    
    	TPacketDGCreateSuccess pack;
    	memset(&pack, 0, sizeof(pack));
    
    	pack.bAccountCharacterIndex = packet->account_index;
    
    	pack.player.dwID			= player_id;
    	strlcpy(pack.player.szName, packet->player_table.name, sizeof(pack.player.szName));
    	pack.player.byJob			= packet->player_table.job;
    	pack.player.byLevel			= 1;
    	pack.player.dwPlayMinutes	= 0;
    	pack.player.byST			= packet->player_table.st;
    	pack.player.byHT			= packet->player_table.ht;
    	pack.player.byDX 			= packet->player_table.dx;
    	pack.player.byIQ			= packet->player_table.iq;
    	pack.player.wMainPart		= packet->player_table.part_base;
    	pack.player.x			= packet->player_table.x;
    	pack.player.y			= packet->player_table.y;
    
    	peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_SUCCESS, dwHandle, sizeof(TPacketDGCreateSuccess));
    	peer->Encode(&pack, sizeof(TPacketDGCreateSuccess));
    
    	sys_log(0, "7 name %s job %d", pack.player.szName, pack.player.byJob);
    
    	s_createTimeByAccountID[packet->account_id] = time(0);
    }

     

     

    copy it again  , I had not closed a round parenthesis (now is fixed)

  6. /*
     * PLAYER CREATE
     */
    void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerCreatePacket* packet)
    {
    	char	queryStr[QUERY_MAX_LEN];
    	int		queryLen;
    	int		player_id;
    
    	// 한 계정에 X초 내로 캐릭터 생성을 할 수 없다.
    	time_by_id_map_t::iterator it = s_createTimeByAccountID.find(packet->account_id);
    
    	if (it != s_createTimeByAccountID.end())
    	{
    		time_t curtime = time(0);
    
    		if (curtime - it->second < 30)
    		{
    			peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
    			return;
    		}
    	}
    
    	queryLen = snprintf(queryStr, sizeof(queryStr), 
    			"SELECT pid%u FROM player_index%s WHERE id=%d", packet->account_index + 1, GetTablePostfix(), packet->account_id);
    
    	std::auto_ptr<SQLMsg> pMsg0(CDBManager::instance().DirectQuery(queryStr));
    	
    	if (pMsg0->Get()->uiNumRows != 0)
    	{
    		if (!pMsg0->Get()->pSQLResult)
    		{
    			peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
    			return;
    		}
    
    		MYSQL_ROW row = mysql_fetch_row(pMsg0->Get()->pSQLResult);
    
    		DWORD dwPID = 0; str_to_number(dwPID, row[0]);
    		if (row[0] && dwPID > 0)
    		{
    			peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_ALREADY, dwHandle, 0);
    			sys_log(0, "ALREADY EXIST AccountChrIdx %d ID %d", packet->account_index, dwPID);
    			return;
    		}
    	}
    	else
    	{
    		//begin fix no insert into player index
    		if(packet->account_index != 0)
    		{
    			peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
    			return;
    		}
    		
    		else
    		{
    			char szQueryInsert[100] = "\0";
    			
    			snprintf(szQueryInsert , sizeof(szQueryInsert) , "INSERT INTO player_index (id , pid1 , pid2 , pid3 , pid4 ) VALUES( '%u' , 0,0,0,0 )",packet->account_id);
    			delete(CDBManager::instance().DirectQuery(szQueryInsert));
    		}
    		//end fix
    	}
    
    	if (g_stLocale == "sjis")
    		snprintf(queryStr, sizeof(queryStr),
    			"SELECT COUNT(*) as count FROM player%s WHERE name='%s' collate sjis_japanese_ci", 
    			GetTablePostfix(), packet->player_table.name);	
    	else
    	snprintf(queryStr, sizeof(queryStr), 
    			"SELECT COUNT(*) as count FROM player%s WHERE name='%s'", GetTablePostfix(), packet->player_table.name);
    
    	std::auto_ptr<SQLMsg> pMsg1(CDBManager::instance().DirectQuery(queryStr));
    
    	if (pMsg1->Get()->uiNumRows)
    	{
    		if (!pMsg1->Get()->pSQLResult)
    		{
    			peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
    			return;
    		}
    
    		MYSQL_ROW row = mysql_fetch_row(pMsg1->Get()->pSQLResult);
    
    		if (*row[0] != '0')
    		{
    			sys_log(0, "ALREADY EXIST name %s, row[0] %s query %s", packet->player_table.name, row[0], queryStr);
    			peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_ALREADY, dwHandle, 0);
    			return;
    		}
    	}
    	else
    	{
    		peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
    		return;
    	}
    
    	queryLen = snprintf(queryStr, sizeof(queryStr), 
    			"INSERT INTO player%s "
    			"(id, account_id, name, level, st, ht, dx, iq, "
    			"job, voice, dir, x, y, z, "
    			"hp, mp, random_hp, random_sp, horse_appearance, stat_point, stamina, part_base, part_main, part_hair, gold, playtime, "
    			"skill_level, quickslot) "
    			"VALUES(0, %u, '%s', %d, %d, %d, %d, %d, "
    			"%d, %d, %d, %d, %d, %d, %d, "
    			"%d, %d, %d, %d, %d, %d, %d, 0, %d, 0, ",
    			GetTablePostfix(),
    			packet->account_id, packet->player_table.name, packet->player_table.level, packet->player_table.st, packet->player_table.ht, packet->player_table.dx, packet->player_table.iq,
    			packet->player_table.job, packet->player_table.voice, packet->player_table.dir, packet->player_table.x, packet->player_table.y, packet->player_table.z,
    			packet->player_table.hp, packet->player_table.sp, packet->player_table.sRandomHP, packet->player_table.sRandomSP, packet->player_table.sHorse_appearance, packet->player_table.stat_point, packet->player_table.stamina, packet->player_table.part_base, packet->player_table.part_base, packet->player_table.gold);
    
    	sys_log(0, "PlayerCreate accountid %d name %s level %d gold %lld, st %d ht %d job %d",
    			packet->account_id, 
    			packet->player_table.name, 
    			packet->player_table.level, 
    			packet->player_table.gold, 
    			packet->player_table.st, 
    			packet->player_table.ht, 
    			packet->player_table.job);
    
    	static char text[4096 + 1];
    
    	CDBManager::instance().EscapeString(text, packet->player_table.skills, sizeof(packet->player_table.skills));
    	queryLen += snprintf(queryStr + queryLen, sizeof(queryStr) - queryLen, "'%s', ", text);
    	if (g_test_server)
    		sys_log(0, "Create_Player queryLen[%d] TEXT[%s]", queryLen, text);
    
    	CDBManager::instance().EscapeString(text, packet->player_table.quickslot, sizeof(packet->player_table.quickslot));
    	queryLen += snprintf(queryStr + queryLen, sizeof(queryStr) - queryLen, "'%s')", text);
    
    	std::auto_ptr<SQLMsg> pMsg2(CDBManager::instance().DirectQuery(queryStr));
    	if (g_test_server)
    		sys_log(0, "Create_Player queryLen[%d] TEXT[%s]", queryLen, text);
    
    	if (pMsg2->Get()->uiAffectedRows <= 0)
    	{
    		peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_ALREADY, dwHandle, 0);
    		sys_log(0, "ALREADY EXIST3 query: %s AffectedRows %lu", queryStr, pMsg2->Get()->uiAffectedRows);
    		return;
    	}
    
    	player_id = pMsg2->Get()->uiInsertID;
    
    	snprintf(queryStr, sizeof(queryStr), "UPDATE player_index%s SET pid%d=%d WHERE id=%d", 
    			GetTablePostfix(), packet->account_index + 1, player_id, packet->account_id);
    	std::auto_ptr<SQLMsg> pMsg3(CDBManager::instance().DirectQuery(queryStr));
    
    	if (pMsg3->Get()->uiAffectedRows <= 0)
    	{
    		sys_err("QUERY_ERROR: %s", queryStr);
    
    		snprintf(queryStr, sizeof(queryStr), "DELETE FROM player%s WHERE id=%d", GetTablePostfix(), player_id);
    		CDBManager::instance().DirectQuery(queryStr);
    
    		peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
    		return;
    	}
    
    	TPacketDGCreateSuccess pack;
    	memset(&pack, 0, sizeof(pack));
    
    	pack.bAccountCharacterIndex = packet->account_index;
    
    	pack.player.dwID			= player_id;
    	strlcpy(pack.player.szName, packet->player_table.name, sizeof(pack.player.szName));
    	pack.player.byJob			= packet->player_table.job;
    	pack.player.byLevel			= 1;
    	pack.player.dwPlayMinutes	= 0;
    	pack.player.byST			= packet->player_table.st;
    	pack.player.byHT			= packet->player_table.ht;
    	pack.player.byDX 			= packet->player_table.dx;
    	pack.player.byIQ			= packet->player_table.iq;
    	pack.player.wMainPart		= packet->player_table.part_base;
    	pack.player.x			= packet->player_table.x;
    	pack.player.y			= packet->player_table.y;
    
    	peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_SUCCESS, dwHandle, sizeof(TPacketDGCreateSuccess));
    	peer->Encode(&pack, sizeof(TPacketDGCreateSuccess));
    
    	sys_log(0, "7 name %s job %d", pack.player.szName, pack.player.byJob);
    
    	s_createTimeByAccountID[packet->account_id] = time(0);
    }

     

     

     

    try to change it in this way.....

    is not the best way to solve the problem, but not too bad.

    Let us know if it works;)

    sorry I've investigated some more about your mistake... I think I've found another problem... now I tell you but wait a second before doing the test.

  7. 3 minutes ago, cubex33 said:

    i dont know what is wrong

    I sincerely think that the problem is in 
    clientmanagerlogin. cpp.
    where the game creates (if it doesn't exist) the new line in player_index tables...


    in my files the method that does this is called
    RESULT_LOGIN_BY_KEY
    by chance have you modified this method or some other method within this file?

  8. the error tell you

     

    	if (pMsg3->Get()->uiAffectedRows <= 0)
        {
            sys_err("QUERY_ERROR: %s", queryStr);
    
            snprintf(queryStr, sizeof(queryStr), "DELETE FROM player%s WHERE id=%d", GetTablePostfix(), player_id);
            CDBManager::instance().DirectQuery(queryStr);
    
            peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
            return;
        }

    This happens if there is any problem with the player_index table...

     

    check what this query does not go well 

    UPDATE player_index%s SET pid%d=%d WHERE id=%d

    checks that the table exists and that it has columns with the same name that is used in this query

  9. 5 hours ago, revengertmt said:

    bool CHARACTER::SetCoins(long coins) { SQLMsg *msg; msg = DBManager::instance().DirectQuery("UPDATE account.account SET coins = coins + '%ld' WHERE id = '%d'", coins, GetAID()); if (msg->uiSQLErrno != 0) { sys_err("[MD] Nu pot fi predate!(a aparut o eroare)"); return false; } return true; }

     

    I suggest you change with this

    bool CHARACTER::ChangeCoins(DWORD dwVnum)
    {
    	int iCount = 0;
    	
    	for(int i = 0 ; i < VOUCHER_NUM ; i++)
    	{
    		if(dwVnum == cdwVoucherVnum[i])
    		{
    			iCount = ciVoucherCountDR[i];
    			break;
    		}
    	}
    	
    	if(iCount ==0)
    		return false;
    
    
    	SQLMsg* pMsg = AccountDB::instance().DirectQuery("UPDATE account.account SET coins = coins + '%ld' WHERE id = '%d'", iCount,GetAID());
    	bool bSucc = (pMsg->uiSQLErrno == 0);
    
    	delete(pMsg);
    
    	if (!bSucc)
    	{
    		sys_err("[MD] Nu pot fi predate!(a aparut o eroare)");
    	}
    	
    	else
    	{
    		LogManager::instance().CoinsLog(GetAID() , GetPlayerID() , dwVnum , iCount);
    		ChatPacket(CHAT_TYPE_INFO,"<SYSTEM> You received [%d]DR ",iCount);
    	}
      
    	return bSucc;
    }

     

    if you don't delete pMsg you get memory leak...

     

     

    change in char_item (UseItem / UseItemEx) your's script with this
     

    switch (item->GetVnum())
    	{
    		//Vnums
    		case 80014: // 100 DR/Coins
    		case 80015: // 500 DR/Coins
    		case 80016: // 1000 DR/Coins
    		case 80017:
    			if (ChangeCoins(item->GetVnum()))
    			{
    				item->SetCount(item->GetCount() - 1);
    			}
    			else
    			{
    				ChatPacket(CHAT_TYPE_INFO, "A aparut o eroare. Contactati administratorul.");
    			}
    			return 1;
    			break;
    		
    		default:
    			break;
    	}

     

    add in constants.cpp and constants.h

    //constants.cpp (end of file)
    
    const DWORD cdwVoucherVnum[VOUCHER_NUM] = 
    {
    	80014,
    	80015,
    	80016,
    	80017
    }
    
    const int ciVoucherCountDR[VOUCHER_NUM] =
    {
    	100,
    	500,
    	1000,
    	50
    }
    
    
    //constants.h (end of file)
    
    #define VOUCHER_NUM 4
    extern const DWORD cdwVoucherVnum[VOUCHER_NUM];
    extern const int ciVoucherCountDR[VOUCHER_NUM];
    
      

     

     

    add in log.cpp and log.h

    
    //log.cpp
    void LogManager::CoinsLog( DWORD dwAID , dwPlayerID , DWORD dwVnum , int iCount)
    {
    	Query("INSERT INTO voucher_log (id , account_id , item_vnum , coins , data) VALUES('%u' , '%u' , '%u' , '%u' , NOW() )",dwPlayerID , dwAID , dwVnum , iCount );
    }
    
    
    log.h
    //under public
    	CoinsLog(DWORD dwAID , dwPlayerID , DWORD dwVnum , int iCount);

     

     

    Let me know if you have problems...
    I have not tested it but should do everything you ask for

    Fixed the chat packet error *

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