Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <amx_settings_api>
- #define PLUGIN "D2LOD VIP"
- #define VERSION "1.0"
- #define AUTHOR "Catastrophe"
- #define vip_config "vips.ini"
- #define SCOREATTRIB_DEAD ( 1 << 0 )
- #define SCOREATTRIB_VIP ( 1 << 2 )
- new Array:g_vip_ids
- new is_vip[33]
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- register_clcmd("say /vips", "show_vips")
- register_clcmd("amx_reload_vips", "reload_vips")
- register_message( get_user_msgid( "ScoreAttrib" ), "MessageScoreAttrib"
- )
- g_vip_ids = ArrayCreate(64, 1)
- amx_load_setting_string_arr(vip_config, "VIPS", "Ids", g_vip_ids)
- }
- public reload_vips(id)
- {
- if(!(get_user_flags(id) & ADMIN_IMMUNITY))
- {
- console_print(id, "You have no access.")
- return
- }
- amx_load_setting_string_arr(vip_config, "VIPS", "Ids", g_vip_ids)
- for(new k = 1; k <= get_maxplayers(); k++)
- {
- if(is_user_connected(k))
- {
- client_authorized(k)
- }
- }
- }
- public MessageScoreAttrib( iMsgID, iDest, iReceiver )
- {
- new iPlayer = get_msg_arg_int( 1 );
- if( is_user_connected( iPlayer ) && is_vip[iPlayer]) {
- set_msg_arg_int( 2, ARG_BYTE, is_user_alive( iPlayer ) ? SCOREATTRIB_VIP
- : SCOREATTRIB_DEAD );
- }
- }
- public show_vips(id)
- {
- if(ArraySize(g_vip_ids) <= 0)
- {
- colorchat(id, "^x04 No Vips connected")
- return
- }
- new v_list[256]
- for(new i = 1; i <= get_maxplayers(); i++)
- {
- if(!is_user_connected(i))
- continue
- new name[32]
- get_user_name(i, name, 31)
- if(is_vip[i] && !equali(v_list, ""))
- {
- formatex(v_list, 255, "%s, %s", v_list, name)
- }
- else if(is_vip[i] && equali(v_list, ""))
- {
- formatex(v_list, 255, "%s", name)
- }
- else
- continue
- }
- colorchat(id, "^x04 Connected VIPs: %s", v_list)
- }
- public client_authorized(id)
- {
- for(new i; i <= ArraySize(g_vip_ids) - 1; i++)
- {
- new authid[32], u_id[32]
- get_user_authid(id, u_id, 31)
- ArrayGetString(g_vip_ids, i, authid, 31)
- if(equali(u_id, authid))
- {
- is_vip[id] = 1
- return
- }
- }
- }
- public plugin_natives()
- {
- register_native("d2_get_vip", "get_vip")
- }
- public get_vip(plugin_id, num_params)
- {
- new id = get_param(1)
- if (!is_user_connected(id))
- {
- log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
- return -1
- }
- return is_vip[id]
- }
- stock colorchat(target, const message[], any:...)
- {
- static buffer[512], msg_SayText = 0
- if( !msg_SayText ) msg_SayText = get_user_msgid("SayText")
- // Send to everyone
- if (!target)
- {
- static player, maxplayers, argscount
- maxplayers = get_maxplayers()
- argscount = numargs()
- for (player = 1; player <= maxplayers; player++)
- {
- // Not connected
- if (!is_user_connected(player))
- continue;
- // Remember changed arguments
- static arg_index, changed_args[20], changedcount // [20]
- = max LANG_PLAYER occurencies
- changedcount = 0
- // Replace LANG_PLAYER with player id
- for (arg_index = 2; arg_index < argscount; arg_index++)
- {
- if (getarg(arg_index) == LANG_PLAYER &&
- arg_index + 1 < argscount)
- {
- // Check if next param string is a
- registered language translation
- static lang_key[64], arg_subindex
- arg_subindex = 0
- while ((lang_key[arg_subindex] = getarg
- (arg_index + 1, arg_subindex++))) { /* keep looping */ }
- if (GetLangTransKey(lang_key) !=
- TransKey_Bad)
- {
- setarg(arg_index, 0, player)
- changed_args[changedcount++] =
- arg_index
- arg_index++ // skip next
- argument since we know it's a translation key
- }
- }
- }
- // Format message for player (+add ZP prefix)
- vformat(buffer, charsmax(buffer), message, 3)
- // Send it
- message_begin(MSG_ONE_UNRELIABLE, msg_SayText, _,
- player)
- write_byte(player)
- write_string(buffer)
- message_end()
- // Replace back player id's with LANG_PLAYER
- for (arg_index = 0; arg_index < changedcount; arg_index
- ++)
- setarg(changed_args[arg_index], 0, LANG_PLAYER)
- }
- }
- // Send to specific target
- else
- {
- // Format message for player (+add ZP prefix)
- vformat(buffer, charsmax(buffer), message, 3)
- // Send it
- message_begin(MSG_ONE, msg_SayText, _, target)
- write_byte(target)
- write_string(buffer)
- message_end()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement