CLuaArgument* CLuaArguments::PushBoolean(bool bBool) { CLuaArgument* pArgument = new CLuaArgument(); pArgument->ReadBool(bBool); m_Arguments.push_back(pArgument); return pArgument; }
CLuaArgument* CAccountManager::GetAccountData( CAccount* pAccount, const char* szKey ) { //Get the user ID int iUserID = pAccount->GetID(); //create a new registry result for the query return CRegistryResult result; //Select the value and type from the database where the user is our user and the key is the required key m_pDatabaseManager->QueryWithResultf ( m_hDbConnection, &result, "SELECT value,type from userdata where userid=? and key=? LIMIT 1", SQLITE_INTEGER, iUserID, SQLITE_TEXT, szKey ); // Default result is nil CLuaArgument* pResult = new CLuaArgument (); //Do we have any results? if ( result->nRows > 0 ) { const CRegistryResultRow& row = result->Data.front(); int iType = static_cast < int > ( row[1].nVal ); //Account data is stored as text so we don't need to check what type it is just return it if ( iType == LUA_TBOOLEAN ) { SString strResult = (const char *)row[0].pVal; pResult->ReadBool ( strResult == "true" ); } else if ( iType == LUA_TNUMBER ) pResult->ReadNumber ( strtod ( (const char *)row[0].pVal, NULL ) ); else pResult->ReadString ( (const char *)row[0].pVal ); } else { //No results pResult->ReadBool ( false ); } return pResult; }