Код:
var buy_list_width = 200;
var buy_list_hide = Globals.Curtime() + 20;
UI.AddSliderInt(name_text + "_buy_list_x", 0,screen_size[0]);
UI.AddSliderInt(name_text + "_buy_list_y", 0,screen_size[1]);
UI.SetEnabled("Script items", name_text + "_buy_list_x", false);
UI.SetEnabled("Script items", name_text + "_buy_list_y", false);
var buy_list_x = UI.GetValue("Script items", name_text + "_buy_list_x") || screen_size[0] - buy_list_width;
var buy_list_y = UI.GetValue("Script items", name_text + "_buy_list_y") || (screen_size[1] / 2) - (list_height / 2);
var buys = {};
var weapon_icons = {
"weapon_deagle": "a",
"weapon_elite": "b",
"weapon_fiveseven": "c",
"weapon_glock": "d",
"weapon_ak47": "e",
"weapon_aug": "f",
"weapon_awp": "g",
"weapon_famas": "h",
"weapon_m249": "i",
"weapon_g3sg1": "j",
"weapon_galilar": "k",
"weapon_m4a1": "l",
"weapon_m4a1_silencer": "m",
"weapon_mac10": "n",
"weapon_hkp2000": "o",
"weapon_mp5sd": "p",
"weapon_ump45": "q",
"weapon_xm1014": "r",
"weapon_bizon": "s",
"weapon_mag7": "t",
"weapon_negev": "u",
"weapon_sawedoff": "v",
"weapon_tec9": "w",
"weapon_taser": "x",
"weapon_p250": "y",
"weapon_mp7": "z",
"weapon_mp9": "A",
"weapon_nova": "B",
"weapon_p90": "C",
"weapon_scar20": "D",
"weapon_sg556": "E",
"weapon_ssg08": "F",
"weapon_flashbang": "H",
"weapon_hegrenade": "I",
"weapon_smokegrenade": "J",
"weapon_molotov": "K",
"weapon_decoy": "L",
"weapon_incgrenade": "M",
"weapon_usp_silencer": "P",
"weapon_cz75a": "Q",
"weapon_revolver": "R",
"item_assaultsuit": "S",
"item_kevlar": "T",
"item_defuser": "U",
};
var needToClearBuylist = false;
var buy_list_hide = 0;
function buyList(){
if(!checkbox_states["buy_list"]) return;
local = Entity.GetLocalPlayer();
var gamerules = Entity.GetGameRulesProxy();
if(!local || !Entity.IsValid(local) && !UI.IsMenuOpen()) return;
if(Globals.Curtime() >= buy_list_hide && needToClearBuylist){
clearBuyList();
}
var add_height = 0;
Render.GradientRect(buy_list_x, buy_list_y, buy_list_width / 2, 2, 1, [218, 160, 87, 255], [255, 223, 150, 255]);
Render.GradientRect(buy_list_x + buy_list_width / 2, buy_list_y, buy_list_width / 2, 2, 1, [255, 223, 150, 255], [218, 160, 87, 255]);
Render.FilledRect(buy_list_x, buy_list_y + 2, buy_list_width, list_height - 2, [38, 40, 52, 90]);
list_font = Render.AddFont("Segoe UI", 8, 900);
var text_size = Render.TextSizeCustom("buy list", list_font);
renderShadowText(buy_list_x + (buy_list_width / 2) - (text_size[0] / 2), buy_list_y + 2, "buy list", list_text_color, list_font);
//Cheat.Print(Entity.GetProp(gamerules, "CCSGameRulesProxy", "m_bWarmupPeriod") + "\n");
//if(Entity.GetProp(gamerules, "CCSGameRulesProxy", "m_bWarmupPeriod") == "true") return;
var players = Object.keys(buys);
for(i = 0; i < players.length; i++){
var add_width = 0;
var name = rus_to_latin(Entity.GetName(Entity.GetEntityFromUserID(players[i])));
var name_size = Render.TextSizeCustom(name, list_font);
renderShadowText(buy_list_x + 3, buy_list_y + list_height + add_height, name, list_text_color, list_font);
for(a = 0; a < buys[players[i]].length; a++){
var weapon = buys[players[i]][a];
Render.String(buy_list_x + 2 + add_width, buy_list_y + list_height + add_height + 15, 0, weapon_icons[weapon], [0, 0, 0, 100], 5);
Render.String(buy_list_x + 1 + add_width, buy_list_y + list_height + add_height + 14, 0, weapon_icons[weapon], list_text_color, 5);
add_width += Render.TextSize(weapon_icons[weapon], 5)[0] - 1;
}
add_height += 32;
}
}
function moveBuyList(){
if(!checkbox_states["buy_list"]) return;
if(!UI.IsMenuOpen()) return;
if(is_moving) return;
cursor_pos = Input.GetCursorPosition();
if(!Input.IsKeyPressed(0x01)){
buy_list_is_moving = false;
buy_list_old_cursor = cursor_pos;
}
if((cursor_pos[0] >= buy_list_x && cursor_pos[0] <= buy_list_x + buy_list_width && cursor_pos[1] >= buy_list_y && cursor_pos[1] <= buy_list_y + list_height) || (buy_list_is_moving)){
buy_list_is_moving = true;
buy_list_x = clamp(cursor_pos[0] - buy_list_old_cursor[0] + buy_list_x, 0, screen_size[0] - buy_list_width);
buy_list_y = clamp(cursor_pos[1] - buy_list_old_cursor[1] + buy_list_y, 0, screen_size[1] - list_height);
buy_list_old_cursor = cursor_pos;
UI.SetValue("Script items", name_text + "_buy_list_x", buy_list_x);
UI.SetValue("Script items", name_text + "_buy_list_y", buy_list_y);
}
}
function addWeaponInBuyList(){
if(!checkbox_states["buy_list"]) return;
if(Event.GetInt("team") === Entity.GetProp(Entity.GetLocalPlayer(), "CBaseEntity", "m_iTeamNum")) return;
var weapon = Event.GetString("weapon");
var player = Event.GetInt("userid");
if(player in buys){
buys[player].push(weapon);
}
else{
buys[player] = [weapon];
}
}
function clearBuyList(){
buys = {};
needToClearBuylist = false;
}
function hideBuyList(){
needToClearBuylist = true;
buy_list_hide = Globals.Curtime() + parseInt(Convar.GetString("mp_buytime")/* - Convar.GetString("mp_freezetime")*/) + 5;
}