Skip to content

Commit

Permalink
Lua code format - (Stylua)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed May 25, 2024
1 parent 1940fd9 commit 4a5a0f9
Showing 1 changed file with 22 additions and 35 deletions.
57 changes: 22 additions & 35 deletions data/scripts/talkactions/player/cast_system.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ function talkaction.onSay(player, words, param)
local split = param:splitTrimmed(",")
local data = player:getCastViewers()

if table.contains({"help"}, split[1]) then
if table.contains({ "help" }, split[1]) then
player:popupFYI(table.concat(helpMessages, "\n"))

elseif table.contains({"off", "no", "disable"}, split[1]) then
elseif table.contains({ "off", "no", "disable" }, split[1]) then
if not data.broadcast then
player:sendTextMessage(MESSAGE_STATUS, "You already have the live stream closed.")
return true
Expand All @@ -39,12 +38,11 @@ function talkaction.onSay(player, words, param)
db.query("UPDATE `active_casters` SET `cast_status` = 0, `cast_viewers` = 0 WHERE `caster_id` = " .. player:getGuid())
player:sendTextMessage(MESSAGE_STATUS, "Your stream is currently disabled.")
if experienceMultiplier > 0 then
player:sendTextMessage(MESSAGE_LOOK, "Experience bonus deactivated: -" ..experienceMultiplier.. "%")
player:sendTextMessage(MESSAGE_LOOK, "Experience bonus deactivated: -" .. experienceMultiplier .. "%")
player:kv():scoped("cast-system"):remove("experience-bonus")
end
playersCasting[player:getGuid()] = nil

elseif table.contains({"on", "yes", "enable"}, split[1]) then
elseif table.contains({ "on", "yes", "enable" }, split[1]) then
if data.broadcast then
player:sendTextMessage(MESSAGE_STATUS, "You already have the live stream open.")
return true
Expand All @@ -53,13 +51,12 @@ function talkaction.onSay(player, words, param)
player:sendTextMessage(MESSAGE_STATUS, "You have started live broadcast.")
db.query("INSERT INTO `active_casters` (`caster_id`, `cast_status`) VALUES (" .. player:getGuid() .. ", 1) ON DUPLICATE KEY UPDATE `cast_status` = 1")
if experienceMultiplier and experienceMultiplier > 0 then
player:sendTextMessage(MESSAGE_LOOK, "Experience bonus actived: +" ..experienceMultiplier.. "%")
player:sendTextMessage(MESSAGE_LOOK, "Experience bonus actived: +" .. experienceMultiplier .. "%")
player:kv():scoped("cast-system"):set("experience-bonus", true)
end
playersCasting[player:getGuid()] = true
player:setExhaustion("cast-system-exhaustion", 20)

elseif table.contains({"show", "count", "see"}, split[1]) then
elseif table.contains({ "show", "count", "see" }, split[1]) then
if data.broadcast then
local count = table.maxn(data.names)
if count > 0 then
Expand All @@ -76,8 +73,7 @@ function talkaction.onSay(player, words, param)
else
player:sendTextMessage(MESSAGE_STATUS, "You are not streaming right now.")
end

elseif table.contains({"kick", "remove"}, split[1]) then
elseif table.contains({ "kick", "remove" }, split[1]) then
if data.broadcast then
if split[2] then
if split[2] ~= "all" then
Expand Down Expand Up @@ -105,8 +101,7 @@ function talkaction.onSay(player, words, param)
else
player:sendTextMessage(MESSAGE_STATUS, "You are not streaming right now.")
end

elseif table.contains({"ban", "block"}, split[1]) then
elseif table.contains({ "ban", "block" }, split[1]) then
if data.broadcast then
if split[2] then
local found = false
Expand All @@ -129,13 +124,12 @@ function talkaction.onSay(player, words, param)
else
player:sendTextMessage(MESSAGE_STATUS, "You are not streaming right now.")
end

elseif table.contains({"unban", "unblock"}, split[1]) then
elseif table.contains({ "unban", "unblock" }, split[1]) then
if data.broadcast then
if split[2] then
local found, i = 0, 1
for _, name in ipairs(data.bans) do
if(split[2]:lower() == name:lower()) then
if split[2]:lower() == name:lower() then
found = i
break
end
Expand All @@ -156,8 +150,7 @@ function talkaction.onSay(player, words, param)
else
player:sendTextMessage(MESSAGE_STATUS, "You are not streaming right now.")
end

elseif table.contains({"bans", "banlist"}, split[1]) then
elseif table.contains({ "bans", "banlist" }, split[1]) then
if table.maxn(data.bans) then
local str = ""
for _, name in ipairs(data.bans) do
Expand All @@ -168,8 +161,7 @@ function talkaction.onSay(player, words, param)
else
player:sendTextMessage(MESSAGE_STATUS, "Your ban list is empty.")
end

elseif table.contains({"mute", "squelch"}, split[1]) then
elseif table.contains({ "mute", "squelch" }, split[1]) then
if data.broadcast then
if split[2] then
local found = false
Expand All @@ -193,8 +185,7 @@ function talkaction.onSay(player, words, param)
else
player:sendTextMessage(MESSAGE_STATUS, "You are not streaming right now.")
end

elseif table.contains({"unmute", "unsquelch"}, split[1]) then
elseif table.contains({ "unmute", "unsquelch" }, split[1]) then
if data.broadcast then
if split[2] then
local found, i = 0, 1
Expand All @@ -220,8 +211,7 @@ function talkaction.onSay(player, words, param)
else
player:sendTextMessage(MESSAGE_STATUS, "You are not streaming right now.")
end

elseif table.contains({"mutes", "mutelist"}, split[1]) then
elseif table.contains({ "mutes", "mutelist" }, split[1]) then
if table.maxn(data.mutes) then
local str = ""
for _, name in ipairs(data.mutes) do
Expand All @@ -232,18 +222,17 @@ function talkaction.onSay(player, words, param)
else
player:sendTextMessage(MESSAGE_STATUS, "Your mute list is empty.")
end

elseif table.contains({"password", "guard"}, split[1]) then
elseif table.contains({ "password", "guard" }, split[1]) then
if split[2] then
if table.contains({"off", "no", "disable"}, split[2]) then
if table.contains({ "off", "no", "disable" }, split[2]) then
if data.password:len() ~= 0 then
db.query("UPDATE `active_casters` SET `cast_status` = 1 WHERE `caster_id` = " .. player:getGuid())
end

player:kv():scoped("cast-system"):remove("password")
player:sendTextMessage(MESSAGE_STATUS, "You have removed password for your stream.")
if experienceMultiplier > 0 then
player:sendTextMessage(MESSAGE_LOOK, "Your experience bonus of : " ..experienceMultiplier.. "% was reactivated.")
player:sendTextMessage(MESSAGE_LOOK, "Your experience bonus of : " .. experienceMultiplier .. "% was reactivated.")
player:kv():scoped("cast-system"):set("experience-bonus", true)
end
else
Expand All @@ -253,7 +242,7 @@ function talkaction.onSay(player, words, param)
end
player:sendTextMessage(MESSAGE_STATUS, "You have set new password for your stream.")
if experienceMultiplier > 0 then
player:sendTextMessage(MESSAGE_LOOK, "Your experience bonus of : " ..experienceMultiplier.. "% was deactivated.")
player:sendTextMessage(MESSAGE_LOOK, "Your experience bonus of : " .. experienceMultiplier .. "% was deactivated.")
player:kv():scoped("cast-system"):remove("experience-bonus")
end
player:kv():scoped("cast-system"):set("password", data.password)
Expand All @@ -263,11 +252,10 @@ function talkaction.onSay(player, words, param)
else
player:sendTextMessage(MESSAGE_STATUS, "Your stream is currently not protected.")
end

elseif table.contains({"desc", "description"}, split[1]) then
elseif table.contains({ "desc", "description" }, split[1]) then
if split[2] then
-- print(split[2])
if table.contains({"remove", "delete"}, split[2]) then
if table.contains({ "remove", "delete" }, split[2]) then
player:kv():scoped("cast-system"):remove("description")
player:sendTextMessage(MESSAGE_STATUS, "You have removed description for your stream.")
else
Expand All @@ -281,13 +269,12 @@ function talkaction.onSay(player, words, param)
player:sendTextMessage(MESSAGE_STATUS, "Your description max lenght 50 characters.")
return false
end
player:sendTextMessage(MESSAGE_STATUS, "Cast description was set to: ".. split[2] ..".")
player:sendTextMessage(MESSAGE_STATUS, "Cast description was set to: " .. split[2] .. ".")
end
else
player:sendTextMessage(MESSAGE_STATUS, "Please enter your description or if you want to remove your description type remove.")
end

elseif table.contains({"status", "info"}, split[1]) then
elseif table.contains({ "status", "info" }, split[1]) then
player:sendTextMessage(MESSAGE_STATUS, "Your stream is currently " .. (data.broadcast and "enabled" or "disabled") .. ".")
else
player:popupFYI(table.concat(helpMessages, "\n"))
Expand Down

0 comments on commit 4a5a0f9

Please sign in to comment.