Jump to content

Looking For Example MySQL SELECT, INSERT, UPDATE c++/lua


Recommended Posts

Hello, i ask now how i can use MySQL

insert/update/select from c++ and lua.

can you post example how i can use it?

 

i ask there for example how i can send packet from

game->python

game->client binary

game->client binary->python

client binary->python

client binary->game

client binary->game and python

get values like from MySQL like[player->gold] and send it to client and receive

binary/and or python

if (gold >= 0){

//todo

}

can someone make a tutorial or show under example code?

i think it will be helpfull not only for me but for all people to understand how it work. thanks!

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

5 minut temu, ragem0re napisał:

Just look for an existing part in your source code.

so you mean like this:

 

	int pc_set_test(lua_State* L){
		char szQuery[QUERY_MAX_LEN];

		if(!lua_isstring(L,1)){
			return 0;
		}

		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();

		snprintf(szQuery,sizeof(szQuery),"update account%s set test = '%s' where id = '%d'",get_table_postfix(),lua_tostring(L,1), ch->GetAID()); //ch->GetAID() = get account id
		std::auto_ptr<SQLMsg> pmsg(DBManager::instance().DirectQuery(szQuery));

		if(pmsg->Get()->uiInsertID == 0){
			return 0;
		}

		return 1;
	}

is correct?

i think this is 

LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); // = current character playing

 

btw, how about use mysql_query in lua?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



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