Guest User

mysql ban

a guest
Jul 19th, 2014
414
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==========================================
  2. // ========= [ DevoXx Scripting ] ===========
  3. // [ FilterScript - MySQL Ban ]
  4. // ---| Uživajte | ---
  5. // ==========================================
  6.  
  7. // #3 (Druga Filter Scripta)
  8.  
  9. // --- [Includes] ---
  10. #include <a_samp>
  11. #include <a_mysql>
  12. #include <sscanf2>
  13. #include <zcmd>
  14.  
  15. // --- [Ostalo] ---
  16. #define NARANDZASTA 0xFF9900AA
  17. #define SCM SendClientMessage
  18.  
  19. // --- [Databaza] ---
  20. #define MySQL_HOST "localhost"
  21. #define MySQL_DATABASE "databaza_imebaze"
  22. #define MySQL_USER "root"
  23. #define MySQL_PASS ""
  24.  
  25. // --------- [Ostale Definicije] ---------
  26. public OnFilterScriptInit()
  27. {
  28. mysql_connect(MySQL_HOST, MySQL_USER, MySQL_PASS, MySQL_DATABASE); // Ucitavanje databaze
  29. return 1;
  30. }
  31.  
  32. public OnFilterScriptExit()
  33. {
  34. mysql_close();
  35. return 1;
  36. }
  37. public OnPlayerConnect(playerid)
  38. {
  39. new BananIP[32];
  40. GetPlayerIp(playerid, BananIP, sizeof BananIP);
  41. new query[255];
  42. format(query, sizeof query, "SELECT `razlog`, `datum`, `adminbanovao` FROM `banovi` WHERE `nickigraca` = '%s' OR `ip` = '%s'", ImeIgraca(playerid), BananIP);
  43. mysql_query(query);
  44. mysql_store_result();
  45. if(mysql_num_rows())
  46. {
  47. new razlog[32], str[165], datum[32], adminbanovao[32];
  48. mysql_fetch_row(str);
  49. sscanf(str, "p<|>s[32]s[32]s[32]", razlog, datum, adminbanovao);
  50. format(str, sizeof str, "{FFFFFF}|ISKLJUCENJE SA SERVERA| {FF0000}Vi ste banovani sa ovog servera. Razlog: {FFFFFF}%s. {FF0000}Danasnji Datum: {FFFFFF}%s. {FF0000}Admin: %s", razlog, datum, adminbanovao);
  51. SCM(playerid, NARANDZASTA, str);
  52. Kick(playerid);
  53. }
  54. mysql_free_result();
  55. return 1;
  56. }
  57. ImeIgraca(playerid)
  58. {
  59. new igrac[MAX_PLAYER_NAME];
  60. GetPlayerName(playerid, igrac, sizeof(igrac));
  61. return igrac;
  62. }
  63. stock Banovani(playerid, adminbanovao[], razlog[])
  64. {
  65. new BananIP[32], dan, mjesec, godina, sat, minuta;
  66. getdate(godina, mjesec, dan);
  67. gettime(sat, minuta);
  68. GetPlayerIp(playerid, BananIP, sizeof BananIP);
  69. new query[255];
  70. format(query, sizeof query, "INSERT INTO `banovi` (`nickigraca`, `ip`, `datum`, `razlog`, `adminbanovao`) VALUES ('%s', '%s', '%d.%d.%d, %d:%d', '%s', '%s')", ImeIgraca(playerid), BananIP, dan, mjesec, godina, sat, minuta, razlog, adminbanovao);
  71. mysql_query(query);
  72. new str[95];
  73. format(str, sizeof str, "[Vi ste Banovani sa naseg servera] {FFFFFF}Vasa IP Adresa: %s", BananIP);
  74. SCM(playerid, NARANDZASTA, str);
  75. SetTimerEx("IzbaciIgraca", 100, false, "d", playerid);
  76. }
  77. CMD:ban(playerid, params[])
  78. {
  79. if(!IsPlayerAdmin(playerid)) return SCM(playerid, NARANDZASTA, "(INFO) Niste autorizovani da koristite ovu komandu!"); // RCON Admin
  80. new igrac, razlog[138];
  81. if(sscanf(params, "ds[100]", igrac, razlog)) return SCM(playerid, NARANDZASTA, "Koristite: {FFFFFF}/ban [ID Igraca] [Razlog]");
  82. new string[138];
  83. format(string, sizeof string, "{FF0000}BAN | Igrac %s je banovan od Admina %s, Razlog: %s", ImeIgraca(igrac), ImeIgraca(playerid), razlog);
  84. SendClientMessageToAll(-1, string);
  85. Banovani(igrac, ImeIgraca(playerid), razlog);
  86. return 1;
  87. }
  88.  
  89. forward IzbaciIgraca(playerid);
  90. public IzbaciIgraca(playerid)
  91. {
  92. Kick(playerid);
  93. return 1;
  94. }
  95.  
  96.  
  97. // ------------ [ Kraj, Nadam se da ce nekima da pomogne, Uzivajte ] ------------
RAW Paste Data