execution88

Untitled

Jul 12th, 2025
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.41 KB | None | 0 0
  1. stock Quest:GenerateSapiJson()
  2. {
  3.     SAPI:CreateInsert("quests");
  4.  
  5.     strcpy(g_string_4096, "{");
  6.  
  7.     QuestCategoryDataCategory:GetListSapiJson(g_string_4096);
  8.     strcat(g_string_4096, ",");
  9.  
  10.     strcat(g_string_4096, "\"quest_list\":[");
  11.     for (new QUEST_CATEGORY:category = QUEST_CATEGORY:0; category < MAX_QUEST_CATEGORY; ++category)
  12.     {
  13.         if (!QuestCategoryDataCategory:IsInit(category))
  14.         {
  15.             continue;
  16.         }
  17.        
  18.         if (_:category != 0)
  19.         {
  20.             strcat(g_string_4096, ",");
  21.         }
  22.  
  23.         for (new quest_id = 0; quest_id < MAX_CATEGORY_QUEST; ++quest_id)
  24.         {
  25.             if (!QuestCategoryDataQuest:IsInit(category, quest_id))
  26.             {
  27.                 SendConsoleQuestDebug("[Quest:GenerateSapiJson]: category: %d, quest_id: %d !!!", _:category, quest_id);
  28.                 break;
  29.             }
  30.  
  31.             if (quest_id != 0)
  32.             {
  33.                 strcat(g_string_4096, ",");
  34.             }
  35.  
  36.             g_string_1024 = "";
  37.             QuestCategoryDataQuest:GetSapiJson(category, quest_id, g_string_1024);
  38.            
  39.             if (strlen(g_string_4096) + strlen(g_string_1024) >= sizeof(g_string_4096))
  40.             {
  41.                 SAPI:AddInsertJson(g_string_4096);
  42.                 g_string_4096[0] = EOS;
  43.             }
  44.  
  45.             strcat(g_string_4096, g_string_1024);
  46.         }
  47.     }
  48.  
  49.     if (g_string_4096[0] != EOS)
  50.     {
  51.         SAPI:AddInsertJson(g_string_4096);
  52.         g_string_4096[0] = EOS;
  53.     }
  54.  
  55.     strcat(g_string_4096, "]");
  56.     strcat(g_string_4096, ",");
  57.     QuestCategoryDataBonus:GetSapiJson(g_string_4096);
  58.     strcat(g_string_4096, ",");
  59.     // CHAPTER
  60.     QuestChapterDataChapter:GetSapiJson(g_string_4096);
  61.     strcat(g_string_4096, ",");
  62.  
  63.     SAPI:AddInsertJson(g_string_4096);
  64.     g_string_4096[0] = EOS;
  65.  
  66.     strcat(g_string_4096, "\"chapter_quest_list\":[");
  67.  
  68.     for (new QUEST_CHAPTER:chapter = QUEST_CHAPTER:0; chapter < MAX_QUEST_CHAPTER; ++chapter)
  69.     {
  70.         if (!QuestChapterDataChapter:IsInit(chapter))
  71.         {
  72.             break;
  73.         }
  74.  
  75.         if (_:chapter != 0)
  76.         {
  77.             strcat(g_string_4096, ",");
  78.         }
  79.        
  80.         for (new quest_id = 0; quest_id < MAX_CHAPTER_QUEST; ++quest_id)
  81.         {
  82.             if (!QuestChapterDataQuest:IsInit(chapter, quest_id))
  83.             {
  84.                 break;
  85.             }
  86.  
  87.             QuestChapterDataQuest:GetSapiJson(chapter, quest_id, sapi_query_str, SAPI_INSERT_QUERY_LEN);
  88.             QuestChapterDataTask:GetSapiJson(chapter, quest_id, sapi_query_str, SAPI_INSERT_QUERY_LEN);
  89.  
  90.             strcat(sapi_query_str, ",");
  91.             QuestChapterDataReward:GetListJson(chapter, quest_id, sapi_query_str, SAPI_INSERT_QUERY_LEN);
  92.             strcat(sapi_query_str, "}");
  93.  
  94.             if (strlen(sapi_query_str) > 8000)
  95.             {
  96.                 sapi_query_str[strlen(sapi_query_str) - 1] = EOS;
  97.                 SAPI:SendSingleInsert(sapi_query_str);
  98.             }
  99.         }
  100.     }
  101.  
  102.     strcat(sapi_query_str, "]");
  103.     strcat(sapi_query_str, "}");
  104.  
  105.     SendConsoleQuestDebug("[QUEST]============================================", -1);
  106.     SendConsoleQuestDebug(sapi_query_str, -1);
  107.     if (sapi_query_str[0] != EOS)
  108.     {
  109.         SAPI:SendSingleInsert(sapi_query_str);
  110.     }
  111.  
  112.     SAPI:SendInsert();
  113.     SAPI:Request(SAPI:JsonTablePurge, .key = "quests", .await_queries_handle = connection[HANDLE_GENERAL]);
  114. }
Advertisement
Add Comment
Please, Sign In to add comment