Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.41 KB | None | 0 0
  1. /*
  2. * _______ _ _ __ __
  3. * | _____/ | | | | \ \ __ / /
  4. * | | | | | | | | / \ | |
  5. * | | | |____| | | |/ __ \| |
  6. * | | ___ | ______ | | / \ |
  7. * | | |_ | | | | | | / \ |
  8. * | | | | | | | | | | | |
  9. * | |____| | | | | | | | | |
  10. * |_______/ |_| |_| \_/ \_/
  11. *
  12. *
  13. *
  14. * Last Edited: 12-06-09
  15. *
  16. * ============
  17. * Changelog:
  18. * ============
  19. *
  20. * v1.1
  21. * -Bug Fixes
  22. *
  23. * v1.0
  24. * -Initial Release
  25. *
  26. */
  27.  
  28. #define VERSION "1.1"
  29.  
  30. #include <amxmodx>
  31. #include <amxmisc>
  32. #include <geoip>
  33.  
  34. #define SHOW_COLOR 1
  35. #define SHOW_CONNECT 2
  36. #define SHOW_DISCONNECT 4
  37. #define PLAY_SOUND_CONNECT 8
  38. #define PLAY_SOUND_DISCONNECT 16
  39.  
  40. new display_type_pcvar
  41.  
  42. new name[33][32]
  43. new authid[33][32]
  44. new country[33][46]
  45. new ip[33][32]
  46.  
  47. new connect_soundfile[64]
  48. new disconnect_soundfile[64]
  49.  
  50. new saytext_msgid
  51.  
  52. public plugin_init()
  53. {
  54. register_plugin("GHW Connect Messages",VERSION,"GHW_Chronic")
  55. display_type_pcvar = register_cvar("cm_flags","7")
  56. register_cvar("cm_connect_string","[1337] %name se ha conectado (%country).")
  57. register_cvar("cm_disconnect_string","[1337] %name se ha desconectado (%country).")
  58.  
  59. saytext_msgid = get_user_msgid("SayText")
  60. }
  61.  
  62. public plugin_precache()
  63. {
  64. register_cvar("cm_connect_sound","buttons/bell1.wav")
  65. register_cvar("cm_disconnect_sound","fvox/blip.wav")
  66.  
  67. get_cvar_string("cm_connect_sound",connect_soundfile,63)
  68. get_cvar_string("cm_disconnect_sound",disconnect_soundfile,63)
  69.  
  70. precache_sound(connect_soundfile)
  71. precache_sound(disconnect_soundfile)
  72. }
  73.  
  74. public client_putinserver(id)
  75. {
  76. if(!is_user_bot(id))
  77. {
  78. get_client_info(id)
  79.  
  80. new display_type = get_pcvar_num(display_type_pcvar)
  81. if(display_type & SHOW_CONNECT)
  82. {
  83. new string[200]
  84. get_cvar_string("cm_connect_string",string,199)
  85. format(string,199,"^x01%s",string)
  86.  
  87. if(display_type & SHOW_COLOR)
  88. {
  89. new holder[46]
  90.  
  91. format(holder,45,"^x04%s^x01",name[id])
  92. replace(string,199,"%name",holder)
  93.  
  94. format(holder,45,"^x04%s^x01",authid[id])
  95. replace(string,199,"%steamid",holder)
  96.  
  97. format(holder,45,"^x04%s^x01",country[id])
  98. replace(string,199,"%country",holder)
  99.  
  100. format(holder,45,"^x04%s^x01",ip[id])
  101. replace(string,199,"%ip",holder)
  102. }
  103. else
  104. {
  105. replace(string,199,"%name",name[id])
  106. replace(string,199,"%steamid",authid[id])
  107. replace(string,199,"%country",country[id])
  108. replace(string,199,"%ip",ip[id])
  109. }
  110.  
  111. new num, players[32], player
  112. get_players(players,num,"ch")
  113. for(new i=0;i<num;i++)
  114. {
  115. player = players[i]
  116.  
  117. message_begin(MSG_ONE,saytext_msgid,{0,0,0},player)
  118. write_byte(player)
  119. write_string(string)
  120. message_end()
  121.  
  122. if(display_type & PLAY_SOUND_CONNECT)
  123. {
  124. new stringlen = strlen(connect_soundfile)
  125. if(connect_soundfile[stringlen - 1]=='v' && connect_soundfile[stringlen - 2]=='a' && connect_soundfile[stringlen - 3]=='w') //wav
  126. {
  127. client_cmd(player,"spk ^"sound/%s^"",connect_soundfile)
  128. }
  129. if(connect_soundfile[stringlen - 1]=='3' && connect_soundfile[stringlen - 2]=='p' && connect_soundfile[stringlen - 3]=='m') //wav
  130. {
  131. client_cmd(player,"mp3 play ^"sound/%s^"",connect_soundfile)
  132. }
  133. }
  134. }
  135. }
  136. }
  137. }
  138.  
  139. public get_client_info(id)
  140. {
  141. get_user_name(id,name[id],31)
  142. get_user_authid(id,authid[id],31)
  143.  
  144. get_user_ip(id,ip[id],31)
  145. geoip_country(ip[id],country[id])
  146. if(equal(country[id],"error"))
  147. {
  148. if(contain(ip[id],"192.168.")==0 || equal(ip[id],"127.0.0.1") || contain(ip[id],"10.")==0 || contain(ip[id],"172.")==0)
  149. {
  150. country[id] = "LAN"
  151. }
  152. if(equal(ip[id],"loopback"))
  153. {
  154. country[id] = "ListenServer User"
  155. }
  156. else
  157. {
  158. country[id] = "Unknown Country"
  159. }
  160. }
  161. }
  162.  
  163. public client_infochanged(id)
  164. {
  165. if(!is_user_bot(id))
  166. {
  167. get_user_info(id,"name",name[id],31)
  168. }
  169. }
  170.  
  171. public client_disconnect(id)
  172. {
  173. if(!is_user_bot(id))
  174. {
  175. new display_type = get_pcvar_num(display_type_pcvar)
  176. if(display_type & SHOW_DISCONNECT)
  177. {
  178. new string[200]
  179. get_cvar_string("cm_disconnect_string",string,199)
  180. format(string,199,"^x01%s",string)
  181.  
  182. if(display_type & SHOW_COLOR)
  183. {
  184. new holder[46]
  185.  
  186. format(holder,45,"^x04%s^x01",name[id])
  187. replace(string,199,"%name",holder)
  188.  
  189. format(holder,45,"^x04%s^x01",authid[id])
  190. replace(string,199,"%steamid",holder)
  191.  
  192. format(holder,45,"^x04%s^x01",country[id])
  193. replace(string,199,"%country",holder)
  194.  
  195. format(holder,45,"^x04%s^x01",ip[id])
  196. replace(string,199,"%ip",holder)
  197. }
  198. else
  199. {
  200. replace(string,199,"%name",name[id])
  201. replace(string,199,"%steamid",authid[id])
  202. replace(string,199,"%country",country[id])
  203. replace(string,199,"%ip",ip[id])
  204. }
  205.  
  206. new num, players[32], player
  207. get_players(players,num,"ch")
  208. for(new i=0;i<num;i++)
  209. {
  210. player = players[i]
  211.  
  212. message_begin(MSG_ONE,saytext_msgid,{0,0,0},player)
  213. write_byte(player)
  214. write_string(string)
  215. message_end()
  216.  
  217. if(display_type & PLAY_SOUND_DISCONNECT){
  218. new stringlen = strlen(disconnect_soundfile)
  219. if(disconnect_soundfile[stringlen - 1]=='v' && disconnect_soundfile[stringlen - 2]=='a' && disconnect_soundfile[stringlen - 3]=='w') //wav
  220. {
  221. client_cmd(player,"spk ^"sound/%s^"",disconnect_soundfile)
  222. }
  223. if(disconnect_soundfile[stringlen - 1]=='3' && disconnect_soundfile[stringlen - 2]=='p' && disconnect_soundfile[stringlen - 3]=='m') //wav
  224. {
  225. client_cmd(player,"mp3 play ^"sound/%s^"",disconnect_soundfile)
  226. }
  227. }
  228. }
  229. }
  230. }
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement