PHP Code:
#include <amxmodx>
#include <amxmisc>
#define MAX_PLAYERS 32
#define MAX_AUTHID_LENGTH 22
#define FFADE_IN 0x0000
#define FFADE_OUT 0x0001
#define FFADE_STAYOUT 0x0004
#define set_user_blinded(%1) g_bBlinded |= 1<<(%1 & 31)
#define set_user_unblinded(%1) g_bBlinded &= ~( 1<<(%1 & 31) )
#define is_user_blinded(%1) g_bBlinded & 1<<(%1 & 31)
const CMDTARGET_BLIND = (CMDTARGET_OBEY_IMMUNITY|CMDTARGET_ALLOW_SELF|CMDTARGET_ONLY_ALIVE|CMDTARGET_NO_BOTS)
new g_bBlinded
new gmsgScreenFade
public plugin_init()
{
register_plugin("AMX Blind", "v1.2", "T(+)rget")
register_event("ScreenFade", "Event_ScreenFade", "b")
register_concmd("amx_blind", "AdminCommand_BlindUser", ADMIN_KICK, "<authid, nick or #userid>")
register_concmd("amx_unblind", "AdminCommand_UnblindUser", ADMIN_KICK, "<authid, nick or #userid>")
gmsgScreenFade = get_user_msgid("ScreenFade")
}
public client_putinserver( id )
{
set_user_unblinded(id)
}
public AdminCommand_BlindUser(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
{
return PLUGIN_HANDLED
}
new szArg[32]
read_argv(1, szArg, charsmax(szArg))
new iPlayer
if( !(iPlayer = cmd_target(id, szArg, CMDTARGET_BLIND)) )
{
return PLUGIN_HANDLED
}
new szName2[32]
get_user_name(iPlayer, szName2, charsmax(szName2))
if( is_user_blinded(iPlayer) )
{
console_print(id, "Client ^"%s^" is already blind", szName2)
return PLUGIN_HANDLED
}
else
{
set_user_blinded(iPlayer)
static const iBlindFxTime = (1<<3)|(1<<8)|(1<<10)
Send_ScreenFade(id, iBlindFxTime, iBlindFxTime, FFADE_OUT|FFADE_STAYOUT, 0xFF)
}
new szName[32]
get_user_name(id, szName, charsmax(szName))
show_activity_key("ADMIN: blinded %s", "ADMIN %s: blinded %s", szName, szName2)
console_print(id, "Client ^"%s^" blinded", szName2)
return PLUGIN_HANDLED
}
public AdminCommand_UnblindUser(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
{
return PLUGIN_HANDLED
}
new szArg[32]
read_argv(1, szArg, charsmax(szArg))
new iPlayer
if( !(iPlayer = cmd_target(id, szArg, CMDTARGET_BLIND)) )
{
return PLUGIN_HANDLED
}
new szName2[32]
get_user_name(iPlayer, szName2, charsmax(szName2))
if( is_user_blinded(iPlayer) )
{
set_user_unblinded(iPlayer)
Send_ScreenFade(iPlayer, 4, 0, FFADE_IN, 0)
}
else
{
console_print(id, "Client ^"%s^" is already unblind", szName2)
return PLUGIN_HANDLED
}
new szName[32]
get_user_name(id, szName, charsmax(szName))
show_activity_key("ADMIN: unblinded %s", "ADMIN %s: unblinded %s", szName, szName2)
console_print(id, "Client ^"%s^" unblinded", szName2)
return PLUGIN_HANDLED
}
public Event_ScreenFade( id )
{
if( is_user_blinded(id) )
{
Send_ScreenFade(id, 4, 0, FFADE_OUT|FFADE_STAYOUT, 0xFF)
}
}
Send_ScreenFade(id, iFadeTime, iHoldTime, iFlags, iAlpha)
{
message_begin(MSG_ONE_UNRELIABLE, gmsgScreenFade, _, id)
write_short(iFadeTime)
write_short(iHoldTime)
write_short(iFlags)
write_byte(0)
write_byte(0)
write_byte(0)
write_byte(iAlpha)
message_end()
}