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?