dobrograd-13-06-2022/garrysmod/addons/admin-sg/lua/plugins/votes/cl_init.lua
Jonny_Bro (Nikita) e4d5311906 first commit
2023-11-16 15:01:19 +05:00

41 lines
No EOL
1 KiB
Lua

--[[
© 2017 Thriving Ventures Limited do not share, re-distribute or modify
without permission of its author (gustaf@thrivingventures.com).
]]
local plugin = plugin;
plugin:IncludeFile("shared.lua", SERVERGUARD.STATE.CLIENT);
plugin:IncludeFile("sh_commands.lua", SERVERGUARD.STATE.CLIENT);
plugin:IncludeFile("cl_panel.lua", SERVERGUARD.STATE.CLIENT);
plugin:Hook("PlayerBindPress", "votes.PlayerBindPress", function(player, bind, pressed)
if (plugin.vote) then
local option = tonumber(bind:match("slot(%d)"));
if (option and plugin.vote.options[option]) then
serverguard.netstream.Start("CastVote", option);
plugin.vote = nil;
if (IsValid(plugin.panel)) then
plugin.panel.checkboxes[option]:SetChecked(true);
plugin.panel:FadeOut();
end;
return true;
end;
end;
end);
serverguard.netstream.Hook("CreateVote", function(data)
plugin.vote = data;
plugin.panel = vgui.Create("tiger.panel.vote");
timer.Simple(15, function()
if (IsValid(plugin.panel)) then
plugin.panel:FadeOut();
end;
end);
end);