#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
new const PLUGIN[] = "vip"
new const VERSION[] = "1.0"
new const AUTHOR[] = "L1fe"
#define TASK_CONNECT 504030
#define CVAR_ENABLE "vipc_enable"
#define CVAR_SHOWMSG "vipc_show_message"
#define CVAR_MESSAGE "vipc_message"
#define CVAR_SETFLAGS "vipc_setflags"
#define OFFSET_TEAM 114
#define MAX_LENOFNAME 32
#define MAX_FLOODCOUNT 12
enum CsTeams
{
CS_TEAM_UNASSIGNED = 0,
CS_TEAM_T = 1,
CS_TEAM_CT = 2,
CS_TEAM_SPECTATOR = 3
}
enum ChatColor
{
CHATCOLOR_NORMAL = 1, // Normal
CHATCOLOR_GREEN, // Green Color
CHATCOLOR_TEAM_COLOR, // Red, grey, blue
CHATCOLOR_GREY, // grey
CHATCOLOR_RED, // Red
CHATCOLOR_BLUE, // Blue
}
new g_TeamName[][] =
{
"",
"TERRORIST",
"CT",
"SPECTATOR"
}
new g_msgSayText
new g_msgTeamInfo
new sz_anti_flood_msg[] = "so many errors at lines, operation break at line #%d"
new g_name_change[] = "#Cstrike_Name_Change"
new g_say_team[] = "say_team"
new g_name[] = "name"
// Тут можно установить таг
new VIP_TAG[] = "vip*"
// // // // // // // // //
new VIPFile[256]
new bool:readflags = false
new bool:hasVip[33] = { false, ... }
new VipFlags[33]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar(CVAR_ENABLE, "1")
register_cvar(CVAR_SHOWMSG, "1")
//Приветствуем VIP клиента!^x04 %name%^x01 %ip% %steamid% Флаги:^x04 %flags%
register_cvar(CVAR_MESSAGE, "Vip cyber gamer connect........^x04 %name%^x01 Management level:^x04 %flags%")
register_cvar(CVAR_SETFLAGS, "ab")
register_clcmd("say", "cmdCheckSay", -1)
register_clcmd(g_say_team, "cmdCheckSay", -1)
register_forward(FM_ClientUserInfoChanged, "forward_client_userinfochanged")
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
g_msgSayText = get_user_msgid("SayText")
g_msgTeamInfo = get_user_msgid("TeamInfo")
}
public plugin_cfg()
{
get_localinfo("amxx_configsdir", VIPFile, sizeof VIPFile -1)
format(VIPFile, sizeof VIPFile -1, "%s/vip.ini", VIPFile)
if(!file_exists(VIPFile))
{
log_amx("new file: '%s' created, manual added", VIPFile)
write_file(VIPFile, "; Файл сгенерирован плагином vip_client.amxx v1.1")
write_file(VIPFile, "; Варианты проверки:")
write_file(VIPFile, "; n - Ник и пароль")
write_file(VIPFile, "; i - IP")
write_file(VIPFile, "; s - SteamID")
write_file(VIPFile, "; Например:")
write_file(VIPFile, "; n ^"My Name^" ^"My Super Password^"")
write_file(VIPFile, "; i ^"127.0.0.1^"")
write_file(VIPFile, "; s ^"STEAM_0:0:123456789^"")
write_file(VIPFile, ";")
write_file(VIPFile, "; Примечание: Пароль вводить через setinfo _pw - (setinfo _pw ^"My Super Password^")")
}
}
public client_putinserver(id)
{
if(!is_user_bot(id) && !is_user_hltv(id) && get_cvar_num(CVAR_ENABLE))
{
hasVip[id] = false
set_task(3.0, "cmdCheckClient", id+TASK_CONNECT)
}
}
public client_disconnect(id)
hasVip[id] = false
public cmdCheckClient(pid)
{
static id
id = pid - TASK_CONNECT
if(is_user_connected(id))
{
if(file_exists(VIPFile))
{
static
szData[74],
whatcheck[35],
whatpwd[MAX_LENOFNAME],
mode[6]
new
anti_flood = 0,
numofline = 0,
joinmode = 4,
l_mode
static temp_tagname[MAX_LENOFNAME], temp_name[MAX_LENOFNAME], temp_password[MAX_LENOFNAME], temp_ip[16], temp_steamid[35]
pev(id, pev_netname, temp_name, sizeof temp_name -1)
copy(temp_tagname, sizeof temp_tagname -1, temp_name)
replace(temp_tagname, sizeof temp_tagname -1, VIP_TAG, "")
get_user_info(id, "_pw", temp_password, sizeof temp_password -1)
get_user_ip(id, temp_ip, sizeof temp_ip -1, 1)
get_user_authid(id, temp_steamid, sizeof temp_steamid -1)
new file = fopen(VIPFile, "rt")
while(!feof(file))
{
numofline++
mode = ""
fgets(file, szData, sizeof szData -1)
if(!strlen(szData) || szData[0] == ';' || (szData[0] == '/' && szData[1] == '/'))
continue
parse(szData, mode, sizeof mode -1, whatcheck, sizeof whatcheck -1, whatpwd, sizeof whatpwd -1)
l_mode = strlen(mode)
if(!l_mode)
continue
if(l_mode >= 2)
{
anti_flood++
log_amx("sorry, len of mode can't be >= 2 (now %d) (line #%d)", l_mode, numofline)
if(anti_flood >= MAX_FLOODCOUNT)
{
log_amx(sz_anti_flood_msg, numofline)
break
}
continue
}
joinmode = 4
switch(mode[0])
{
case 'n': // Name & Password
{
if(!strlen(whatpwd))
{
anti_flood++
log_amx("hm... password not set! (Name: <%s> line #%d)", temp_name, numofline)
log_amx("Use this: n ^"%s^" ^"His Super Password^"", temp_name)
if(anti_flood >= MAX_FLOODCOUNT)
{
log_amx(sz_anti_flood_msg, numofline)
break
}
}
else
{
if((equali(temp_tagname, whatcheck) || equali(temp_name, whatcheck)) && equal(whatpwd, temp_password))
{
hasVip[id] = true
joinmode = 1
break
}
}
}
case 'i': // IP
{
if(equal(temp_ip, whatcheck))
{
hasVip[id] = true
joinmode = 2
break
}
}
case 's': // SteamID
{
if(equal(temp_steamid, whatcheck))
{
hasVip[id] = true
joinmode = 3
break
}
}
default: // lol
{
anti_flood++
log_amx("unknown mode at line #%d", numofline)
if(anti_flood >= MAX_FLOODCOUNT)
{
log_amx(sz_anti_flood_msg, numofline)
break
}
}
}
}
fclose(file)
if(hasVip[id] && joinmode != 4)
{
static
login_by[16],
sflags[28],
flags
switch(joinmode)
{
case 1: login_by = "Name & Password"
case 2: login_by = "IP"
case 3: login_by = "SteamID"
}
get_cvar_string(CVAR_SETFLAGS, sflags, sizeof sflags -1)
if(strlen(sflags) >= 1)
{
flags = read_flags(sflags)
remove_user_flags(id, -1)
set_user_flags(id, flags)
VipFlags[id] = flags
get_flags(VipFlags[id], sflags, sizeof sflags -1)
readflags = true
}
else
{
new cs_default[35]
get_cvar_string("amx_default_access", cs_default, sizeof cs_default -1)
flags = read_flags(cs_default)
VipFlags[id] = flags
get_flags(VipFlags[id], sflags, sizeof sflags -1)
readflags = false
}
log_amx("%s <%s><%s><%s><%s> at line #%d joined by %s", PLUGIN, temp_name, temp_ip, temp_steamid, sflags, numofline, login_by)
if(get_cvar_num(CVAR_SHOWMSG))
{
static message[190]
get_cvar_string(CVAR_MESSAGE, message, sizeof message -1)
if(strlen(message) >= 1)
{
if(strlen(temp_name) >= 12)
add(temp_name, 12, "...")
replace(message, sizeof message -1, "%name%", temp_name)
replace(message, sizeof message -1, "%ip%", temp_ip)
if(equali(temp_steamid, "STEAM_ID_LAN")
|| equali(temp_steamid, "VALVE_ID_LAN")
|| equali(temp_steamid, "STEAM_666:88:666")
|| equali(temp_steamid, "www.mindtrek.ru")
|| equali(temp_steamid, "STEAM_ID_PENDING")
|| equali(temp_steamid, "VALVE_ID_PENDING"))
{
replace(message, sizeof message -1, "%steamid%", "No SteamID")
}
else
replace(message, sizeof message -1, "%steamid%", temp_steamid)
replace(message, sizeof message -1, "%flags%", sflags)
format(message, sizeof message -1, "^x04[VIPC]^x01: %s", message)
colorChat(0, CHATCOLOR_NORMAL, message)
}
else
log_amx("cvarstring %s not set :/", CVAR_MESSAGE)
}
if(is_user_alive(id))
{
pev(id, pev_netname, temp_name, sizeof temp_name -1)
if(!(contain(temp_name, VIP_TAG) != -1))
{
cmdAddUserTag(id, temp_name)
}
}
}
}
else // extreme noobs
{
log_amx("Nizia ydaliat fail, kogda rabotaet plagin ! >:[")
log_amx("plugin paused koro4e...")
pause("a")
}
}
}
public cmdCheckSay(id)
{
if(!hasVip[id])
return PLUGIN_CONTINUE
static message[192]
read_args(message, sizeof message -1)
remove_quotes(message)
if(!strlen(message))
return PLUGIN_HANDLED // :/
static cmd[9]
read_argv(0, cmd, sizeof cmd -1)
static name[MAX_LENOFNAME]
pev(id, pev_netname, name, sizeof name -1)
static CsTeams:team
team = fm_get_user_team(id)
static players[MAX_LENOFNAME], totalplayers, pid
switch(team)
{
case CS_TEAM_SPECTATOR:
{
if(equal(cmd, g_say_team))
{
get_players(players, totalplayers, "c")
format(message, sizeof message -1, "^x01(Spectator)^x03 %s^x04 : %s", name, message)
for(new i = 0; i < totalplayers; i++)
{
pid = players[i]
if(fm_get_user_team(pid) == CS_TEAM_SPECTATOR)
{
colorChat(pid, CHATCOLOR_GREY, "%s", message)
}
}
}
else
{
get_players(players, totalplayers, "bc")
format(message, sizeof message -1, "^x01*SPEC*^x03 %s^x04 : %s", name, message)
for(new i=0;i<totalplayers;i++)
{
pid = players[i]
colorChat(pid, CHATCOLOR_GREY, "%s", message)
}
}
}
case CS_TEAM_T:
{
if(is_user_alive(id))
{
if(equal(cmd, g_say_team))
{
get_players(players, totalplayers, "ace", "TERRORIST")
format(message, sizeof message -1, "^x01(Terrorist)^x03 %s^x01 :^x04 %s", name, message)
for(new i = 0; i < totalplayers; i++)
{
pid = players[i]
colorChat(pid, CHATCOLOR_RED, "%s", message)
}
}
else
{
get_players(players, totalplayers, "ac")
format(message, sizeof message -1, "^x03%s^x01 :^x04 %s", name, message)
for(new i = 0; i < totalplayers; i++)
{
pid = players[i]
colorChat(pid, CHATCOLOR_RED, "%s", message)
}
}
}
else
{
if(equal(cmd, g_say_team))
{
get_players(players, totalplayers, "bce", "TERRORIST")
format(message, sizeof message -1, "^x01*DEAD*(Terrorist)^x03 %s^x01 :^x04 %s", name, message)
for(new i = 0; i < totalplayers; i++)
{
pid = players[i]
colorChat(pid, CHATCOLOR_RED, "%s", message)
}
}
else
{
get_players(players, totalplayers, "bc")
format(message, sizeof message -1, "^x01*DEAD*^x03 %s^x01 :^x04 %s", name, message)
for(new i = 0; i < totalplayers; i++)
{
pid = players[i]
colorChat(pid, CHATCOLOR_RED, "%s", message)
}
}
}
}
case CS_TEAM_CT:
{
if(is_user_alive(id))
{
if(equal(cmd, g_say_team))
{
get_players(players, totalplayers, "ace", "CT")
format(message, sizeof message -1, "^x01(Counter-Terrorist) ^x03%s ^x01:^x04 %s", name, message)
for(new i = 0; i < totalplayers; i++)
{
pid = players[i]
colorChat(pid, CHATCOLOR_BLUE, "%s", message)
}
}
else
{
get_players(players, totalplayers, "ac")
format(message, sizeof message -1, "^x03%s ^x01:^x04 %s", name, message)
for(new i = 0; i < totalplayers; i++)
{
pid = players[i]
colorChat(pid, CHATCOLOR_BLUE, "%s", message)
}
}
}
else
{
if(equal(cmd, g_say_team))
{
get_players(players, totalplayers, "bce", "CT")
format(message, sizeof message -1, "^x01*DEAD*(Counter-Terrorist)^x03 %s^x01 :^x04 %s", name, message)
for(new i = 0; i < totalplayers; i++)
{
pid = players[i]
colorChat(pid, CHATCOLOR_BLUE, "%s", message)
}
}
else
{
get_players(players, totalplayers, "bc")
format(message, sizeof message -1, "^x01*DEAD*^x03 %s^x01 :^x04 %s", name, message)
for(new i = 0; i < totalplayers; i++)
{
pid = players[i]
colorChat(pid, CHATCOLOR_BLUE, "%s", message)
}
}
}
}
}
return PLUGIN_HANDLED
}
public client_infochanged(id)
{
if(!hasVip[id] || !readflags)
return PLUGIN_CONTINUE
remove_user_flags(id, -1)
set_user_flags(id, VipFlags[id])
return PLUGIN_CONTINUE
}
public forward_client_userinfochanged(id, buffer)
{
if(!is_user_connected(id))
return FMRES_IGNORED
static oldname[MAX_LENOFNAME], newname[MAX_LENOFNAME]
pev(id, pev_netname, oldname, sizeof oldname -1)
engfunc(EngFunc_InfoKeyValue, buffer, g_name, newname, sizeof newname - 1)
if(equal(newname, oldname))
return FMRES_IGNORED
if(hasVip[id])
cmdAddUserTag(id, newname)
msg_name_change(id, oldname, newname)
return FMRES_SUPERCEDE
}
public cmdAddUserTag(id, name[])
{
replace(name, MAX_LENOFNAME, VIP_TAG, "")
format(name, MAX_LENOFNAME -1, "%s%s", VIP_TAG, name)
set_user_info(id, g_name, name)
}
public fwHamPlayerSpawnPost(id)
{
if(!is_user_alive(id) || !hasVip[id])
return HAM_IGNORED
static name[MAX_LENOFNAME]
pev(id, pev_netname, name, MAX_LENOFNAME -1)
cmdAddUserTag(id, name)
return HAM_HANDLED
}
msg_name_change(id, oldname[], newname[])
{
message_begin(MSG_BROADCAST, g_msgSayText)
write_byte(id)
write_string(g_name_change)
write_string(oldname)
write_string(newname)
message_end()
}
stock CsTeams:fm_get_user_team(id)
{
return CsTeams:get_pdata_int(id, OFFSET_TEAM)
}
colorChat(id, ChatColor:color, const msg[], {Float,Sql,Result,_}:...)
{
new team, index, MSG_Type
new bool:teamChanged = false
static message[192]
switch(color)
{
case CHATCOLOR_NORMAL: // Normal
{
message[0] = 0x01
}
case CHATCOLOR_GREEN: // Green
{
message[0] = 0x04
}
default: // Grey, Red, Blue
{
message[0] = 0x03
}
}
vformat(message[1], 190, msg, 4)
if(id == 0)
{
index = findAnyPlayer()
MSG_Type = MSG_ALL
}
else
{
index = id
MSG_Type = MSG_ONE
}
if(index != 0)
{
team = get_user_team(index)
if(color == CHATCOLOR_RED && team != 1)
{
messageTeamInfo(index, MSG_Type, g_TeamName[1])
teamChanged = true
}
else if(color == CHATCOLOR_BLUE && team != 2)
{
messageTeamInfo(index, MSG_Type, g_TeamName[2])
teamChanged = true
}
else if(color == CHATCOLOR_GREY && team != 0)
{
messageTeamInfo(index, MSG_Type, g_TeamName[0])
teamChanged = true
}
messageSayText(index, MSG_Type, message)
if(teamChanged)
{
messageTeamInfo(index, MSG_Type, g_TeamName[team])
}
}
}
messageSayText(id, type, message[])
{
message_begin(type, g_msgSayText, _, id)
write_byte(id)
write_string(message)
message_end()
}
messageTeamInfo(id, type, team[])
{
message_begin(type, g_msgTeamInfo, _, id)
write_byte(id)
write_string(team)
message_end()
}
findAnyPlayer()
{
static players[MAX_LENOFNAME], inum, pid
get_players(players, inum)
for(new a = 0; a < inum; a++)
{
pid = players[a]
if(is_user_connected(pid))
return pid
}
return 0
}