#include <amxmodx>
//#include <fakemeta>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#include <engine>
#define ACCESS_FLAG ADMIN_LEVEL_H
#define keys (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<9)
#define PREFIX "[Surf]"
#define fm_get_user_money(%1) get_pdata_int( %1, 115 )
#define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))
new usersilent[33]
enum Color {
NORMAL = 1, // clients scr_concolor cvar color
GREEN, // Green
TEAM_COLOR, // Red, grey, blue
GREY, // grey
RED, // Red
BLUE, // Blue
};
new TeamName[][] = {
"",
"TERRORIST",
"CT",
"SPECTATOR"
};
new s_Menu[] = "\yВип Меню^n^n\r1.\w Получить \d[\rM3\d] \d(1 раз в 2 раунда)^n\r2.\w Воскреситься \d(1 раз в 2 раунда)^n^n\r3. \wВзять 7000$ \d(1 раз в 4 раунда)^n^n\r0.\w Выход"
new rounddelay[33][10], mxplr
new items[][]=
{
"Дробовик М3",
"Воскрешение",
"Взять 7000$"
}
public plugin_init()
{
register_plugin("VipMenu", "1.0", "OleNb.")
register_cvar("acm_logfile", "0")
register_logevent("round_end", 2, "0=World triggered", "1=Round_End")
register_clcmd("vipmenu", "showMenu", ACCESS_FLAG, "Открыть VIP Меню")
register_clcmd("say /vm", "showMenu", ACCESS_FLAG, "Открыть VIP Меню")
register_menucmd(register_menuid("menu"), keys, "actionMenu")
mxplr = get_maxplayers()
register_event("DeathMsg", "eDeath", "a");
}
public client_connect( id ) {
usersilent[id] = 0;
}
public client_disconnect( id ) {
usersilent[id] = 0;
}
// User Death event
public eDeath( id ) {
new victem = read_data(2);
usersilent[victem] = 0;
}
public round_end()
{
static id, k
for(id = 0; id < mxplr; id++)
{
if(!is_user_connected(id))
continue
for(k = 0; k < 10;k++)
{
if(rounddelay[id][k] > 0)
{
rounddelay[id][k]--
}
}
}
}
public showMenu(id)
{
if( cs_get_user_team(id) != CS_TEAM_SPECTATOR )
if(get_user_flags(id) & ACCESS_FLAG)
{
show_menu(id, keys, s_Menu, -1, "menu")
}
else
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_SERVER, "ACCESS_MSG")
}
return PLUGIN_HANDLED
}
public actionMenu(id, key)
{
new user[32]
get_user_name(id, user, 31)
if(rounddelay[id][key] > 0)
{
ColorChat(id, RED, "[Вип Меню] ^x01Подождите ^x04%d ^x01раунд(а)", rounddelay[id][key])
return PLUGIN_HANDLED
}
switch(key)
{
case 0:
{
if(is_user_alive(id))
{
give_item(id, "weapon_m3")
cs_set_user_bpammo (id, CSW_M3, 32)
client_cmd(id, "vipmenu")
rounddelay[id][key] = 2
}
}
case 1:
{
ExecuteHam(Ham_CS_RoundRespawn, id)
rounddelay[id][key] = 2
client_cmd(id, "vipmenu")
}
case 2:
{
if(is_user_alive(id))
{
cs_set_user_money(id, cs_get_user_money(id) + 7000)
rounddelay[id][key] = 4
client_cmd(id, "vipmenu")
}
}
case 9:
{
return PLUGIN_HANDLED
}
}
if(key != 9)
{
//client_print(0, print_chat, "[Surf] VIP %s %s", user, items[key])
}
return PLUGIN_CONTINUE
}
public client_authorized(id)
{
client_cmd(id, "bind ^"F5^" ^"vipmenu^"")
}
public client_PreThink(id)
{
if(is_user_alive(id))
{
if(usersilent[id] == 1)
{
new oldbuttons = get_user_oldbutton(id);
oldbuttons &= ~IN_JUMP;
entity_set_int(id, EV_INT_oldbuttons, oldbuttons);
}
}
}
public respawn(id)
{
set_user_godmode(id, 0)
set_user_rendering(id, kRenderFxNone, 255, 255, 255, kRenderNormal, 16)
return PLUGIN_CONTINUE
}
// ColorChat - Start
ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...) {
new message[256];
switch(type) {
case NORMAL: message[0] = 0x01;
case GREEN: message[0] = 0x04;
default: message[0] = 0x03;
}
vformat(message[1], 251, msg, 4);
// Make sure message is not longer than 192 character. Will crash the server.
message[192] = '^0';
new team, ColorChange, index, MSG_Type;
if(id) {
MSG_Type = MSG_ONE;
index = id;
} else {
index = FindPlayer();
MSG_Type = MSG_ALL;
}
team = get_user_team(index);
ColorChange = ColorSelection(index, MSG_Type, type);
ShowColorMessage(index, MSG_Type, message);
if(ColorChange)
Team_Info(index, MSG_Type, TeamName[team]);
}
ShowColorMessage(id, type, message[]) {
static bool:saytext_used;
static get_user_msgid_saytext;
if(!saytext_used) {
get_user_msgid_saytext = get_user_msgid("SayText");
saytext_used = true;
}
message_begin(type, get_user_msgid_saytext, _, id);
write_byte(id);
write_string(message);
message_end();
}
Team_Info(id, type, team[]) {
static bool:teaminfo_used;
static get_user_msgid_teaminfo;
if(!teaminfo_used) {
get_user_msgid_teaminfo = get_user_msgid("TeamInfo");
teaminfo_used = true;
}
message_begin(type, get_user_msgid_teaminfo, _, id);
write_byte(id);
write_string(team);
message_end();
return 1;
}
ColorSelection(index, type, Color:Type) {
switch(Type) {
case RED: return Team_Info(index, type, TeamName[1]);
case BLUE: return Team_Info(index, type, TeamName[2]);
case GREY: return Team_Info(index, type, TeamName[0]);
}
return 0;
}
FindPlayer(){
new i = -1;
while(i <= get_maxplayers())
if(is_user_connected(++i))
return i;
return -1;
}