0% found this document useful (0 votes)
18 views5 pages

Figurine Card Bot

The document describes functions for a script that allows automatically promoting or muting players in VRChat based on names or IDs entered by an admin. It provides buttons for admins to add players, edit settings, and view currently seated or promoted players. The script saves entered data and settings on exit.

Uploaded by

wslewis72
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views5 pages

Figurine Card Bot

The document describes functions for a script that allows automatically promoting or muting players in VRChat based on names or IDs entered by an admin. It provides buttons for admins to add players, edit settings, and view currently seated or promoted players. The script saves entered data and settings on exit.

Uploaded by

wslewis72
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

-- Created By Flolania, Please donate :)

-- Thanks to A Polar Bear for testing.

function onLoad(save_state)
self.clearButtons()
Data = {
[1] = '',
[2] = false,
}
MutedPlayers = {}
if save_state ~= nil and save_state ~= "" then
Data = JSON.decode(save_state)
self.setTable('Data', Data)
self.setDescription(Data[1])
ClickedDone = true
self.createButton({label = 'Edit', click_function = 'Edit', rotation = {0,
270, 0},
position = {0.3, 0.1, 0}, width = 500, height = 140, font_size = 100,
function_owner = self})
else
self.setDescription('')
self.createButton({label = 'Start', click_function = 'Start', rotation =
{0, 270, 0},
position = {-2, 0, 0}, width = 1500, height = 550, font_size = 300,
function_owner = self})
end
end

function onSave()
data = self.getTable('Data')
if data[1] == '' then return end
save_state = JSON.encode(self.getTable('Data'))
return save_state
end

--- A Polar Bear returns a polar Bear


function update ()
if ClickedDone == true then
Data = self.getTable('Data')
for i, People in ipairs(Player.getSpectators()) do
for Names in string.gmatch(Data[1], '[^\r\n]+') do
if People.promoted == false and People.admin == false then
if People.steam_name == Names or People.steam_id == Names then
if People.steam_name == People.steam_id then
People.kick()
else
People.promote()
MuteOverRide = true
end
else
if self.getTable('Data')[2] == true then
isMute = false
for t, Muted in ipairs(MutedPlayers) do
if People.steam_name == Muted then
isMute = true
end
end
if isMute == false and MuteOverRide == false then
table.insert(MutedPlayers, People.steam_name)
People.mute()
MuteOverRide = false
end
end
end
end
end
end
for i, colors in ipairs(getSeatedPlayers()) do
for Names in string.gmatch(Data[1], '[^\r\n]+') do
if getPlayer(colors).promoted == false and getPlayer(colors).admin
== false then
if getPlayer(colors).steam_name == Names or
getPlayer(colors).steam_id == Names then
getPlayer(colors).promote()
end
end
end
end
end
end

function ColorCheck(playerColor)
if Player[playerColor].admin == true then
return true
else
return false
end
end

function Edit(object,playerColor)
if ColorCheck(playerColor) == false then return end
ClickedDone = false
self.clearButtons()
self.createButton({label = 'Done', click_function = 'Done', rotation = {0, 270,
0},
position = {2, 0, 0}, width = 1500, height = 550, font_size = 300,
function_owner = self})

local Data = self.getTable('Data')


if Data[2] == true then
self.createButton({label = 'Spectators are muted', click_function = 'Mute',
rotation = {0, 270, 0},
position = {1, 0, 0}, width = 1500, height = 300, font_size = 100,
function_owner = self})
else
self.createButton({label = 'Spectators are not muted', click_function =
'Mute', rotation = {0, 270, 0},
position = {1, 0, 0}, width = 1500, height = 300, font_size = 100,
function_owner = self})
end

self.createButton({label = 'Steam ID', click_function = 'Steam_ID', rotation =


{0, 270, 0},
position = {-1, 0, 0}, width = 1500, height = 550, font_size = 300,
function_owner = self})

end
function Steam_ID(object, playerColor)
if ColorCheck(playerColor) == false then return end
for i, colors in ipairs(getSeatedPlayers()) do
print(getPlayer(colors).steam_name .. ' has ID: ' ..
getPlayer(colors).steam_id)
end

end

function Done(object,playerColor)

if self.getDescription() ~= '' then


ClickedDone = true
Data = self.getTable('Data')
Data[1] = self.getDescription()
self.setTable('Data', Data)
self.clearButtons()
self.createButton({label = 'Edit', click_function = 'Edit', rotation = {0,
270, 0},
position = {0.3, 0.1, 0}, width = 500, height = 140, font_size = 100,
function_owner = self})
else
broadcastToAll('Please read game chat on how to use.', {1,0,1})
end
end

function Start(object,playerColor)
if ColorCheck(playerColor) == false then return end
broadcastToAll('Read game chat on how to use AUTO PROMOTE.', {0,1,0})
printToAll('1. Right-click on object and select description with mouse.',
{1,0,1})
printToAll('2. Enter names or ids of players you wish to auto promote or use
side buttons.', {1,0,1})
printToAll('3. Make sure names or ids are exact copies and each name is on its
own line.', {1,0,1})
printToAll('4. Once all names or ids are entered, click DONE to lock the names
or ids in.', {1,0,1})
self.clearButtons()

self.createButton({label = 'Done', click_function = 'Done', rotation = {0, 270,


0},
position = {2, 0, 0}, width = 1500, height = 550, font_size = 300,
function_owner = self})

self.createButton({label = 'All Currently Seated', click_function =


'AllSeated', rotation = {0, 270, 0},
position = {0, 0, 3}, width = 1700, height = 550, font_size = 150,
function_owner = self})

self.createButton({label = 'All Currently Promoted', click_function =


'AllPromoted', rotation = {0, 270, 0},
position = {0, 0, -3}, width = 1700, height = 550, font_size = 150,
function_owner = self})

self.createButton({label = 'Spectators are not muted', click_function = 'Mute',


rotation = {0, 270, 0},
position = {1, 0, 0}, width = 1500, height = 300, font_size = 100,
function_owner = self})
self.createButton({label = 'Steam ID', click_function = 'Steam_ID', rotation =
{0, 270, 0},
position = {-1, 0, 0}, width = 1500, height = 550, font_size = 300,
function_owner = self})

end

function Mute(object, playerColor)


if ColorCheck(playerColor) == false then return end

local index = 0
local label = ''
local buttons = object.getButtons()
for i, but in ipairs(buttons) do
if but.click_function == 'Mute' then
index = but.index
label = but.label
end
end
local Data = self.getTable('Data')
local button_parameters = {}
if label == 'Spectators are not muted' then
button_parameters.label = 'Spectators are muted'
printToAll('Only the host is allowed to unmute. This will not mute people
on the list.', {1,0,1})
printToAll('This will not mute currently seated players.', {1,0,1})
Data[2] = true
else
button_parameters.label = 'Spectators are not muted'
Data[2] = false
end
button_parameters.index = index
self.setTable('Data', Data)
object.editButton(button_parameters)
end

function AllPromoted(object,playerColor)
if ColorCheck(playerColor) == false then return end
AddPlayers(object, 1)
end

function AllSeated(object,playerColor)
if ColorCheck(playerColor) == false then return end
AddPlayers(object, 2)

end

function AddPlayers(object, type)


Names = object.getDescription()
for i, People in ipairs(getSeatedPlayers()) do
add = false
if (Player[People].promoted == true or Player[People].host == true) and
type == 1 then
add = true
end
if add == true or type == 2 then
if Names == '' then
Names = Player[People].steam_name
else
Names = Names .. '\n' .. Player[People].steam_name
end
end
end
object.setDescription(Names)
object.removeButton(1)
object.removeButton(2)
end

You might also like