MegastoRM

trendhost_antiadvertisements

Oct 7th, 2012
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. #include <amxmodx>
  2.  
  3. new cvar_ipblock, cvar_domainblock, cvar_prikaz, cvar_poruka, cvar_ime
  4. new bool:reklama_chat
  5. new bool:reklama_ime
  6.  
  7. new const domain_bez_tacke[][] = {
  8. "com",
  9. "net",
  10. "rs",
  11. "info",
  12. "tk",
  13. "ws",
  14. "org",
  15. "biz",
  16. "eu",
  17. "name",
  18. "ba",
  19. "me",
  20. "mobi",
  21. "ch",
  22. "mk",
  23. "ro",
  24. "pl",
  25. "de",
  26. "hr",
  27. "us",
  28. "ca",
  29. "uk",
  30. "it",
  31. "co",
  32. "in",
  33. "edu"
  34. }
  35.  
  36. new const domain_sa_tackom[][] = {
  37. "www.",
  38. "http://",
  39. ".com",
  40. ".net",
  41. ".rs",
  42. ".info",
  43. ".tk",
  44. ".ws",
  45. ".org",
  46. ".biz",
  47. ".eu",
  48. ".name",
  49. ".ba",
  50. ".me",
  51. ".mobi",
  52. ".ch",
  53. ".mk",
  54. ".ro",
  55. ".pl",
  56. ".de",
  57. ".hr",
  58. ".us",
  59. ".ca",
  60. ".uk",
  61. ".it",
  62. ".co",
  63. ".in",
  64. ".edu"
  65. }
  66.  
  67. public plugin_init()
  68. {
  69. register_plugin("Advanced Advertising Control", "1.0", "Lucky & A1r*M4x")
  70.  
  71. register_clcmd("say", "cmdsay")
  72. register_clcmd("say_team", "cmdsay")
  73.  
  74. cvar_ipblock = register_cvar("aac_ipblock", "1")
  75. cvar_domainblock = register_cvar("aac_domainblock", "1")
  76. cvar_prikaz = register_cvar("aac_prikaz", "1")
  77. cvar_poruka = register_cvar("aac_poruka", "[AAC] Reklamiranje je zabranjeno!")
  78. cvar_ime = register_cvar("aac_ime", "[AAC]")
  79. }
  80.  
  81. public cmdsay(id)
  82. {
  83. new message[194]
  84. read_args(message, charsmax(message))
  85. remove_quotes(message)
  86.  
  87. reklama_chat = false
  88. new broj = 0
  89. new tacka = 0
  90. new dtacka = 0
  91. new razmak = 0
  92. new dbt = 0
  93. new wwwhttp = 0
  94. new i = 0
  95.  
  96. if(get_pcvar_float(cvar_ipblock))
  97. {
  98. while(message[i])
  99. {
  100. if('0' <= message[i] <= '9')
  101. {
  102. broj++
  103. }
  104. if(message[i] == '.')
  105. {
  106. tacka++
  107. }
  108. if(message[i] == ':')
  109. {
  110. dtacka++
  111. }
  112. if(message[i] == ' ')
  113. {
  114. razmak++
  115. }
  116. i++
  117. }
  118. }
  119.  
  120. if(get_pcvar_float(cvar_domainblock))
  121. {
  122. new message_check[194]
  123. message_check = message
  124.  
  125. while(containi(message_check, " ") != -1)
  126. {
  127. replace(message_check, 193, " ", "")
  128. }
  129.  
  130. new j = 0
  131.  
  132. while(j < sizeof(domain_bez_tacke))
  133. {
  134. if(containi(message_check, domain_bez_tacke[j]) != -1)
  135. {
  136. dbt++
  137. }
  138. j++
  139. }
  140. if(containi(message_check, "www") != -1 || containi(message_check, "http") != -1 && !(containi(message_check, "trendhost") != -1 || containi(message_check, "trendhost.net") != -1 || containi(message_check, "www.trendhost.net") != -1))
  141. {
  142. wwwhttp++
  143. }
  144.  
  145. new k = 0
  146.  
  147. while(k < sizeof(domain_sa_tackom))
  148. {
  149. if(containi(message_check, domain_sa_tackom[k]) != -1 && !(containi(message_check, "trendhost") != -1 || containi(message_check, "trendhost.net") != -1 || containi(message_check, "www.trendhost.net") != -1))
  150. {
  151. reklama_chat = true
  152. }
  153. k++
  154. }
  155.  
  156. if(dbt >= 1 && wwwhttp >= 1)
  157. {
  158. reklama_chat = true
  159. }
  160. }
  161.  
  162. if(get_pcvar_float(cvar_ipblock))
  163. {
  164. if(broj >= 9 && tacka >= 3 && dtacka >= 1) // ako je x.x.x.x:xxxxx
  165. {
  166. reklama_chat = true
  167. }
  168. else if(broj >= 10) // ako je x x x x xxxxx
  169. {
  170. reklama_chat = true
  171. }
  172. else if(broj >= 4 && tacka >= 3) // ako je x.x.x.x
  173. {
  174. reklama_chat = true
  175. }
  176. else if(dtacka >= 1 && broj >= 5) // ako je :xxxxx
  177. {
  178. reklama_chat = true
  179. }
  180. }
  181.  
  182. if(reklama_chat == true)
  183. {
  184. new poruka[194]
  185. get_pcvar_string(cvar_poruka, poruka, 193)
  186.  
  187. if(!get_pcvar_float(cvar_prikaz))
  188. {
  189. client_print(id, print_chat, "%s", poruka)
  190. }
  191. else if(get_pcvar_float(cvar_prikaz))
  192. {
  193. client_cmd(id, "say %s", poruka)
  194. }
  195.  
  196. new ime[64]
  197. get_pcvar_string(cvar_ime, ime, 63)
  198.  
  199. new name[194]
  200. get_user_info(id, "name", name, 193)
  201. new userip[32]
  202. get_user_ip(id, userip, 31)
  203. new authid[64]
  204. get_user_authid(id, authid, 63)
  205.  
  206. log_to_file("aac.txt", "Igrac: %s, AuthID: %s Tip Reklamiranja: Reklama u Chatu, Poruka: %s, IP igraca: %s", name, authid, message, userip)
  207. return PLUGIN_HANDLED
  208. }
  209. return PLUGIN_CONTINUE
  210. }
  211.  
  212. public client_connect(id) // kad se igrac konektuje, plugin mu proveri ime
  213. {
  214. proveri_ime(id)
  215. }
  216.  
  217. public client_infochanged(id) // kad igrac promeni neki info, plugin mu proverava ime
  218. {
  219. proveri_ime(id)
  220. }
  221.  
  222. proveri_ime(id)
  223. {
  224. new name[32]
  225. get_user_info(id, "name", name, 31)
  226.  
  227. reklama_ime = false
  228. new broj = 0
  229. new tacka = 0
  230. new dtacka = 0
  231. new razmak = 0
  232. new dbt = 0
  233. new wwwhttp = 0
  234. new i = 0
  235.  
  236. if(get_pcvar_float(cvar_ipblock))
  237. {
  238. while(name[i])
  239. {
  240. if('0' <= name[i] <= '9')
  241. {
  242. broj++
  243. }
  244. if(name[i] == '.')
  245. {
  246. tacka++
  247. }
  248. if(name[i] == ':')
  249. {
  250. dtacka++
  251. }
  252. if(name[i] == ' ')
  253. {
  254. razmak++
  255. }
  256. i++
  257. }
  258. }
  259.  
  260. if(get_pcvar_float(cvar_domainblock))
  261. {
  262. new name_check[64]
  263. name_check = name
  264.  
  265. while(containi(name_check, " ") != -1)
  266. {
  267. replace(name_check, 63, " ", "")
  268. }
  269.  
  270. new j = 0
  271.  
  272. while(j < sizeof(domain_bez_tacke))
  273. {
  274. if(containi(name_check, domain_bez_tacke[j]) != -1)
  275. {
  276. dbt++
  277. }
  278. j++
  279. }
  280. if(containi(name_check, "www") != -1 || containi(name_check, "http") != -1)
  281. {
  282. wwwhttp++
  283. }
  284.  
  285. new k = 0
  286.  
  287. while(k < sizeof(domain_sa_tackom))
  288. {
  289. if(containi(name_check, domain_sa_tackom[k]) != -1)
  290. {
  291. reklama_ime = true
  292. }
  293. k++
  294. }
  295.  
  296. if(dbt >= 1 && wwwhttp >= 1)
  297. {
  298. reklama_ime = true
  299. }
  300. }
  301.  
  302. if(get_pcvar_float(cvar_ipblock))
  303. {
  304. if(broj >= 9 && tacka >= 2) // ako je x.x.x.x:xxxxx
  305. {
  306. reklama_ime = true
  307. }
  308. else if(broj >= 10) // ako je x x x x xxxxx
  309. {
  310. reklama_ime = true
  311. }
  312. else if(broj >= 4 && tacka >= 3) // ako je x.x.x.x
  313. {
  314. reklama_ime = true
  315. }
  316. else if(dtacka >= 1 && broj >= 5) // ako je :xxxxx
  317. {
  318. reklama_ime = true
  319. }
  320. }
  321.  
  322. if(reklama_ime == true)
  323. {
  324. new ime[64]
  325. get_pcvar_string(cvar_ime, ime, 63)
  326.  
  327. client_cmd(id, "name %s; setinfo name %s", ime, ime)
  328.  
  329. new name[194]
  330. get_user_info(id, "name", name, 193)
  331. new userip[32]
  332. get_user_ip(id, userip, 31)
  333. new authid[64]
  334. get_user_authid(id, authid, 63)
  335.  
  336. log_to_file("aac.txt", "Igrac: %s, AuthID: %s Tip Reklamiranja: Reklama u Imenu, IP igraca: %s", name, authid, userip)
  337. return PLUGIN_HANDLED
  338. }
  339. return PLUGIN_CONTINUE
  340. }
Advertisement
Add Comment
Please, Sign In to add comment