HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*** --[Memo IPs Plugin]--
  2.  
  3. Magyarositota:Servercfg
  4. Weboldal:versus.cjb.hu
  5.  
  6.  ***/
  7.  
  8. #include <amxmodx>
  9. #include <amxmisc>
  10.  
  11. new PLUGIN[] = "AmxModX Memo"
  12. new VERSION[] = "0.0.1"
  13. new AUTHOR[] = "Kenvelo"
  14.  
  15.  
  16. public plugin_init()
  17. {
  18.  
  19. register_plugin(PLUGIN, VERSION, AUTHOR)
  20.  
  21. register_concmd("amx_memo_who", "amx_memo_who", ADMIN_IMMUNITY, "<name> - check the registered name of user")
  22. register_concmd("amx_memo_listall", "amx_memo_listall", ADMIN_IMMUNITY, " - list all registered entries")
  23. register_concmd("amx_memo_rename", "amx_memo_rename", ADMIN_IMMUNITY, "<listname> <newlistname> - renames a registered entry")
  24. register_concmd("amx_memo_whosip", "amx_memo_whosip", ADMIN_IMMUNITY, "<ip> - looks up the owner of the given ip")
  25. register_concmd("amx_memo_add", "amx_memo_add", ADMIN_IMMUNITY, "<name> <listname> - adds a new entry to the registry")
  26. register_concmd("amx_memo_list", "amx_memo_list", ADMIN_IMMUNITY, " - performs who on all players")
  27. register_concmd("amx_memo_ban", "amx_memo_ban", ADMIN_IMMUNITY, "<listname> - bans the user's ip")
  28. register_concmd("amx_memo_unban", "amx_memo_unban", ADMIN_IMMUNITY, "<listname> - unbans the user's ip")
  29.  
  30. return PLUGIN_CONTINUE
  31. }
  32.  
  33.  
  34. public amx_memo_who(id, level, cid)
  35. {
  36. // check access
  37. if (!cmd_access(id, level, cid, 2))
  38. return PLUGIN_HANDLED
  39.  
  40. // get parameter
  41. new param[32]
  42. read_argv(1, param, 31)
  43.  
  44. // find user
  45. new player = cmd_target(id, param, 2|8)
  46. if (!player)
  47. {
  48. console_print(id, "Player not found")
  49. return PLUGIN_HANDLED
  50. }
  51.  
  52. // get ip and full name
  53. new name[32]
  54. new ip[32]
  55. get_user_name(player, name, 31)
  56. get_user_ip(player, ip, 31, 1)
  57.  
  58. // scan the file
  59. new entry[64]
  60. new entryip[32]
  61. new entryname[32]
  62. new line = 0
  63. new chcount
  64. do {
  65. read_file("memo.txt", line, entry, 63, chcount)
  66. strtok(entry, entryip, 31, entryname, 31, ':')
  67.  
  68. if (equal(ip, entryip))
  69. {
  70. // write scan result
  71. console_print(id, "%s van voltakeppen %s [%s]", name, entryname, entryip)
  72. return PLUGIN_HANDLED
  73. }
  74.  
  75. line++
  76. } while (!equal(entry, "*"))
  77.  
  78. // no entry found
  79. console_print(id, "%s nem vagy a listan", name)
  80.  
  81. return PLUGIN_HANDLED
  82. }
  83.  
  84.  
  85. public amx_memo_listall(id, level, cid)
  86. {
  87. new line = 0
  88. new entry[64]
  89. new entryname[32]
  90. new entryip[32]
  91. new chcount
  92. // get all records
  93. do {
  94. read_file("memo.txt", line, entry, 63, chcount)
  95.  
  96. if (!equal(entry, "*"))
  97. {
  98. // tokenize
  99. strtok(entry, entryip, 31, entryname, 31, ':')
  100. // print entry
  101. console_print(id, "%s >>>> %s", entryip, entryname)
  102. }
  103.  
  104. line++
  105. } while (!equal(entry, "*"))
  106.  
  107. return PLUGIN_HANDLED
  108. }
  109.  
  110.  
  111. public amx_memo_rename(id, level, cid)
  112. {
  113. // check access
  114. if (!cmd_access(id, level, cid, 3))
  115. return PLUGIN_HANDLED
  116.  
  117. // get parameters
  118. new oldname[32]
  119. new newname[32]
  120. read_argv(1, oldname, 31)
  121. read_argv(2, newname, 31)
  122.  
  123. new line = 0
  124. new entry[64]
  125. new entryip[32]
  126. new entryname[32]
  127. new chcount
  128. // scan the file for the entry
  129. do {
  130. read_file("memo.txt", line, entry, 63, chcount)
  131. strtok(entry, entryip, 31, entryname, 31, ':')
  132.  
  133. // are we there yet?
  134. if (equal(entryname, oldname))
  135. {
  136. // create new entry
  137. entry = ""
  138. strcat(entry, entryip, 63)
  139. strcat(entry, ":", 63)
  140. strcat(entry, newname, 63)
  141. write_file("memo.txt", entry, line)
  142.  
  143. // write new entry
  144. console_print(id, "%s [%s] atkereszteltek %s [%s]", oldname, entryip, newname, entryip)
  145.  
  146. return PLUGIN_HANDLED
  147. }
  148.  
  149. line++
  150. } while (!equal(entry, "*"))
  151.  
  152. // entry not found
  153. console_print(id, "%s nem vagy a listan", oldname)
  154.  
  155. return PLUGIN_HANDLED
  156. }
  157.  
  158.  
  159. public amx_memo_whosip(id, level, cid)
  160. {
  161. // check access
  162. if (!cmd_access(id, level, cid, 2))
  163. return PLUGIN_HANDLED
  164.  
  165. // get parameters
  166. new ip[32]
  167. read_argv(1, ip, 31)
  168.  
  169. new entry[64]
  170. new entryip[32]
  171. new entryname[32]
  172. new line = 0
  173. new chcount
  174. do {
  175. read_file("memo.txt", line, entry, 63, chcount)
  176. strtok(entry, entryip, 31, entryname, 31, ':')
  177.  
  178. if (equal(ip, entryip))
  179. {
  180. console_print(id, "A cim %s tartozik %s", entryip, entryname)
  181. break
  182. }
  183.  
  184. line++
  185. } while (!equal(entry, "*"))
  186.  
  187. if (equal(entry, "*"))
  188. {
  189. console_print(id, "Cim %s nincs a listan", ip)
  190. }
  191.  
  192. return PLUGIN_HANDLED
  193. }
  194.  
  195.  
  196.  
  197. public amx_memo_add(id, level, cid)
  198. {
  199. // check access
  200. if (!cmd_access(id, level, cid, 3))
  201. return PLUGIN_HANDLED
  202.  
  203. // get parameters
  204. new name[32]
  205. new regname[32]
  206. read_argv(1, name, 31)
  207. read_argv(2, regname, 31)
  208.  
  209. // find user
  210. new player = cmd_target(id, name, 2|8)
  211. if (!player)
  212. {
  213. console_print(id, "Jatekos nem talalhato")
  214. return PLUGIN_HANDLED
  215. }
  216.  
  217. // get the full name
  218. new fullname[32]
  219. new ip[32]
  220. get_user_name(player, fullname, 31)
  221. get_user_ip(player, ip, 31, 1)
  222.  
  223. // add the user to the registry
  224. new entry[64]
  225. new entryip[32]
  226. new entryname[32]
  227. new line = 0
  228. new chcount
  229. do {
  230. read_file("memo.txt", line, entry, 63, chcount)
  231. strtok(entry, entryip, 31, entryname, 31, ':')
  232. if (equal(entryip, ip))
  233. {
  234. console_print(id, "Nev %s mar a listan van %s [%s]", fullname, entryname, entryip)
  235. return PLUGIN_HANDLED
  236. }
  237. line++
  238. } while (!equal(entry,"*"))
  239.  
  240. entry = ""
  241. strcat(entry, ip, 63)
  242. strcat(entry, ":", 63)
  243. strcat(entry, regname, 63)
  244. write_file("memo.txt", entry, line-1)
  245. write_file("memo.txt", "*", line)
  246. console_print(id, "%s bovitette az ismert felhasznalokat dol %s [%s]", fullname, regname, ip)
  247.  
  248. return PLUGIN_HANDLED
  249. }
  250.  
  251.  
  252. public amx_memo_list(id, level, cid)
  253. {
  254. // check access
  255. if (!cmd_access(id, level, cid, 1))
  256. return PLUGIN_HANDLED
  257.  
  258. // get the player ids
  259. new players[32]
  260. new nrplayers
  261. new player
  262. get_players(players, nrplayers, "c")
  263.  
  264. // run through all ids
  265. new i
  266. for (i = 0; i < nrplayers; i++)
  267. {
  268. player = players[i]
  269.  
  270. // get ip and full name
  271. new name[32]
  272. new ip[32]
  273. get_user_name(player, name, 31)
  274. get_user_ip(player, ip, 31, 1)
  275.  
  276. // scan the file
  277. new entry[64]
  278. new entryip[32]
  279. new entryname[32]
  280. new line = 0
  281. new chcount
  282. do {
  283. read_file("memo.txt", line, entry, 63, chcount)
  284. strtok(entry, entryip, 31, entryname, 31, ':')
  285.  
  286. if (equal(ip, entryip))
  287. {
  288. // write scan result
  289. console_print(id, "%s >>>> %s [%s]", name, entryname, entryip)
  290. break
  291. }
  292.  
  293. line++
  294. } while (!equal(entry, "*"))
  295.  
  296. if (equal(entry, "*"))
  297. {
  298. // no entry found
  299. console_print(id, "%s >>>> ..... [%s]", name, ip)
  300. }
  301. }
  302.  
  303. return PLUGIN_HANDLED
  304. }
  305.  
  306.  
  307. public amx_memo_ban(id, level, cid)
  308. {
  309. // check access
  310. if (!cmd_access(id, level, cid, 2))
  311. return PLUGIN_HANDLED
  312.  
  313. // get parameter
  314. new name[32]
  315. read_argv(1, name, 31)
  316.  
  317. // check if minutes were specified
  318. new minutes[16] = "0"
  319. if (read_argc() > 2)
  320. read_argv(2, minutes, 15)
  321.  
  322. // find the ip from the registry
  323. new entry[64]
  324. new entryip[32]
  325. new entryname[32]
  326. new line = 0
  327. new chcount
  328. do {
  329. read_file("memo.txt", line, entry, 63, chcount)
  330. strtok(entry, entryip, 31, entryname, 31, ':')
  331.  
  332. if (equal(name, entryname))
  333. {
  334. server_cmd("addip ^"%s^" ^"%s^";wait;writeip", minutes, entryip)
  335. if (equal (minutes, "0"))
  336. console_print(id, "%s [%s] banolvan orokre", name, entryip)
  337. else
  338. console_print(id, "%s [%s] banolvna %s percre", name, entryip, minutes)
  339. return PLUGIN_HANDLED
  340. }
  341. line++
  342. } while (!equal(entry, "*"))
  343.  
  344. console_print(id, "%s nincs a listan", name);
  345.  
  346. return PLUGIN_HANDLED
  347. }
  348.  
  349.  
  350. public amx_memo_unban(id, level, cid)
  351. {
  352. // check access
  353. if (!cmd_access(id, level, cid, 2))
  354. return PLUGIN_HANDLED
  355.  
  356. // get parameter
  357. new name[32]
  358. read_argv(1, name, 31)
  359.  
  360. // find the ip from the registry
  361. new entry[64]
  362. new entryip[32]
  363. new entryname[32]
  364. new line = 0
  365. new chcount
  366. do {
  367. read_file("memo.txt", line, entry, 63, chcount)
  368. strtok(entry, entryip, 31, entryname, 31, ':')
  369.  
  370. if (equal(name, entryname))
  371. {
  372. server_cmd("iptorlese ^"%s^";writeip", entryip)
  373. console_print(id, "%s [%s] Tiltasfeloldasa", name, entryip)
  374. return PLUGIN_HANDLED
  375. }
  376. line++
  377. } while (!equal(entry, "*"))
  378.  
  379. console_print(id, "%s nincs a listan", name);
  380.  
  381. return PLUGIN_HANDLED
  382. }
  383.  
  384.