HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* Admin Gag Command
  2. About:
  3. This plugin allows you to gag players from using say_team,say or voicecomm. It also echos admin acctions
  4. based on amx_show_activity. The plugin can also block gagged clients from changing their nick.
  5. Admins with immunity will not be executed on, unless their executing on themself
  6.  
  7. Usage:
  8. amx_gag <nick/userid> <flags (a/b/c)> <time in seconds> // lets you control what you want to gag
  9. amx_gag <nick/userid> <time in seconds> // Will automaticly add the abc flag.
  10. amx_gag <nick/userid> // Will add abc flags, and 600 secounds gag.
  11. amx_gag <nick/userid> <flags>
  12. amx_ungag <nick/userid> // Will remove all "gags"
  13.  
  14. Modules required:
  15. Engine
  16.  
  17. FAQ)
  18. Q) Can i mute voicecomm?
  19. A) Yes, that should be on by defualt. But you can make sure "#define VoiceCommMute 1"
  20.  
  21. Q) Is there any way i can disable the engine module and still run the plugin?
  22. A) yes, "#define VoiceCommMute 0".
  23.  
  24. Plugin forum thread: http://www.amxmodx.org/forums/viewtopic.php?t=463
  25.  
  26.  
  27. Credits:
  28. Ops in #AMXmod @ Quakenet for alot of help ( + AssKicker & CheesyPeteza )
  29. This plugin is heavly based on the work of tcquest78 in his gag plugin http://djeyl.net/forum/index.php?showtopic=4962
  30. Code for Namechange block code was taken from Olo`s one_name plugin.
  31.  
  32. Changelog:
  33. 1.8.3 ( 23.02.2005 )
  34. - Fixed: Voicecomm not being muted via callfunc interface ( Like Admin Aimmenu )
  35.  
  36. 1.8.2 ( 22.09.2004 )
  37. - Fixed: Default gag reason not being shown.
  38.  
  39. 1.8.1 ( 21.09.2004 )
  40. - Fixed: Players voicecomm not being reset properbly with sv_alltalk 1
  41.  
  42. 1.8.0 ( 10.09.2004 )
  43. - Added: func_AddGag() to allow third party plugins to gag a client( Like my admin Aimmenu)
  44. - Added: func_RemoveGag() to remove a gag via a third party plugin
  45.  
  46.   1.7.5 ( 06.07.2004 )
  47. - Changed: #define MaxPlayers to be 32 instead of 33 (Should save a few byte of mem )
  48.  
  49.   1.7.4 ( 06.07.2004 )
  50. - Changed: Once amx_gag/amx_ungag is used admins will no longer see "command not found" in console anymore ( Thx to Downtown1)
  51. - Added: #define for MaxPlayers
  52.  
  53.   1.7.3 ( 06.07.2004 )
  54. - Fixed: Fixed possible issue with steamids being to long (Would just be text cut on in logs/text)
  55.  
  56.   1.7.2 ( 03.07.2004 )
  57. - Fixed: Spelling Errors ( Thx to Mr. Satan )
  58.  
  59.   1.7.1 ( 20.06.2004 )
  60. - Added: Plugin now logs the gag reason
  61.  
  62.   1.7.0 ( 20.06.2004 )
  63. - Changed: Plugin has gotten a rewrite/cleanup
  64. - Changed: Plugin is now properbly format
  65. - Added: Ability to play a to gagged clients when their trying to talk ( Idea by Girthesniper )
  66. - Added: Ability to show the reason for the gag.
  67. - Fixed: Error where the command line would not read out more then 3 bytes of eatch var.
  68.  
  69.   1.6.2 ( 28.05.2004 )
  70. - Hack: UnGagPlayer echoing that unconnected clients had been ungagged when time ran out
  71.  
  72.   1.6.1 ( 25.05.2004 )
  73. - Changed: task is now registered with the same id as player index
  74. - Added: a define to change the default gag time
  75.  
  76.   1.6.0
  77. - Changed: Name change blocking enabled by default.
  78. - Added: Plugin now logs amx_ungag actions
  79. - Added: amx_ungag now echos target nick even if #userid was used
  80. - Added: amx_gag <nick/userid> <seconds or minuts> ( amx_gag EKS 120 / amx_gag EKS 2m )
  81.  
  82.   1.5.0
  83. - Added: Ability to block namechange on clients that are gagged ( Disabled by default, just change #define BlockNameChange )
  84.  
  85.   1.4.3
  86. - No update to the plugin, just added comments to help new admins.
  87.  
  88.   1.4.2
  89. - Fixed oversight that would allow none admins to use the plugin
  90.  
  91.   1.4.1 ( 01.03.2004 )
  92. - Now user log_amx style loggin
  93. - Now use AMXX engine to mute/unmute voicecomm
  94.  
  95.   1.4.0 ( 01.03.2004 )
  96. - Now only umutes voicecomm if player was muted by this plugin
  97. - Now echos what what the admin has muted.
  98. - To mute voicecomm you either need D2Tools or vexd. You can change what module to use in the define section.( look for: VoiceCommMute )
  99. - You can set #define VoiceCommMute to 0, and you dont need any extra modules anymore. But loose the ability to mute voicecomm.
  100.  
  101.   1.3.1 ( 17.02.2004 )
  102. - Fixed muting voicecomm not working ( Info needed extracted from this plugin: http://djeyl.net/forum/index.php?showtopic=16533 | Proerrenrg )
  103.  
  104.   1.3.0 ( 17.02.2004 )
  105. - Now print nick and authid when a player disconnects
  106. - Now only one place in the code that can ungag a player ( ungag )
  107. - Added admin log
  108. - Fixed not gag flags not working
  109. - Changed plugin file name to: admin_gag.XXX
  110. - Minor code cleanup. More comments, Code cleaner & UnGagPlayer should be "faster"
  111.  
  112.   1.2.1 ( 06.02.2004 )
  113. - Fixed support for #userid again
  114. - Now use console_print to echo when player is not gagged ( in amx_ungag )
  115.  
  116.   1.2
  117. - Now supports muting voicecomm ( the flag c )
  118.   - REQUIRES Vexd module, use 1.1 if you dont want to run this module
  119.  
  120.   1.1
  121. - Now supports amx_gag <nick> <time> ( Adds ab as flag if no other flag is entered.)
  122. - Now supports amx_gag <nick/auth>
  123. - Fixed echoing with amx_show_activity 1 not showing the secounds
  124.  
  125.   1.0 (Changes are from the orginal plugin to this one)
  126. - Now echos admin acctions based on amx_show_activity
  127. - Now echos when a player is ungagged by admin
  128. - Now echos when a player is ungagged becuse the "time" has run out.
  129. - Now echos when a gagged player disconnects
  130. - Admins with immunity flag can do actions on themself.
  131. - If you try to ungag a player thats not gagged, you get a "error" message
  132. - Changed the "your gagged" message so its simpler to spot in Steam.
  133. - Somehow the compiled file is smaller then with the orignal
  134. */
  135. #define VoiceCommMute 1 // 0 = Disabled ( no extra module required ) | 1 = Voicecomm muteing enabled. ( requires engine module)
  136. #define BlockNameChange 1 // 0 = Disabled | 1 = Block namechange on gagged clients
  137. #define LogAdminActions 1 // 0 = Disabled | 1 = Admin actions will be logged
  138. #define DefaultGagTime 600.0 // The std gag time if no other time was entered. ( this is 10 min ), Remember the value MUST contain a .0
  139. #define PlaySound 0 // 0 = Disabled | 1 = Play a sound to gagged clients when their trying to talk
  140. #define GagReason 1 // 0 = Disabled | 1 = Gagged clients can see why there where gagged when they try to talk
  141. #define MaxPlayers 32
  142. #define AllowOtherPlugin2Interface 1
  143.  
  144. #include <amxmodx>
  145. #include <amxmisc>
  146. #include <engine>
  147.  
  148. new g_GagPlayers[MaxPlayers+1] // Used to check if a player is gagged
  149. #if GagReason == 1
  150. new gs_GagReason[MaxPlayers+1][48]
  151. #endif
  152.  
  153. public plugin_init()
  154. {
  155. register_plugin("Admin Gag","1.8.3","EKS")
  156. register_clcmd("say","block_gagged")
  157. register_clcmd("say_team","block_gagged")
  158. register_concmd("amx_gag","CMD_GagPlayer",ADMIN_KICK,"<nick or #userid> <a|b|c> <time>")
  159. register_concmd("amx_ungag","CMD_UnGagPlayer",ADMIN_KICK,"<nick or #userid>")
  160. }
  161.  
  162. public block_gagged(id){ // This function is what check the say / team_say messages & block them if the client is blocked.
  163. if(!g_GagPlayers[id]) return PLUGIN_CONTINUE // Is true if the client is NOT blocked.
  164. new cmd[5]
  165. read_argv(0,cmd,4)
  166. if ( cmd[3] == '_' )
  167. {
  168. if (g_GagPlayers[id] & 2){
  169. #if GagReason == 1
  170. client_print(id,print_chat,"* Le lettel nemitva: %s",gs_GagReason[id])
  171. #else
  172. client_print(id,print_chat,"* le lettel nemitva.")
  173. #endif
  174.  
  175. #if PlaySound == 1
  176. client_cmd(id,"spk barney/youtalkmuch")
  177. #endif
  178. return PLUGIN_HANDLED
  179. }
  180. }
  181. else if (g_GagPlayers[id] & 1) {
  182. #if GagReason == 1
  183. client_print(id,print_chat,"* Le lettel nemitva: %s",gs_GagReason[id])
  184. #else
  185. client_print(id,print_chat,"* Le lettel nemitva.")
  186. #endif
  187. #if PlaySound == 1
  188. client_cmd(id,"spk barney/youtalkmuch")
  189. #endif
  190. return PLUGIN_HANDLED
  191. }
  192. return PLUGIN_CONTINUE
  193. }
  194. public CMD_GagPlayer(id,level,cid)
  195. {
  196. if(!cmd_access (id,level,cid,1)) return PLUGIN_HANDLED
  197. new arg[32],VictimID
  198.  
  199. read_argv(1,arg,31) // Arg contains Targets nick or Userid
  200. VictimID = cmd_target(id,arg,8) // This code here tryes to find out the player index. Either from a nick or #userid
  201. if ((get_user_flags(VictimID) & ADMIN_IMMUNITY) && VictimID != id || !cmd_access (id,level,cid,2) ) { return PLUGIN_HANDLED; } // This code is kind of "long", its job is to. Stop actions against admins with immunity, Stop actions action if the user lacks access, or is a bot/hltv
  202. new s_Flags[4],VictimName[32],AdminName[32],flags,ShowFlags[32],CountFlags,s_GagTime[8],Float:f_GagTime
  203.  
  204. read_argv(2,arg,31)
  205. if (!arg[0]) // This means amx_gag <nick / userid> and no other flag or time was used.
  206. {
  207. f_GagTime = DefaultGagTime
  208. format(s_Flags,7,"abc")
  209. }
  210. else
  211. {
  212. if(contain(arg,"m")!=-1 && contain(arg,"!")==-1) // This means the time was entered in minuts and not seconds
  213. {
  214. copyc(s_GagTime,7,arg, 'm')
  215. f_GagTime = floatstr(s_GagTime) * 60
  216. }
  217. else if(isdigit(arg[0])&& contain(arg,"!")==-1) // The value was entered in seconds
  218. {
  219. format(s_GagTime,7,arg)
  220. f_GagTime = floatstr(s_GagTime)
  221. }
  222. read_argv(3,arg,8)
  223. if (!arg[0]) // No flag has been entered
  224. format(s_Flags,7,"abc")
  225. else if(contain(arg,"!")==-1) // This means that arg did NOT contain the ! symbot
  226. format(s_Flags,7,arg)
  227. else if(contain(arg,"!")!=-1) // This means that arg did DOES contain the ! symbot
  228. format(s_Flags,7,"abc")
  229. if (f_GagTime == 0.0)
  230. {
  231. read_argv(2,arg,8)
  232. if(contain(arg,"!")!=-1)
  233. format(s_Flags,3,"abc") // Flag was entered.
  234. else
  235. format(s_Flags,3,arg) // Flag was entered.
  236. f_GagTime = DefaultGagTime
  237. }
  238. #if GagReason == 1
  239. new GagReasonFound=0
  240. for(new i=2;i<=4;i++)
  241. {
  242. read_argv(i,arg,31)
  243. if(contain(arg,"!")!=-1)
  244. {
  245. read_args(arg,31)
  246. new tmp[32]
  247. copyc(tmp,32,arg,33)
  248. copy(gs_GagReason[VictimID],47,arg[strlen(tmp)+1])
  249. GagReasonFound = 1
  250. }
  251. }
  252. if(GagReasonFound == 0) // If no reason was entered, add the std reason.
  253. format(gs_GagReason[VictimID],47,"ADMIN Altal.")
  254. #endif
  255. }
  256.  
  257. flags = read_flags(s_Flags) // Converts the string flags ( a,b or c ) into a int
  258. g_GagPlayers[VictimID] = flags
  259. #if VoiceCommMute == 1
  260. if(flags & 4) // This code checks if the c flag was used ( reprisented by the number 4 ), If pressent it mutes his voicecomm.
  261. set_speak(VictimID, SPEAK_MUTED)
  262. #endif
  263. new TaskParm[1] // For some reason set_task requires a array. So i make a array :)
  264. TaskParm[0] = VictimID
  265. set_task( f_GagTime,"task_UnGagPlayer",VictimID,TaskParm,1)
  266.  
  267. CountFlags = 0
  268. if (flags & 1)
  269. {
  270. format(ShowFlags,31,"say")
  271. CountFlags++
  272. }
  273. if (flags & 2)
  274. {
  275. if(CountFlags)
  276. format(ShowFlags,31,"%s / say_team",ShowFlags)
  277. if(!CountFlags)
  278. format(ShowFlags,31,"say_team")
  279. }
  280. #if VoiceCommMute != 0
  281. if(flags & 4)
  282. {
  283. if(CountFlags)
  284. format(ShowFlags,31,"%s / voicecomm",ShowFlags)
  285. if(!CountFlags)
  286. format(ShowFlags,31,"voicecomm")
  287. }
  288. #endif
  289. get_user_name(id,AdminName,31)
  290. get_user_name(VictimID,VictimName,31)
  291. switch(get_cvar_num("amx_show_activity"))
  292. {
  293. #if GagReason == 1
  294. case 2: client_print(0,print_chat,"ADMIN %s: %s Lenemitva %0.0f Percre, erre: %s ( %s )",AdminName,VictimName,(f_GagTime / 60),gs_GagReason[VictimID],ShowFlags) // debug added
  295. case 1: client_print(0,print_chat,"ADMIN: %s Lenemitva %0.0f Percre, erre: %s ( %s )",VictimName,(f_GagTime / 60),gs_GagReason[VictimID],ShowFlags)
  296. #else
  297. case 2: client_print(0,print_chat,"ADMIN %s: %s Lenemitva %0.0f Percre ( %s )",AdminName,VictimName,(f_GagTime / 60),ShowFlags) // debug added
  298. case 1: client_print(0,print_chat,"ADMIN: %s Lenemitva %0.0f Percre ( %s )",VictimName,(f_GagTime / 60),ShowFlags)
  299. #endif
  300.  
  301. }
  302. #if LogAdminActions == 1
  303. new parm[5] /*0 = Victim id | 1 = Admin id | 2 = Used to control if its a gag or Ungag | 3 = The gag flags | 4 = Length of the gag */
  304. parm[0] = VictimID
  305. parm[1] = id
  306. parm[2] = 0
  307. parm[3] = flags
  308. parm[4] = floatround(Float:f_GagTime)
  309. LogAdminAction(parm)
  310. #endif
  311. return PLUGIN_HANDLED
  312. }
  313.  
  314. public CMD_UnGagPlayer(id,level,cid) /// Removed gagged player ( done via console command )
  315. {
  316. new arg[32],VictimID
  317. read_argv(1,arg,31) // Arg contains Targets nick
  318.  
  319. VictimID = cmd_target(id,arg,8) // This code here tryes to find out the player index. Either from a nick or #userid
  320. if ((get_user_flags(VictimID) & ADMIN_IMMUNITY) && VictimID != id || !cmd_access (id,level,cid,2) ) { return PLUGIN_HANDLED; } // This code is kind of "long", its job is to. Stop actions against admins with immunity, Stop actions action if the user lacks access, or is a bot/hltv
  321.  
  322. new AdminName[32],VictimName[32]
  323.  
  324. get_user_name(id,AdminName,31) // Gets Admin name
  325. get_user_name(VictimID,VictimName,31)
  326.  
  327. if(!g_GagPlayers[VictimID]) // Checks if player has gagged flag
  328. {
  329. console_print(id,"%s Is Not Gagged & Cannot Be Ungagged.",arg)
  330. return PLUGIN_HANDLED
  331. }
  332. switch(get_cvar_num("amx_show_activity"))
  333. {
  334. case 2: client_print(0,print_chat,"ADMIN %s: Chat engedelyezve %s-nek.",AdminName,VictimName)
  335. case 1: client_print(0,print_chat,"ADMIN: Chat engedelyezve %s-nek.",VictimName)
  336. }
  337.  
  338. #if LogAdminActions == 1
  339. new parm[3] /*0 = Victim id | 1 = Admin id | 2 = Used to control if its a gag or Ungag | 3 = The gag flags | 4 = Length of the gag */
  340. parm[0] = VictimID
  341. parm[1] = id
  342. parm[2] = 1
  343. LogAdminAction(parm)
  344. #endif
  345. remove_task(VictimID) // Removes the set_task set to ungag the player
  346. UnGagPlayer(VictimID) // This is the function that does the actual removal of the gag info
  347. return PLUGIN_HANDLED
  348. }
  349.  
  350. public client_disconnect(id)
  351. {
  352. if(g_GagPlayers[id]) // Checks if disconnected player is gagged, and removes flags from his id.
  353. {
  354. new Nick[32],Authid[35]
  355. get_user_name(id,Nick,31)
  356. get_user_authid(id,Authid,34)
  357. client_print(0,print_chat,"[AMX] Gagged Player Has Disconnected ( %s <%s> )",Nick,Authid)
  358. remove_task(id) // Removes the set_task set to ungag the player
  359. UnGagPlayer(id) // This is the function that does the actual removal of the gag info
  360. }
  361. }
  362. #if BlockNameChange == 1
  363. public client_infochanged(id)
  364. {
  365. if(g_GagPlayers[id])
  366. {
  367. new newname[32], oldname[32]
  368. get_user_info(id, "name", newname,31)
  369. get_user_name(id,oldname,31)
  370.  
  371. if (!equal(oldname,newname))
  372. {
  373. client_print(id,print_chat,"* Letiltott jatekosok nem valthatnak nevet.")
  374. set_user_info(id,"name",oldname)
  375. }
  376. }
  377. }
  378. #endif
  379. public task_UnGagPlayer(TaskParm[]) // This function is called when the task expires
  380. {
  381. new VictimName[32]
  382. get_user_name(TaskParm[0],VictimName,31)
  383. client_print(0,print_chat,"ADMIN: %s Is No Longer Gagged",VictimName)
  384. UnGagPlayer(TaskParm[0])
  385. }
  386. #if LogAdminActions == 1
  387. stock LogAdminAction(parm[]) // This code is what logs the admin actions.
  388. {
  389. new VictimName[32],AdminName[32],AdminAuth[35],VictimAuth[35]
  390. get_user_name(parm[1],AdminName,31)
  391. get_user_name(parm[0],VictimName,31)
  392. get_user_authid(parm[1],AdminAuth,34)
  393. get_user_authid(parm[0],VictimAuth,34)
  394.  
  395. #if GagReason == 1
  396. if(parm[2] == 0)
  397. log_amx("Gag: ^"%s<%s>^" Has Gagged %s <%s> for %d ( %d ) Reason: %s",AdminName,AdminAuth,VictimName,VictimAuth,parm[4],parm[3],gs_GagReason[parm[0]])
  398. #else
  399. if(parm[2] == 0)
  400. log_amx("Gag: ^"%s<%s>^" Has Gagged %s <%s> for %d ( %d )",AdminName,AdminAuth,VictimName,VictimAuth,parm[4],parm[3])
  401. #endif
  402. if(parm[2] == 1)
  403. log_amx("UnGag: ^"%s<%s>^" Has Ungagged %s<%s>",AdminName,AdminAuth,VictimName,VictimAuth)
  404. }
  405. #endif
  406. stock UnGagPlayer(id) // This code is what removes the gag.
  407. {
  408. #if VoiceCommMute == 1
  409. if(g_GagPlayers[id] & 4) // Unmutes the player if he had voicecomm muted.
  410. {
  411. if(get_cvar_num("sv_alltalk") == 1)
  412. set_speak(id, SPEAK_ALL)
  413. else
  414. set_speak(id, SPEAK_NORMAL)
  415. }
  416. #endif
  417. g_GagPlayers[id] = 0
  418. #if GagReason == 1
  419. setc(gs_GagReason[id],31,0)
  420. #endif
  421. }
  422. #if AllowOtherPlugin2Interface == 1
  423. public func_AddGag(id)
  424. {
  425. g_GagPlayers[id] = 7
  426. new TaskParm[1] // For some reason set_task requires a array. So i make a array :)
  427. TaskParm[0] = id
  428. #if VoiceCommMute == 1
  429. set_speak(id, SPEAK_MUTED)
  430. #endif
  431. set_task( DefaultGagTime,"task_UnGagPlayer",id,TaskParm,1)
  432. }
  433.  
  434. public func_RemoveGag(id)
  435. {
  436. remove_task(id) // Removes the set_task set to ungag the player
  437. UnGagPlayer(id)
  438. }
  439. #endif