Krixius 13 Posted June 24, 2017 Share Posted June 24, 2017 Hi dev Actually im trying to add a new function but i don't know why this is working bad: I have in player a new column called: rank and i want that this function returns the number that i have in rank but i don't know how to do it ._. int pc_get_rank(lua_State* L) { DBManager::instance().Query("SELECT rank FROM player.player WHERE name='%s' ", CQuestManager::instance().GetCurrentCharacterPtr()->GetName()); lua_pushnumber(L, 0); return 1; } Function returns me all time 0 in game Link to comment Share on other sites More sharing options...
Solution Shang 371 Posted June 24, 2017 Solution Share Posted June 24, 2017 int pc_get_rank(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); if (!ch) { lua_pushnumber(L, 0); return 1; } char szQuery[512]; snprintf(szQuery, sizeof(szQuery), "SELECT rank FROM player.player WHERE name='%s'", ch->GetName()); std::auto_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery(szQuery)); if (pMsg->Get()->uiNumRows > 0) { MYSQL_ROW row = mysql_fetch_row(pMsg->Get()->pSQLResult); int iRank = 0; str_to_number(iRank, row[0]); lua_pushnumber(L, iRank); return 1; } lua_pushnumber(L, 0); return 1; } You are not pushing the query return value, you're pushing 0 all the time. Not tested. Oh, and it is better to declare first the LPCHARACTER to avoid core crashes if it doesn't exists. PS: Where did you get the Dev member? In a bet? 3 Link to comment Share on other sites More sharing options...
Krixius 13 Posted June 24, 2017 Author Share Posted June 24, 2017 3 years ago i get the dev member, i will test it, thanks in advance Ok, solved thanks Link to comment Share on other sites More sharing options...
RatCatcher 77 Posted June 24, 2017 Share Posted June 24, 2017 >has developer tag lmfao Enough is enough Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now