Crowlai 1 Posted April 6, 2020 Share Posted April 6, 2020 (edited) Hello, im writing own offline shops and i have a problem that i cant deal with. I encountered a problem with getting the total number of yang from the currency safebox. The type of data storage in the column is "bigint", the equivalent to "long long" in c++.I tried to do it by all means but the number after reading is a minus value. When i set the data type to "int" everything works as it should but this data type is unfortunately too small. Any ideas anyone has? Edited April 8, 2020 by Crowlai Link to comment Share on other sites More sharing options...
Johnny69 365 Posted April 6, 2020 Share Posted April 6, 2020 How do you convert data from MYSQL_ROW to long long in your code ? Link to comment Share on other sites More sharing options...
Crowlai 1 Posted April 6, 2020 Author Share Posted April 6, 2020 (edited) 2 hours ago, Johnny69 said: How do you convert data from MYSQL_ROW to long long in your code ? For example: char* playerOffYang; char* playerOffWon; long long playerOfflineYang; long long playerOfflineWon; SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT collected_yang, collected_won ..............")); SQLResult * pRes = pkMsg->Get(); if (pRes->uiNumRows > 0){ MYSQL_ROW row; while ((row = mysql_fetch_row(pRes->pSQLResult)) != NULL){ playerOfflineYang = row[0]; playerOfflineWon = row[1]; } } str_to_number(playerOfflineYang, playerOffYang); str_to_number(playerOfflineWon, playerOffWon); Edited April 6, 2020 by Crowlai Link to comment Share on other sites More sharing options...
Solution Johnny69 365 Posted April 7, 2020 Solution Share Posted April 7, 2020 Try it like this: long long playerOfflineYang = 0; long long playerOfflineWon = 0; // Add LIMIT 1 SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT collected_yang, collected_won")); SQLResult * pRes = pkMsg->Get(); if (pRes->uiNumRows > 0){ MYSQL_ROW row = mysql_fetch_row(pRes->pSQLResult); if(row) { str_to_number(playerOfflineYang, row[0]); str_to_number(playerOfflineWon, row[1]); } } Link to comment Share on other sites More sharing options...
Crowlai 1 Posted April 7, 2020 Author Share Posted April 7, 2020 @Johnny69 I tried, as i said, i tried to do it by all means and when i lacked ideas, i applied for help. Output: [LOG] Request received to send data info -1474836480 yang to client. Database yang value: 20000000000 Link to comment Share on other sites More sharing options...
Johnny69 365 Posted April 7, 2020 Share Posted April 7, 2020 Well, maybe the value is ok but you print it with the wrong format (%d maybe). Long long variables need to printed with %lld format. 1 Link to comment Share on other sites More sharing options...
Premium Jira 458 Posted April 7, 2020 Premium Share Posted April 7, 2020 (edited) https://metin2.download/picture/YK3j3Ie43GQFo2R44qRL3zt6ncUzP77c/.png BIGINT, maybe there in your code is mistakes Edited September 4, 2022 by Metin2 Dev Core X - External 2 Internal 1 Link to comment Share on other sites More sharing options...
Crowlai 1 Posted April 7, 2020 Author Share Posted April 7, 2020 (edited) 1 hour ago, Johnny69 said: Well, maybe the value is ok but you print it with the wrong format (%d maybe). Long long variables need to printed with %lld format. Good observation, check how i will have some time. 1 hour ago, Moț said: https://metin2.download/picture/XtHh63bkn57vats5gHV8j0f1dL5095Ap/.png BIGINT, maybe there in your code is mistakes I did not think about it, i will also check how i will have some time. I'll let you know what and how probably in the evening;) Edited September 4, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Crowlai 1 Posted April 7, 2020 Author Share Posted April 7, 2020 2 hours ago, Johnny69 said: Well, maybe the value is ok but you print it with the wrong format (%d maybe). Long long variables need to printed with %lld format. Apr 07 19:42:09 :: [LOG] Request received to send data info 100000000000 yang, 1 won to client. Apr 07 19:42:09 :: [LOG] 1000000000 yang, 0 won paid out successfully I cant believe i spent so much time trying to do something that worked well only the problem was displaying in sys_log.. I feel stupid. 1 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