Проблема со шрифтом, поэтому оно может достигать просто невьъебических размеров
buy_list.js:
var logs = {};
var screen = Render.GetScreenSize();
var data = new Object();
var cache = [0, 0]; var drg = 0;
var anim = 0;
UI.AddSubTab(["Visuals", "SUBTAB_MGR"], "Buy List")
UI.AddSliderInt(["Visuals", "Buy List", "Buy List"], "Buy List | Position X", 1, screen[0])
UI.AddSliderInt(["Visuals", "Buy List", "Buy List"], "Buy List | Position Y", 1, screen[0])
UI.AddColorPicker(["Visuals", "Buy List", "Buy List"], "Buy List | Color"); UI.SetColor(["Visuals", "Buy List", "Buy List", "Buy List | Color"], [180, 180, 255, 255])
const Lerp = function(a, b, percentage) { return a + (b - a) * percentage };
const CursorBox = function(mouse_pos, x, y, x2, y2) { return (mouse_pos[0] > x) && (mouse_pos[1] > y) && (mouse_pos[0] < x2) && (mouse_pos[1] < y2) };
const Render_StringShadow = function(x, y, centered, text, color, font) {
Render.String(x + 1, y + 1, centered, text, [0, 0, 0, 255 * (anim / 255)], font)
Render.String(x, y, centered, text, color, font)
}
const Drag = function(pos, x, y, x2, y2) {
if(Input.IsKeyPressed(0x01)) {
if(CursorBox(pos, x, y, x2, y2) && drg == 0) {
cache[0] = x - pos[0]
cache[1] = y - pos[1]
drg = 1
}
}
if (!Input.IsKeyPressed(0x01)) drg = 0
if(UI.IsMenuOpen() > 0 && drg == 1) {
UI.SetValue(["Visuals", "Buy List", "Buy List", "Buy List | Position X"], pos[0] + cache[0])
UI.SetValue(["Visuals", "Buy List", "Buy List", "Buy List | Position Y"], pos[1] + cache[1])
}
}
const weapon_icons = {
// Pistols
"weapon_deagle": "A",
"weapon_elite": "B",
"weapon_fiveseven": "C",
"weapon_glock": "D",
"weapon_hkp2000": "E",
"weapon_p250": "F",
"weapon_usp_silencer": "G",
"weapon_tec9": "H",
"weapon_cz75a": "I",
"weapon_revolver": "J",
// Heavy
"weapon_xm1014": "b",
"weapon_sawedoff": "c",
"weapon_mag7": "d",
"weapon_nova": "e",
"weapon_negev": "f",
"weapon_m249": "g",
// SMG
"weapon_mac10": "K",
"weapon_ump45": "L",
"weapon_bizon": "M",
"weapon_mp7": "N",
"weapon_mp5sd": "L",
"weapon_mp9": "O",
"weapon_p90": "P",
// Rifles
"weapon_ak47": "W",
"weapon_aug": "U",
"weapon_awp": "g",
"weapon_famas": "R",
"weapon_galilar": "Q",
"weapon_m4a1": "S",
"weapon_m4a1_silencer": "T",
"weapon_g3sg1": "X",
"weapon_scar20": "Y",
"weapon_sg556": "V",
"weapon_ssg08": "a",
// Equipment
"item_kevlar": "q",
"item_assaultsuit": "r",
"weapon_taser": "i",
"item_defuser": "s",
// Grenade
"weapon_flashbang": "j",
"weapon_hegrenade": "k",
"weapon_smokegrenade": "l",
"weapon_molotov": "m",
"weapon_decoy": "n",
"weapon_incgrenade": "o",
};
const BuyLogs = function() {
// if(Event.GetInt('team') === Entity.GetProp(Entity.GetLocalPlayer(), "CBaseEntity", "m_iTeamNum")) return;
const item = Event.GetString('weapon');
const userID = Event.GetInt('userid');
const ent = Entity.GetEntityFromUserID(userID);
const name = Entity.GetName(ent);
if(!logs[userID]) logs[userID] = { name: name, weapons: [] }
logs[userID].weapons.push(weapon_icons[item]);
}
var size_x = 160;
var size_y = 17;
var time = Globals.Curtime();
const onDraw = function() {
if(!Entity.IsValid(Entity.GetLocalPlayer())) return;
if(time + 20 < Globals.Curtime()) {
logs = {};
size_y = 17;
}
var x = UI.GetValue(["Visuals", "Buy List", "Buy List", "Buy List | Position X"])
var y = UI.GetValue(["Visuals", "Buy List", "Buy List", "Buy List | Position Y"])
var Color = UI.GetColor(["Visuals", "Buy List", "Buy List", "Buy List | Color"])
var add_height = 0;
const font = Render.GetFont("Verdanab.ttf", 9, true);
const font_weapon = Render.GetFont("Undefeated.ttf", 11, true);
Render.FilledRect(x, y + 2, size_x, 9 + Object.keys(logs).length * 14, [0, 0, 0, 200 * (anim / 255)])
Render.FilledRect(x, y, size_x, 2, [Color[0], Color[1], Color[2], Color[3] * (anim / 255)])
for(player in logs) {
var add_width = 0;
const player = logs[player];
const name = player.name;
const weapons = player.weapons;
Render.String(x + 3, y + 5 + add_height, 0, name, [255, 255, 255, 255], font)
weapons.forEach(function(weapon, i) {
Render.String((x + 10 + Render.TextSize(name, font)[0]) + add_width + 5 * i, y + 5 + add_height, 0, weapon, [255, 255, 255, 255], font_weapon)
add_width += Render.TextSize(weapon, 5)[0] + 25;
if(add_width + 5 * i > size_x - 60) {
size_x = add_width + 5 * i + 90
}
})
add_height += 15
}
anim = Lerp(anim, (Object.keys(logs).length != 0 || UI.IsMenuOpen()) ? 255 : 0, 0.2)
Drag(Input.GetCursorPosition(), x, y, x + size_x, y + size_y)
}
const roundEnd = function() {
logs = {};
size_x = 160;
size_y = 17;
time = Globals.Curtime()
}
Cheat.RegisterCallback("Draw", "onDraw")
Global.RegisterCallback("item_purchase", "BuyLogs");
Global.RegisterCallback("round_end", "roundEnd");