Hi !
I'm going to have a high volume of insertion into the database, so I decided to put in the source, how could I write this code?
Example: pc.add_pvm(1)
Code
- int pc_add_pvm(lua_State * L)
- {
- if (!lua_isnumber(L, 1))
- {
- sys_err("invalid argument");
- return 0;
- }
- LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
- long val = (long)lua_tonumber(L, 1);
- SQLMsg *msg;
- msg = DBManager::instance().DirectQuery("UPDATE player.player SET evento = evento+1 WHERE id = '%d' LIMIT 1", val, ch->GetPlayerID());
- msg = DBManager::instance().DirectQuery("UPDATE player.player SET premio = premio+1 WHERE id = '%d' LIMIT 1", val, ch->GetPlayerID());
- if (msg->uiSQLErrno != 0)
- {
- sys_err("pc_update_event_pvm query failed");
- return 0;
- }
- delete msg;
- }