Advertisement
Guest User

Untitled

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