HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* Admin Sprite show
  2. About:
  3. This plugin allows admins to place signs over the head of other players/admins, you can place 1 sign pr player. And you can spesify what .spr files to use in a included
  4. config file.
  5.  
  6. Install:
  7. Install the plugin like any other.
  8. Copy the sprites.ini to AMXX configs dir
  9. Copy the .spr files to <mod>/sprites
  10. Edit/Add new sprites by editing the sprites.ini file
  11.  
  12. Usage:
  13. amx_sprite <nev / #steamid> <jel nev> <ido>
  14. amx_sprite <nev / #steamid> <jel nev>
  15. amx_unsprite <nev / #steamid>
  16.  
  17. Credits:
  18. Ops in #AMXmod @ Quakenet for alot of help ( + AssKicker & CheesyPeteza )
  19. Based on idea from: KRoTaL, StuD|MaN
  20. */
  21.  
  22. #define Max_Sprites 8
  23. #define MAXPLAYERS 32
  24. #define DefaultSpriteTime 300.0
  25. #define SpriteReason 1
  26. #define AllowOtherPlugin2Interface 1
  27.  
  28.  
  29. #define SpriteShowTime 4000
  30. #define ReAddSpriteTime 4.0
  31.  
  32. #include <amxmodx>
  33. #include <amxmisc>
  34.  
  35.  
  36. new gs_SpriteFile[128]
  37. new gs_SpriteName[Max_Sprites+1][12] // contains the "name" of the sprite used in the command
  38. new gs_SpriteID[Max_Sprites+1] // Contains the precash index of the sprite
  39. new g_TotalSprites // Contains the number of sprites used ingame
  40. new g_PlayerStatus[MAXPLAYERS+1] // Contains the precashe index of the sprite for eatch player (0 if no sprite is assigned)
  41.  
  42. public plugin_init()
  43. {
  44. register_plugin("Admin Sprite Show", "1.2.2", "EKS")
  45. register_clcmd("amx_sprite", "CMD_AddSprite", ADMIN_KICK, "<name/id/wonid> <sprite> - shows sprite above player's head")
  46. register_clcmd("amx_unsprite", "CMD_RemoveSprite", ADMIN_KICK, "changes back to normal")
  47.  
  48. set_task(ReAddSpriteTime,"Task_ReAddSprites",MAXPLAYERS+1,_,_,"b")
  49. }
  50.  
  51. public CMD_AddSprite(id,level,cid)
  52. {
  53. if(!cmd_access (id,level,cid,2) || !g_TotalSprites) return PLUGIN_HANDLED
  54. new arg[32],VictimID
  55.  
  56. read_argv(1,arg,31) // Arg contains Targets nick or Userid
  57. VictimID = cmd_target(id,arg,2) // This code here tryes to find out the player index. Either from a nick or #userid
  58. 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
  59. new VictimName[32],AdminName[32],SpriteNR
  60. new Float:f_SpriteTime
  61. read_argv(2,arg,11) // Reads out the sprite name
  62. for(new i=0;i<=g_TotalSprites;i++) if(equali(arg,gs_SpriteName[i]))
  63. {
  64. Add_Sprite(VictimID,gs_SpriteID[i])
  65. if(!g_PlayerStatus[VictimID]) g_PlayerStatus[0]++ // This is increased so the server knows how many ppl have a sign over their head
  66. SpriteNR = i
  67. g_PlayerStatus[VictimID] = gs_SpriteID[i]
  68. break
  69. }
  70. if(!SpriteNR)
  71. {
  72. new Sprites[48]
  73. for(new i=0;i<=g_TotalSprites;i++) format(Sprites,47,"%s %s",Sprites,gs_SpriteName[i])
  74. console_print(id,"[AMXX] %s not a vaild sprite, the vaild once are:%s",arg,Sprites)
  75. return PLUGIN_HANDLED
  76. }
  77.  
  78. read_argv(3,arg,11) // Reads out how long the sprite should be shown.
  79. if(!arg[0])
  80. f_SpriteTime = DefaultSpriteTime
  81. else if(contain(arg,"m")!=-1) // This means the time was entered in minuts and not seconds
  82. {
  83. new Temp[8]
  84. copyc(Temp,7,arg, 'm')
  85. f_SpriteTime = floatstr(Temp) * 60
  86. }
  87. else if(isdigit(arg[0])) // The value was entered in seconds
  88. {
  89. f_SpriteTime = floatstr(arg)
  90. }
  91. else
  92. {
  93. f_SpriteTime = DefaultSpriteTime
  94. }
  95.  
  96. get_user_name(id,AdminName,31)
  97. get_user_name(VictimID,VictimName,31)
  98.  
  99. switch(get_cvar_num("amx_show_activity"))
  100. {
  101. case 2: client_print(0,3,"ADMIN %s adott egy %s jelt %s-nak/nek %0.0f percre!",AdminName,gs_SpriteName[SpriteNR],VictimName,(f_SpriteTime / 60))
  102. case 1: client_print(0,3,"%s feje fole kituztek egy %s jelt %0.0f perce",VictimName,gs_SpriteName[SpriteNR],(f_SpriteTime / 60))
  103. }
  104.  
  105. new parm[1]
  106. parm[0] = VictimID
  107. remove_task(VictimID) // Incase a task was there allready
  108. set_task(f_SpriteTime,"task_RemoveSprite",VictimID,parm,1,"a",1)
  109. return PLUGIN_HANDLED
  110. }
  111. public CMD_RemoveSprite(id,level,cid) /// Removed gagged player ( done via console command )
  112. {
  113. new arg[32],VictimID
  114. read_argv(1,arg,31) // Arg contains Targets nick
  115.  
  116. VictimID = cmd_target(id,arg,2) // This code here tryes to find out the player index. Either from a nick or #userid
  117. 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
  118.  
  119. new AdminName[32],VictimName[32]
  120.  
  121. get_user_name(id,AdminName,31) // Gets Admin name
  122. get_user_name(VictimID,VictimName,31)
  123.  
  124. if(!g_PlayerStatus[VictimID]) // Checks if player has gagged flag
  125. {
  126. console_print(id,"%s has no sign over his head",arg)
  127. return PLUGIN_HANDLED
  128. }
  129. switch(get_cvar_num("amx_show_activity"))
  130. {
  131. case 2: client_print(0,print_chat,"ADMIN %s Torolte %s fejerol a jelt!",AdminName,VictimName)
  132. case 1: client_print(0,print_chat,"%s fejerol lekerult a kituzott jel.",VictimName)
  133. }
  134. new parm[1]
  135. parm[0] = VictimID
  136. task_RemoveSprite(parm)
  137. return PLUGIN_HANDLED
  138.  
  139. }
  140. public client_disconnect(id)
  141. {
  142. if(g_PlayerStatus[id])
  143. {
  144. new Name[32],Authid[35]
  145. get_user_name(id,Name,31)
  146. get_user_authid(id,Authid,34)
  147. client_print(0,print_chat,"[Sprite]: %s <%s> lecsatlakozott mikozben a fejefolott volt egy jel!",Name,Authid)
  148. new parm[1]
  149. parm[0] = id
  150. task_RemoveSprite(parm)
  151. }
  152. }
  153.  
  154. public Task_ReAddSprites()
  155. {
  156. if(g_PlayerStatus[0] == 0)
  157. return PLUGIN_HANDLED
  158.  
  159. for(new i=1;i<=MAXPLAYERS;i++) if(is_user_connected(i) && is_user_alive(i) && g_PlayerStatus[i] != 0)
  160. {
  161. server_print("Add_Sprite adding sprite to: %d",i)
  162. Add_Sprite(i,g_PlayerStatus[i])
  163. }
  164. return PLUGIN_HANDLED
  165. }
  166.  
  167. public task_RemoveSprite(parm[])
  168. {
  169. remove_task(parm[0])
  170. g_PlayerStatus[parm[0]] = 0
  171. Remove_Sprite(parm[0])
  172. g_PlayerStatus[0]--
  173. }
  174.  
  175. stock Remove_Sprite(id) // This is the function used to remove a sprite from a player
  176. {
  177. message_begin(MSG_ALL,SVC_TEMPENTITY)
  178. write_byte(125)
  179. write_byte(id)
  180. message_end()
  181. }
  182.  
  183.  
  184.  
  185. stock Add_Sprite(id,SpriteID)
  186. {
  187. message_begin(MSG_ALL,SVC_TEMPENTITY)
  188. write_byte(124)
  189. write_byte(id)
  190. write_coord(65)
  191. write_short(SpriteID)
  192. write_short(SpriteShowTime)
  193. message_end()
  194. }
  195.  
  196.  
  197. public plugin_precache()
  198. {
  199. get_localinfo("amxx_configsdir",gs_SpriteFile,127)
  200. format(gs_SpriteFile,127,"%s/sprites.ini",gs_SpriteFile)
  201. if (!file_exists(gs_SpriteFile)) // If the file does not exist no point trying to read it.
  202. {
  203. server_print("Fatal error, no config file was found(%s)",gs_SpriteFile)
  204. return PLUGIN_HANDLED
  205. }
  206. new CurrentLine = 0
  207. new EndOfFile = 1
  208. new InfoFromFile[32]
  209. new SpriteFileName[Max_Sprites+1][32]
  210.  
  211. while(read_file(gs_SpriteFile,CurrentLine,InfoFromFile,31,EndOfFile) != 0 && CurrentLine <= Max_Sprites)
  212. {
  213. CurrentLine++
  214. parse(InfoFromFile, SpriteFileName[CurrentLine], 31, gs_SpriteName[CurrentLine], 11)
  215. if (!file_exists(SpriteFileName[CurrentLine])) // If the file does not exist no point trying to read it.
  216. {
  217. log_amx("[AMXX] Could not find the .spr file(%s). Stopping plugin",SpriteFileName[CurrentLine])
  218. return PLUGIN_HANDLED
  219. }
  220. gs_SpriteID[CurrentLine] = precache_model(SpriteFileName[CurrentLine])
  221. g_TotalSprites++
  222. }
  223. return PLUGIN_HANDLED
  224. }
  225. #if AllowOtherPlugin2Interface == 1
  226. public func_AddSprite(id,SpriteName[12])
  227. {
  228. //new SpriteNR
  229. for(new i=0;i<=g_TotalSprites;i++) if(equali(SpriteName,gs_SpriteName[i]))
  230. {
  231. Add_Sprite(id,gs_SpriteID[i])
  232. if(!g_PlayerStatus[id]) g_PlayerStatus[0]++ // This is increased so the server knows how many ppl have a sign over their head
  233. g_PlayerStatus[id] = gs_SpriteID[i]
  234. Add_Sprite(id,gs_SpriteID[i])
  235.  
  236. new parm[1]
  237. parm[0] = id
  238. remove_task(id) // Incase a task was there allready
  239. set_task(DefaultSpriteTime,"task_RemoveSprite",id,parm,1,"a",1)
  240. }
  241. if(!g_PlayerStatus[id]) g_PlayerStatus[0]++ // This is increased so the server knows how many ppl have a sign over their head
  242. }
  243. public func_RemoveSprite(id)
  244. {
  245. new parm[1]
  246. parm[0] = id
  247. task_RemoveSprite(parm)
  248. }
  249. #endif
  250.