Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new plugin Server-VoteKick.luau #47

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions Server/Server-VoteKick.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
return function(Vargs)
local server, service = Vargs.Server, Vargs.Service
local Remote, Logs = server.Remote, server.Logs

server.Commands.VoteKick = {
Prefix = server.Settings.Prefix;
Commands = {"votekick"};
Args = {"Player", "Reason"};
Description = "Votekick a player to be kicked";
Hidden = false;
Fun = false;
AdminLevel = "Players";
Function = function(plr,args)
assert(args[1], "You need to specifiy a player to vote kick")

if #server.Functions.GetPlayers(plr, args[1], {NoFakePlayer = true}) > 1 then
assert(false, "You cannot vote more than one player at a time")
end

local responses = {}

for i, v in service.GetPlayers(plr, "all") do
task.spawn(function()
local response = Remote.GetGui(v, "Vote", {
Question = `Vote kick {server.Functions.GetPlayers(plr, args[1], {NoFakePlayer = true})[1]}? Reason: {args[2] or "No reason provided."}`;
Answers = {"Yes", "No"};
})
if response then
table.insert(responses, response)
end
end)
end

task.spawn(function()
task.wait(30)

local Yes = 0
local No = 0

for i, v in responses do
if v == "Yes" then
Yes += 1
elseif v == "No" then
No += 1
end
end

local Player = server.Functions.GetPlayers(plr, args[1])[1]

if Yes > No then
if Player then
Player:Kick(`Vote kicked. Reason: {args[2] or "No reason provided."}`)
Logs:AddLog("Script", `{Player.Name} was votekicked. Reason: {args[2] or "No reason provided."}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would recommend service.FormatPlayer(Player) over Player.Name.

end
server.Functions.Notify("Vote kick", `{Player.Name} was vote kicked.`, {plr})
else
server.Functions.Notify("Vote kick", `{Player.Name} was not vote kicked.`, {plr})
end
end)
end
}
end