Advertisement
Guest User

Untitled

a guest
Mar 15th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. new opHandle = -1;
  2.  
  3. enum e_mysql_data {
  4. myhost,
  5. myuser,
  6. mydatabase,
  7. mypassword
  8. }
  9.  
  10. static MySQL[e_mysql_data][45];
  11.  
  12. public OnGameModeInit() {
  13.  
  14. opmysql_init();
  15.  
  16. opmysql_runFile("MySQL/Vehiculos.sql");
  17. opmysql_runFile("MySQL/Subsidios.sql");
  18. opmysql_runFile("MySQL/Logs.sql");
  19.  
  20. #if defined opmysql_OnGameModeInit
  21. return opmysql_OnGameModeInit();
  22. #else
  23. return 1;
  24. #endif
  25. }
  26.  
  27. #if defined _ALS_OnGameModeInit
  28. #undef OnGameModeInit
  29. #else
  30. #define _ALS_OnGameModeInit
  31. #endif
  32. #define OnGameModeInit opmysql_OnGameModeInit
  33.  
  34. forward opmysql_OnGameModeInit();
  35.  
  36. stock opmysql_init() {
  37.  
  38. static const filename[] = "database.ini";
  39.  
  40. if (!fexist (filename)) {
  41. printf ("NO EXISTE EL ARCHIVO DATABASE.ini ...");
  42.  
  43. static bool: running = true;
  44.  
  45. while (running) {}
  46.  
  47. }
  48.  
  49. new
  50. stringRead[100],
  51. File: config = fopen (filename, io_read);
  52.  
  53. while (fread(config, stringRead)) {
  54.  
  55. if (stringRead[0] == '#' || stringRead[1] == '#')
  56. continue;
  57.  
  58. printf ("Informacion de MySQL:");
  59.  
  60. sscanf (stringRead, "p<|>s[30]s[30]s[30]s[30]", MySQL[myhost], MySQL[myuser], MySQL[mydatabase], MySQL[mypassword]);
  61.  
  62. printf ("\t- Host: \"%s\"", MySQL[myhost]);
  63. printf ("\t- User: \"%s\"", MySQL[myuser]);
  64. printf ("\t- Database: \"%s\"", MySQL[mydatabase]);
  65. printf ("\t- Password: \"%s\"", MySQL[mypassword]);
  66.  
  67. }
  68.  
  69. mysql_log(LOG_WARNING | LOG_ERROR);
  70.  
  71. printf ("Intentando conectar ..");
  72.  
  73. opHandle = mysql_connect (MySQL[myhost], MySQL[myuser], MySQL[mydatabase], MySQL[mypassword]);
  74. mysql_log(LOG_ERROR | LOG_WARNING);
  75.  
  76. }
  77. stock opmysql_runFile(const filename[]) {
  78.  
  79. if (!fexist(filename)) {
  80. printf ("[src/include/optimus/mysql.inc]: Error, opmysql_runFile (Archivo '%s' no existe)", filename);
  81. return 0;
  82. }
  83.  
  84. new
  85. File:arch = fopen(filename, io_read),
  86. stringRead[1024];
  87.  
  88. while (fread(arch, stringRead)) {
  89. if (strfind(stringRead, "#") != -1 || strlen(stringRead) < 5) continue;
  90.  
  91. mysql_tquery(opHandle, stringRead, "", "");
  92. //printf(stringRead);
  93. }
  94.  
  95. return 1;
  96. }
  97.  
  98. // All definitions
  99. #define opmysql_tquery( mysql_tquery(opHandle,
  100. #define opmysql_pquery( mysql_pquery(opHandle,
  101. #define opmysql_format( mysql_format(opHandle,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement