Advertisement
Guest User

Untitled

a guest
Nov 29th, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <amx_settings_api>
  4.  
  5. #define PLUGIN "D2LOD VIP"
  6. #define VERSION "1.0"
  7. #define AUTHOR "Catastrophe"
  8.  
  9. #define vip_config "vips.ini"
  10.  
  11. #define SCOREATTRIB_DEAD ( 1 << 0 )
  12. #define SCOREATTRIB_VIP ( 1 << 2 )
  13.  
  14. new Array:g_vip_ids
  15. new is_vip[33]
  16.  
  17. public plugin_init()
  18. {
  19. register_plugin(PLUGIN, VERSION, AUTHOR)
  20.  
  21. register_clcmd("say /vips", "show_vips")
  22. register_clcmd("amx_reload_vips", "reload_vips")
  23.  
  24. register_message( get_user_msgid( "ScoreAttrib" ), "MessageScoreAttrib"
  25.  
  26. )
  27.  
  28. g_vip_ids = ArrayCreate(64, 1)
  29.  
  30. amx_load_setting_string_arr(vip_config, "VIPS", "Ids", g_vip_ids)
  31. }
  32.  
  33. public reload_vips(id)
  34. {
  35. if(!(get_user_flags(id) & ADMIN_IMMUNITY))
  36. {
  37. console_print(id, "You have no access.")
  38. return
  39. }
  40.  
  41. amx_load_setting_string_arr(vip_config, "VIPS", "Ids", g_vip_ids)
  42.  
  43. for(new k = 1; k <= get_maxplayers(); k++)
  44. {
  45. if(is_user_connected(k))
  46. {
  47. client_authorized(k)
  48. }
  49. }
  50. }
  51.  
  52. public MessageScoreAttrib( iMsgID, iDest, iReceiver )
  53. {
  54. new iPlayer = get_msg_arg_int( 1 );
  55.  
  56. if( is_user_connected( iPlayer ) && is_vip[iPlayer]) {
  57. set_msg_arg_int( 2, ARG_BYTE, is_user_alive( iPlayer ) ? SCOREATTRIB_VIP
  58.  
  59. : SCOREATTRIB_DEAD );
  60. }
  61. }
  62.  
  63. public show_vips(id)
  64. {
  65. if(ArraySize(g_vip_ids) <= 0)
  66. {
  67. colorchat(id, "^x04 No Vips connected")
  68. return
  69. }
  70.  
  71. new v_list[256]
  72.  
  73. for(new i = 1; i <= get_maxplayers(); i++)
  74. {
  75. if(!is_user_connected(i))
  76. continue
  77.  
  78. new name[32]
  79. get_user_name(i, name, 31)
  80.  
  81. if(is_vip[i] && !equali(v_list, ""))
  82. {
  83. formatex(v_list, 255, "%s, %s", v_list, name)
  84. }
  85.  
  86. else if(is_vip[i] && equali(v_list, ""))
  87. {
  88. formatex(v_list, 255, "%s", name)
  89. }
  90.  
  91. else
  92. continue
  93. }
  94.  
  95. colorchat(id, "^x04 Connected VIPs: %s", v_list)
  96. }
  97.  
  98. public client_authorized(id)
  99. {
  100. for(new i; i <= ArraySize(g_vip_ids) - 1; i++)
  101. {
  102. new authid[32], u_id[32]
  103. get_user_authid(id, u_id, 31)
  104. ArrayGetString(g_vip_ids, i, authid, 31)
  105.  
  106. if(equali(u_id, authid))
  107. {
  108. is_vip[id] = 1
  109. return
  110. }
  111. }
  112. }
  113.  
  114. public plugin_natives()
  115. {
  116. register_native("d2_get_vip", "get_vip")
  117. }
  118.  
  119. public get_vip(plugin_id, num_params)
  120. {
  121. new id = get_param(1)
  122.  
  123. if (!is_user_connected(id))
  124. {
  125. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  126. return -1
  127. }
  128.  
  129. return is_vip[id]
  130. }
  131.  
  132. stock colorchat(target, const message[], any:...)
  133. {
  134. static buffer[512], msg_SayText = 0
  135. if( !msg_SayText ) msg_SayText = get_user_msgid("SayText")
  136.  
  137. // Send to everyone
  138. if (!target)
  139. {
  140. static player, maxplayers, argscount
  141. maxplayers = get_maxplayers()
  142. argscount = numargs()
  143.  
  144. for (player = 1; player <= maxplayers; player++)
  145. {
  146. // Not connected
  147. if (!is_user_connected(player))
  148. continue;
  149.  
  150. // Remember changed arguments
  151. static arg_index, changed_args[20], changedcount // [20]
  152.  
  153. = max LANG_PLAYER occurencies
  154. changedcount = 0
  155.  
  156. // Replace LANG_PLAYER with player id
  157. for (arg_index = 2; arg_index < argscount; arg_index++)
  158. {
  159. if (getarg(arg_index) == LANG_PLAYER &&
  160.  
  161. arg_index + 1 < argscount)
  162. {
  163. // Check if next param string is a
  164.  
  165. registered language translation
  166. static lang_key[64], arg_subindex
  167. arg_subindex = 0
  168. while ((lang_key[arg_subindex] = getarg
  169.  
  170. (arg_index + 1, arg_subindex++))) { /* keep looping */ }
  171. if (GetLangTransKey(lang_key) !=
  172.  
  173. TransKey_Bad)
  174. {
  175. setarg(arg_index, 0, player)
  176. changed_args[changedcount++] =
  177.  
  178. arg_index
  179. arg_index++ // skip next
  180.  
  181. argument since we know it's a translation key
  182. }
  183. }
  184. }
  185.  
  186. // Format message for player (+add ZP prefix)
  187. vformat(buffer, charsmax(buffer), message, 3)
  188.  
  189.  
  190. // Send it
  191. message_begin(MSG_ONE_UNRELIABLE, msg_SayText, _,
  192.  
  193. player)
  194. write_byte(player)
  195. write_string(buffer)
  196. message_end()
  197.  
  198. // Replace back player id's with LANG_PLAYER
  199. for (arg_index = 0; arg_index < changedcount; arg_index
  200.  
  201. ++)
  202. setarg(changed_args[arg_index], 0, LANG_PLAYER)
  203. }
  204. }
  205. // Send to specific target
  206. else
  207. {
  208. // Format message for player (+add ZP prefix)
  209. vformat(buffer, charsmax(buffer), message, 3)
  210.  
  211. // Send it
  212. message_begin(MSG_ONE, msg_SayText, _, target)
  213. write_byte(target)
  214. write_string(buffer)
  215. message_end()
  216. }
  217. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement