Advertisement
Guest User

Untitled

a guest
Aug 8th, 2020
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #include <a_samp>
  2. #include <a_mysql>
  3.  
  4. static const SQL_HOST[10] = "localhost";
  5. static const SQL_USER[5] = "root";
  6. static const SQL_PASS[1] = "";
  7. static const SQL_DB[6] = "testt";
  8.  
  9. enum PI { rekord, online }
  10. new PortalInfo[PI];
  11. new MySQL:sql;
  12.  
  13. public OnFilterScriptInit() {
  14. sql = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS, SQL_DB);
  15. if(mysql_errno(sql) != 0 || sql == MYSQL_INVALID_HANDLE) {
  16. print("Konekcija sa databazom nije uspesna.");
  17. SendRconCommand("exit");
  18. return true; }
  19. mysql_tquery(sql, "SELECT * FROM `test`", "UcitajRekord");
  20. return true;
  21. }
  22.  
  23. public OnFilterScriptExit() {
  24. mysql_close(sql);
  25. return true;
  26. }
  27.  
  28. public OnPlayerConnect(playerid) {
  29. PortalInfo[online] ++;
  30. static query[128];
  31. mysql_format(sql, query, sizeof(query), "UPDATE `test`\
  32. SET `online`='%d'\
  33. WHERE `sqlid`= '1'", PortalInfo[online]);
  34. mysql_tquery(sql, query);
  35. RekordProvera();
  36. return true;
  37. }
  38.  
  39. public OnPlayerDisconnect(playerid, reason) {
  40. PortalInfo[online] --;
  41. static query[128];
  42. mysql_format(sql, query, sizeof(query), "UPDATE `test`\
  43. SET `online`='%d'\
  44. WHERE `sqlid`= '1'", PortalInfo[online]);
  45. mysql_tquery(sql, query);
  46. return true;
  47. }
  48.  
  49. forward public UcitajRekord();
  50. public UcitajRekord() { if(cache_num_rows() > 0) { cache_get_value_int(0, "rekord", PortalInfo[rekord]); } }
  51.  
  52. static stock RekordProvera() {
  53. if(PortalInfo[rekord] < PortalInfo[online]) {
  54. PortalInfo[rekord] = PortalInfo[online];
  55. static query[128];
  56. mysql_format(sql, query, sizeof(query), "UPDATE `test`\
  57. SET `rekord`='%d'\
  58. WHERE `sqlid`= '1'", PortalInfo[online]);
  59. mysql_tquery(sql, query);
  60. return true; }
  61. return true;
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement