Advertisement
SoolKing_RS6

Untitled

Nov 19th, 2021
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1.  
  2. /*
  3. * AMXMOD script.
  4. * (plugin_slash.sma)
  5. * by mike_cao <mike@mikecao.com>
  6. * This file is provided as is (no warranties).
  7. *
  8. * This plugin allows admins to execute amx commands
  9. * using 'say' and a slash '/'. It can also execute
  10. * a command on all players or a team using '@all' and
  11. * '@team' in place of the authid/nick parameter.
  12. *
  13. * Examples:
  14. * To kick a player type '/kick playername'
  15. * To kick all players type '/kick @all'
  16. * To kick all players on a team type '/kick @team:TEAMID'
  17. * To ban all players for 10 minutes, type '/ban 10 @all'
  18. *
  19. * Additional Commands:
  20. * Includes an IRC style '/me' command. If you say
  21. * '/me sucks', it'll replace the '/me' with your name
  22. * and print it to everyone.
  23. *
  24. * Includes a '/getteam' command in case you need to find
  25. * the teamid for a player.
  26. *
  27. * Important: place this plugin at the bottom of your plugins.ini file so it doesn't interfere with other plugin that may use the '/'.
  28. *
  29. */
  30.  
  31. #include <amxmodx>
  32.  
  33. #define MAX_NAME_LENGTH 32
  34. #define MAX_TEXT_LENGTH 192
  35. #define MAX_PLAYERS 32
  36.  
  37. public admin_slash(id)
  38. {
  39. new sName[MAX_NAME_LENGTH+1]
  40. new sArg[MAX_NAME_LENGTH+1]
  41. read_argv(1,sArg,MAX_NAME_LENGTH)
  42.  
  43. // Check for '/' char
  44. if ( sArg[0] == '/' ) {
  45. new sCommand[MAX_TEXT_LENGTH+1]
  46. new sMessage[MAX_TEXT_LENGTH+1]
  47. new sTemp[MAX_TEXT_LENGTH+1]
  48.  
  49. // Get data
  50. read_args(sMessage,MAX_TEXT_LENGTH)
  51. remove_quotes(sMessage)
  52. replace(sMessage,MAX_TEXT_LENGTH,"/","")
  53.  
  54. // For all players
  55. if ( containi(sMessage,"@all") != -1 ) {
  56. new iPlayers[MAX_PLAYERS], iNumPlayers
  57. get_players(iPlayers,iNumPlayers)
  58.  
  59. for (new i = 0; i < iNumPlayers; i++) {
  60. get_user_name(iPlayers[i],sName,MAX_NAME_LENGTH)
  61. copy(sTemp,MAX_TEXT_LENGTH,sMessage)
  62. replace(sTemp,MAX_TEXT_LENGTH,"@all","^"@name^"")
  63. replace(sTemp,MAX_TEXT_LENGTH,"@name",sName)
  64. format(sCommand,MAX_TEXT_LENGTH,"amx_%s",sTemp)
  65. client_cmd(id,sCommand)
  66. }
  67. copyc(sCommand,MAX_NAME_LENGTH,sTemp,' ')
  68. client_print(id,print_chat,"[AMX] Command ^"%s^" executed on all players",sCommand)
  69. }
  70. // For a team
  71. else if ( containi(sMessage,"@team:") != -1 ) {
  72. new sTeam[MAX_NAME_LENGTH+1]
  73. new sRemove[MAX_TEXT_LENGTH+1]
  74.  
  75. // Get team
  76. copy(sTemp,MAX_TEXT_LENGTH,sMessage)
  77. copyc(sRemove,MAX_TEXT_LENGTH,sTemp,'@')
  78. replace(sTemp,MAX_TEXT_LENGTH,sRemove,"")
  79. copyc(sTeam,MAX_TEXT_LENGTH,sTemp,' ')
  80.  
  81. if ( containi(sTeam,"@team:") != -1 ) {
  82. replace(sMessage,MAX_TEXT_LENGTH,sTeam,"^"@name^"")
  83. replace(sTeam,MAX_TEXT_LENGTH,"@team:","")
  84.  
  85. // Shortcuts for Counter-strike
  86. if ( equal(sTeam,"T") ) {
  87. copy(sTeam,MAX_NAME_LENGTH,"TERRORIST")
  88. }
  89. else if ( equal(sTeam,"S") ) {
  90. copy(sTeam,MAX_NAME_LENGTH,"SPECTATOR")
  91. }
  92. }
  93. else {
  94. client_print(id,print_chat,"[AMX] Team identifier not recognized")
  95. return PLUGIN_HANDLED
  96. }
  97.  
  98. new iPlayers[MAX_PLAYERS], iNumPlayers
  99. get_players(iPlayers,iNumPlayers,"e",sTeam)
  100.  
  101. if ( iNumPlayers ) {
  102. for (new i = 0; i < iNumPlayers; i++) {
  103. get_user_name(iPlayers[i],sName,MAX_NAME_LENGTH)
  104. copy(sTemp,MAX_TEXT_LENGTH,sMessage)
  105. replace(sTemp,MAX_TEXT_LENGTH,"@name",sName)
  106. format(sCommand,MAX_TEXT_LENGTH,"amx_%s",sTemp)
  107. client_cmd(id,sCommand)
  108. }
  109. copyc(sCommand,MAX_NAME_LENGTH,sTemp,' ')
  110. client_print(id,print_chat,"[AMX] Command ^"%s^" executed on team ^"%s^"",sCommand,sTeam)
  111. }
  112. else {
  113. client_print(id,print_chat,"[AMX] There are no players on team ^"%s^"",sTeam)
  114. }
  115. }
  116. else {
  117. format(sCommand,MAX_TEXT_LENGTH,"amx_%s",sMessage)
  118. client_cmd(id,sCommand)
  119. }
  120.  
  121. return PLUGIN_HANDLED
  122. }
  123. return PLUGIN_CONTINUE
  124. }
  125.  
  126. public admin_me(id)
  127. {
  128. new sName[MAX_NAME_LENGTH+1]
  129. new sMessage[MAX_TEXT_LENGTH+1]
  130.  
  131. // Get data
  132. get_user_name(id,sName,MAX_NAME_LENGTH)
  133. read_args(sMessage,MAX_TEXT_LENGTH)
  134. remove_quotes(sMessage)
  135.  
  136. // Display message only to same status players
  137. new bAlive = is_user_alive(id)
  138. for (new i = 1; i <= MAX_PLAYERS; i++) {
  139. if(is_user_alive(i) == bAlive) {
  140. client_print(i,print_chat,"%s %s",sName,sMessage)
  141. }
  142. }
  143. return PLUGIN_HANDLED
  144. }
  145. public plugin_init()
  146. {
  147. register_plugin("Admin Slash","1.1","mike_cao")
  148. register_clcmd("say","admin_slash",0,"say /command < params >")
  149. register_clcmd("amx_me","admin_me",0,"amx_me < text >")
  150. return PLUGIN_CONTINUE
  151. }
  152.  
  153.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement