Advertisement
Guest User

npc_vendor item inserter

a guest
Aug 16th, 2013
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.73 KB | None | 0 0
  1. /*
  2. *  Author: Daniel Balla, Date: August, 2013;
  3. *  Source code released for free use only;
  4. *  Not for selling;
  5. *  Please feel free to use and improve it;
  6. *  Desinged on Ubuntu 12.04;
  7. *  Required compilers: GCC, G++;
  8. */
  9. #include <iostream>
  10. #include <fstream>
  11. #include "header.h"
  12.  
  13. using namespace std;
  14.  
  15. int main()
  16. {
  17.     cout << "\nWhich table do you want to write in?";
  18.     cout << "\n 1. npc_vendor";
  19.     cout << "\n press q to quit\n";
  20.     char in;
  21.     ofstream SQLQuery("script.sql");
  22.     in=getchar();
  23.     if (in=='1')
  24.     {
  25.         cout << "\nPlease type in the entry of the vendor:";
  26.         int entry;
  27.         cin >> entry;
  28.         cout << "\nPlease type in the extended cost of the items:";
  29.         int extended_cost;
  30.         cin >> extended_cost;
  31.         cout << "\nPlease type in the time (millisecs) this item is able to be bought:";
  32.         int incrtime;
  33.         cin >> incrtime;
  34.         cout << "\nPlease type in how many times can this item be bought:";
  35.         int maxcount;
  36.         cin >> maxcount;
  37.         cout << "\nPlease type in the item IDs (if you have finished press q)\n";
  38.         string item;
  39.         string start="INSERT INTO `npc_vendor` (`entry`, `item`, `maxcount`, `incrtime`, `ExtendedCost`) VALUES\n";
  40.         cout << start;
  41.         SQLQuery << start;
  42.         int line=1;
  43.         do
  44.         {
  45.             cin >> item;
  46.             if (item=="q" or item=="Q")
  47.             {
  48.                 cout << ";";
  49.                 SQLQuery << ";";
  50.                 cout << "\nThanks for using the program! If you want to donate us: http://bloodsyndicate.vng.hu";
  51.             }
  52.             else
  53.             {
  54.                 if (line==1)
  55.                 {
  56.                     cout << "\n";
  57.                     SQLQuery << "\n";
  58.                     cout << "('" << entry << "', '" << item << "', '" << maxcount << "', '" << incrtime << "', '" << extended_cost << "')";
  59.                     SQLQuery << "('" << entry << "', '" << item << "', '" << maxcount << "', '" << incrtime << "', '" << extended_cost << "')";
  60.                     line++;
  61.                 }
  62.                 else
  63.                 {
  64.                     cout << ",\n";
  65.                     SQLQuery << ",\n";
  66.                     cout << "('" << entry << "', '" << item << "', '" << maxcount << "', '" << incrtime << "', '" << extended_cost << "')";
  67.                     SQLQuery << "('" << entry << "', '" << item << "', '" << maxcount << "', '" << incrtime << "', '" << extended_cost << "')";
  68.                 }
  69.             }
  70.         }
  71.         while (item!="q" or item=="Q");
  72.  
  73.     }
  74.     if (in=='q' or in=='Q')
  75.     {
  76.         cout << "\nThanks for using the program! If you want to donate us: http://bloodsyndicate.vng.hu";
  77.     }
  78.     return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement