Guest User

Untitled

a guest
Apr 25th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.46 KB | None | 0 0
  1. bool cChat::BuyVIPCommand(LPOBJ gObj, char *Msg)
  2. {
  3.     if(Vip.Config.Enabled)
  4.     {
  5.         int Hours = 1;
  6.         char State[255];
  7.         sscanf(Msg, "%s %d", &State, &Hours);
  8.        
  9.         int RealState = -1;
  10.         for(int i = 1; i<= Vip.Config.NumStates; i++)
  11.         {
  12.             if(!_strcmpi(State, Vip.Config.VIPState[i].VIPName))
  13.             {
  14.                 RealState = i;
  15.                 break;
  16.             }
  17.         }
  18.  
  19.         if(AddTab[gObj->m_Index].VIP_Type > 0 || AddTab[gObj->m_Index].VIP_Min > 0)
  20.         {
  21.             if(Vip.Config.AllowRebuying)
  22.             {
  23.                 if(AddTab[gObj->m_Index].VIP_Type != RealState)
  24.                 {
  25.                     MessageLog(1, c_Red, t_VIP, gObj, "[VIPBuy] You can't buy another type of vip.");      
  26.                     return true;
  27.                 }
  28.             }
  29.             else
  30.             {
  31.                 MessageLog(1, c_Red, t_VIP, gObj, "[VIPBuy] You have already bought VIP.");    
  32.                 return true;
  33.             }
  34.         }
  35.  
  36.         if(RealState == -1)
  37.         {            
  38.             MessageLog(1, c_Red, t_VIP, gObj, "[VIP] There are no such vip status.");
  39.             return true;
  40.         }
  41.         if(!Vip.Config.VIPState[RealState].EnabledCmd)
  42.         {            
  43.             MessageLog(1, c_Red, t_VIP, gObj, "[VIP] You can't buy %s vip status.", Vip.Config.VIPState[RealState].VIPName);
  44.             return true;
  45.         }
  46.         if(Hours < Vip.Config.VIPState[RealState].MinHours || Hours > Vip.Config.VIPState[RealState].MaxHours)
  47.         {
  48.             MessageLog(1, c_Red, t_VIP, gObj, "[VIP] You can't buy less then %d and more than %d hours.", Vip.Config.VIPState[RealState].MinHours, Vip.Config.VIPState[RealState].MaxHours);
  49.             return true;
  50.         }
  51.  
  52.         if(CheckCommand(gObj, Vip.Config.VIPState[RealState].EnabledCmd, GmSystem.NONE, Vip.Config.VIPState[RealState].CostZen * Hours,
  53.             Vip.Config.VIPState[RealState].CostPCPoints * Hours, Vip.Config.VIPState[RealState].CostWCoins * Hours, 0, 2, 0, "VIPBuy", "/vipbuy <state> <hours>", Msg))
  54.             return true;
  55.  
  56.         TakeCommand(gObj, Vip.Config.VIPState[RealState].CostZen * Hours, Vip.Config.VIPState[RealState].CostPCPoints * Hours,
  57.                 Vip.Config.VIPState[RealState].CostWCoins * Hours, "BuyVIP");
  58.  
  59.         MuOnlineQuery.ExecQuery("UPDATE MEMB_INFO SET %s = (%s + %d), %s = %d WHERE MEMB__ID = '%s'", Vip.Config.ColumnDate, Vip.Config.ColumnDate, Hours*60, Vip.Config.Column, RealState, gObj->Name);   
  60.             MuOnlineQuery.Fetch();
  61.             MuOnlineQuery.Close();
  62.  
  63.         AddTab[gObj->m_Index].VIP_Min += Hours*60;
  64.         AddTab[gObj->m_Index].VIP_Type = RealState;
  65.  
  66.         MessageLog(1, c_Red, t_VIP, gObj, "[VIPBuy] Successfully bought %s for %d Hour(s)", Vip.Config.VIPState[RealState].VIPName, Hours);
  67.         MessageLog(1, c_Red, t_VIP, gObj, "[VIPBuy] Your VIP status starts right now!");
  68.     }
  69.     return true;
  70. }
Add Comment
Please, Sign In to add comment