Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock Quest:GenerateSapiJson()
- {
- SAPI:CreateInsert("quests");
- strcpy(g_string_4096, "{");
- QuestCategoryDataCategory:GetListSapiJson(g_string_4096);
- strcat(g_string_4096, ",");
- strcat(g_string_4096, "\"quest_list\":[");
- for (new QUEST_CATEGORY:category = QUEST_CATEGORY:0; category < MAX_QUEST_CATEGORY; ++category)
- {
- if (!QuestCategoryDataCategory:IsInit(category))
- {
- continue;
- }
- if (_:category != 0)
- {
- strcat(g_string_4096, ",");
- }
- for (new quest_id = 0; quest_id < MAX_CATEGORY_QUEST; ++quest_id)
- {
- if (!QuestCategoryDataQuest:IsInit(category, quest_id))
- {
- SendConsoleQuestDebug("[Quest:GenerateSapiJson]: category: %d, quest_id: %d !!!", _:category, quest_id);
- break;
- }
- if (quest_id != 0)
- {
- strcat(g_string_4096, ",");
- }
- g_string_1024 = "";
- QuestCategoryDataQuest:GetSapiJson(category, quest_id, g_string_1024);
- if (strlen(g_string_4096) + strlen(g_string_1024) >= sizeof(g_string_4096))
- {
- SAPI:AddInsertJson(g_string_4096);
- g_string_4096[0] = EOS;
- }
- strcat(g_string_4096, g_string_1024);
- }
- }
- if (g_string_4096[0] != EOS)
- {
- SAPI:AddInsertJson(g_string_4096);
- g_string_4096[0] = EOS;
- }
- strcat(g_string_4096, "]");
- strcat(g_string_4096, ",");
- QuestCategoryDataBonus:GetSapiJson(g_string_4096);
- strcat(g_string_4096, ",");
- // CHAPTER
- QuestChapterDataChapter:GetSapiJson(g_string_4096);
- strcat(g_string_4096, ",");
- SAPI:AddInsertJson(g_string_4096);
- g_string_4096[0] = EOS;
- strcat(g_string_4096, "\"chapter_quest_list\":[");
- for (new QUEST_CHAPTER:chapter = QUEST_CHAPTER:0; chapter < MAX_QUEST_CHAPTER; ++chapter)
- {
- if (!QuestChapterDataChapter:IsInit(chapter))
- {
- break;
- }
- if (_:chapter != 0)
- {
- strcat(g_string_4096, ",");
- }
- for (new quest_id = 0; quest_id < MAX_CHAPTER_QUEST; ++quest_id)
- {
- if (!QuestChapterDataQuest:IsInit(chapter, quest_id))
- {
- break;
- }
- QuestChapterDataQuest:GetSapiJson(chapter, quest_id, sapi_query_str, SAPI_INSERT_QUERY_LEN);
- QuestChapterDataTask:GetSapiJson(chapter, quest_id, sapi_query_str, SAPI_INSERT_QUERY_LEN);
- strcat(sapi_query_str, ",");
- QuestChapterDataReward:GetListJson(chapter, quest_id, sapi_query_str, SAPI_INSERT_QUERY_LEN);
- strcat(sapi_query_str, "}");
- if (strlen(sapi_query_str) > 8000)
- {
- sapi_query_str[strlen(sapi_query_str) - 1] = EOS;
- SAPI:SendSingleInsert(sapi_query_str);
- }
- }
- }
- strcat(sapi_query_str, "]");
- strcat(sapi_query_str, "}");
- SendConsoleQuestDebug("[QUEST]============================================", -1);
- SendConsoleQuestDebug(sapi_query_str, -1);
- if (sapi_query_str[0] != EOS)
- {
- SAPI:SendSingleInsert(sapi_query_str);
- }
- SAPI:SendInsert();
- SAPI:Request(SAPI:JsonTablePurge, .key = "quests", .await_queries_handle = connection[HANDLE_GENERAL]);
- }
Advertisement
Add Comment
Please, Sign In to add comment