Jump to content

Recommended Posts

  • Premium

How to make it right?

Any help please.

 

Spoiler

total = DBManager::Instance().Query("SELECT infernus FROM player.player WHERE name='%s'", GetName());
	
	if (total >= 3 ){
		ChatPacket(CHAT_TYPE_INFO,"linha de teste");
	}

 


 
if pc.get_sex() == true and npc.get_sex() == false then
	npc.purge()
end

 

Link to comment
https://metin2.dev/topic/18980-select-value-in-db-c/
Share on other sites

std::unique_ptr<SQLMsg> pSelectMsg(DBManager::instance().DirectQuery("SELECT infernus FROM player.player WHERE name='%s'", GetName());
BYTE count = pSelectMsg->Get()->uiNumRows;

if (count >= 3)
	ChatPacket(CHAT_TYPE_INFO,"Total count is %d", count);

 

  • Love 2
Link to comment
https://metin2.dev/topic/18980-select-value-in-db-c/#findComment-103363
Share on other sites

  • Premium
1 hour ago, ridetpro said:

std::unique_ptr<SQLMsg> pSelectMsg(DBManager::instance().DirectQuery("SELECT infernus FROM player.player WHERE name='%s'", GetName());
BYTE count = pSelectMsg->Get()->uiNumRows;

if (count >= 3)
	ChatPacket(CHAT_TYPE_INFO,"Total count is %d", count);

 

That way, count is allways "1"   :(

 

that way do not get invernus table value

if pc.get_sex() == true and npc.get_sex() == false then
	npc.purge()
end

 

Link to comment
https://metin2.dev/topic/18980-select-value-in-db-c/#findComment-103364
Share on other sites

char szQuery[QUERY_MAX_LEN];
snprintf(szQuery, sizeof(szQuery), "SELECT infernus FROM player.player WHERE name='%s'", GetName());
std::unique_ptr<SQLMsg> pSelectMsg(DBManager::instance().DirectQuery(szQuery);

SQLResult* pRes = pSelectMsg->Get();
	
if (pRes->uiNumRows > 0)
{
	MYSQL_ROW row = mysql_fetch_row(pRes->pSQLResult);
		
	DWORD GetVal = 0;
	str_to_number(GetVal, row[0]);

	ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Total count is %d"), GetVal);
}

It should work now. 

  • Love 2
Link to comment
https://metin2.dev/topic/18980-select-value-in-db-c/#findComment-103367
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



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.