Advertisement
BM_R1KO

Untitled

Aug 6th, 2017
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. void Clients_LoadVIPFeaturesPre(int iClient, const char[] sFeatureName = NULL_STRING)
  3. {
  4.     DebugMessage("Clients_LoadVIPFeaturesPre %N", iClient)
  5.  
  6.     DebugMessage("AreClientCookiesCached %b", AreClientCookiesCached(iClient))
  7.  
  8.     if (!AreClientCookiesCached(iClient))
  9.     {
  10.         DataPack hDataPack = new DataPack();
  11.         hDataPack.WriteCell(UID(iClient));
  12.         if(sFeatureName[0])
  13.         {
  14.             hDataPack.WriteCell(true);
  15.             hDataPack.WriteString(sFeatureName);
  16.         }
  17.         else
  18.         {
  19.             hDataPack.WriteCell(false);
  20.         }
  21.         CreateTimer(0.5, Timer_CheckCookies, hDataPack, TIMER_FLAG_NO_MAPCHANGE|TIMER_DATA_HNDL_CLOSE);
  22.     }
  23.  
  24.     if(sFeatureName[0])
  25.     {
  26.         Clients_LoadVIPFeature(iClient, sFeatureName);
  27.         return;
  28.     }
  29.    
  30.     Clients_LoadVIPFeatures(iClient);
  31. }
  32.  
  33. void Clients_LoadVIPFeatures(int iClient)
  34. {
  35.     DebugMessage("LoadVIPFeatures %N", iClient)
  36.  
  37.     DebugMessage("AreClientCookiesCached %b", AreClientCookiesCached(iClient))
  38.    
  39.     if (!AreClientCookiesCached(iClient))
  40.     {
  41.         CreateTimer(0.5, Timer_CheckCookies, UID(iClient), TIMER_FLAG_NO_MAPCHANGE);
  42.     }
  43.  
  44.     DebugMessage("AreClientCookiesCached %b", AreClientCookiesCached(iClient))
  45.  
  46.     int iFeatures = g_hFeaturesArray.Length;
  47.     DebugMessage("FeaturesArraySize: %d", iFeatures)
  48.     if (iFeatures > 0)
  49.     {
  50.         char sFeatureName[FEATURE_NAME_LENGTH];
  51.  
  52.         g_hFeatures[iClient].GetString(KEY_GROUP, SZF(sFeatureName));
  53.         if (UTIL_CheckValidVIPGroup(sFeatureName))
  54.         {
  55.             for (int i = 0; i < iFeatures; ++i)
  56.             {
  57.                 g_hFeaturesArray.GetString(i, SZF(sFeatureName));
  58.                 Clients_LoadFeature(iClient, sFeatureName);
  59.             }
  60.         }
  61.     }
  62.  
  63.     DebugMessage("Clients_OnVIPClientLoaded: %d %N", iClient, iClient)
  64.  
  65.     Clients_OnVIPClientLoaded(iClient);
  66. }
  67.  
  68. void Clients_LoadVIPFeature(int iClient, const char[] sFeatureName)
  69. {
  70.     DebugMessage("LoadVIPFeature %N", iClient)
  71.  
  72.     int iFeatures = g_hFeaturesArray.Length;
  73.     DebugMessage("FeaturesArraySize: %d", iFeatures)
  74.     if (iFeatures > 0)
  75.     {
  76.         char sGroup[FEATURE_NAME_LENGTH];
  77.  
  78.         g_hFeatures[iClient].GetString(KEY_GROUP, SZF(sGroup));
  79.         if (UTIL_CheckValidVIPGroup(sGroup))
  80.         {
  81.             Clients_LoadFeature(iClient, sFeatureName);
  82.         }
  83.     }
  84. /*
  85.     DebugMessage("Clients_OnVIPClientLoaded: %d %N", iClient, iClient)
  86.  
  87.     Clients_OnVIPClientLoaded(iClient);
  88.     */
  89. }
  90.  
  91. void Clients_LoadFeature(int iClient, const char[] sFeatureName)
  92. {
  93.     static ArrayList hArray;
  94.     if (GLOBAL_TRIE.GetValue(sFeatureName, hArray))
  95.     {
  96.         DebugMessage("LoadClientFeature: %d - %s", i, sFeatureName)
  97.  
  98.         if (GetValue(iClient, view_as<VIP_ValueType>(hArray.Get(FEATURES_VALUE_TYPE)), sFeatureName))
  99.         {
  100.             DebugMessage("GetValue: == true")
  101.             if (view_as<VIP_FeatureType>(hArray.Get(FEATURES_ITEM_TYPE)) == TOGGLABLE)
  102.             {
  103.                 static char             sBuffer[4];
  104.                 static Handle           hCookie;
  105.                 static VIP_ToggleState  Status;
  106.                 hCookie = view_as<Handle>(hArray.Get(FEATURES_COOKIE));
  107.                 GetClientCookie(iClient, hCookie, SZF(sBuffer));
  108.                 Status = view_as<VIP_ToggleState>(StringToInt(sBuffer));
  109.                 DebugMessage("GetFeatureCookie: '%s'", sBuffer)
  110.                 if (sBuffer[0] == '\0' || (view_as<int>(Status) > 2 || view_as<int>(Status) < 0))
  111.                 {
  112.                     if(hArray.Length == 6)
  113.                     {
  114.                         Status = hArray.Get(FEATURES_DEF_STATUS) ? ENABLED:DISABLED;
  115.                     }
  116.                     else
  117.                     {
  118.                         Status = g_CVAR_bDefaultStatus ? ENABLED:DISABLED;
  119.                     }
  120.                     IntToString(view_as<int>(Status), SZF(sBuffer));
  121.                     SetClientCookie(iClient, hCookie, sBuffer);
  122.                     //  Features_SaveStatus(iClient, sFeatureName, hCookie, Status);
  123.                 }
  124.             }
  125.             else
  126.             {
  127.                 Status = ENABLED;
  128.             }
  129.  
  130.             Features_SetStatus(iClient, sFeatureName, Status);
  131.             //  Function_OnItemToggle(view_as<Handle>(hArray.Get(FEATURES_PLUGIN)), Function:hArray.Get(FEATURES_ITEM_SELECT), iClient, sFeatureName, NO_ACCESS, ENABLED);
  132.         }
  133.     }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement