Advertisement
Guest User

example bblock account system

a guest
Mar 23rd, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.37 KB | None | 0 0
  1. //BBlock
  2.  
  3. void CGameContext::ConRegister(IConsole::IResult *pResult, void *pUserData)
  4. {
  5.     CGameContext *pSelf = (CGameContext *) pUserData;
  6.     CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
  7.  
  8.     if(pPlayer->loggedIn){
  9.         pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chat","[BBlock]: You are already logged in.");
  10.     }else{
  11.        
  12.     if (pResult->NumArguments() == 0)
  13.     {
  14.             pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chat","[BBlock]: /register <username> <password>");
  15.  
  16.     }else{
  17.        
  18.         const char *pArg = pResult->GetString(0);
  19.  
  20.        
  21.         //get username and password
  22.        
  23.         std::string username = "notset";
  24.         std::string password = "notset";
  25.        
  26.         std::string token;
  27.         std::string mystring = pArg;
  28.        
  29.         int count = 0;
  30.         while(token != mystring){
  31.             count++;
  32.             token = mystring.substr(0,mystring.find_first_of(" "));
  33.             mystring = mystring.substr(mystring.find_first_of(" ") + 1);
  34.            
  35.             if(count == 1){
  36.                 username = token;
  37.             }
  38.            
  39.             if(count == 2){
  40.                 password = token;
  41.             }  
  42.         }
  43.    
  44.    
  45.        
  46.         if (!username.compare("notset") | !password.compare("notset") )
  47.         {
  48.             pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chat","[BBlock]: /register <username> <password>");
  49.         }else{
  50.  
  51.             //register logic here
  52.  
  53.  
  54.  
  55.            
  56.             CURL *curl;
  57.             std::string readBuffer;
  58.  
  59.             curl = curl_easy_init();
  60.            
  61.            
  62.             if(curl) {
  63.                
  64.                 std::string url = "http://92.42.46.160/tw/register.php?username=";
  65.                 url.append(username);
  66.                 url.append("&password=");
  67.                 url.append(password);
  68.                
  69.                 curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
  70.                 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
  71.                 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
  72.                 curl_easy_perform(curl);
  73.                 curl_easy_cleanup(curl);
  74.  
  75.        
  76.                
  77.    
  78.                 if(readBuffer.find("-1") != std::string::npos){
  79.                     pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chat","[BBlock]: The chosen username is already registered.");
  80.                 }
  81.                
  82.                 if(readBuffer.find("0") != std::string::npos){
  83.                     pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chat","[BBlock]: Successfully registered.");
  84.                    
  85.                     std::string info = "[BBlock]: You can now login with /login " + username + " " + password;
  86.                
  87.                    
  88.                     pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chat",info.c_str());
  89.                 }
  90.                
  91.                
  92.             }
  93.  
  94.  
  95.  
  96.     }      
  97.     }
  98.  
  99.    
  100.    
  101.    
  102. }
  103.  
  104.    
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement