Skip to content

Commit

Permalink
MicroOptimizations & forcesay
Browse files Browse the repository at this point in the history
  • Loading branch information
bleonheart committed Oct 12, 2024
1 parent b69cede commit dadc3ec
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lilia/gamemode/core/libraries/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end
function lia.util.FindPlayersInSphere(origin, radius)
local plys = {}
local r2 = radius ^ 2
for _, client in ipairs(player.GetAll()) do
for _, client in player.Iterator() do
if client:GetPos():DistToSqr(origin) <= r2 then plys[#plys + 1] = client end
end
return plys
Expand Down
2 changes: 1 addition & 1 deletion lilia/gamemode/core/meta/entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ end
-- @realm shared
-- @tparam[opt=96] number radius The radius within which to check for nearby entities.
-- @treturn bool True if there is an entity nearby, false otherwise.
function entityMeta:nearEntity(radius)
function entityMeta:isNearEntity(radius)
for _, v in ipairs(ents.FindInSphere(self:GetPos(), radius or 96)) do
if v:GetClass() == self then return true end
end
Expand Down
7 changes: 7 additions & 0 deletions lilia/modules/core/permissions/commands/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,11 @@ lia.command.add("botsay", {
syntax = "<string botName> <string message>",
privilege = "Bot Say",
onRun = function() end
})

lia.command.add("forcesay", {
superAdminOnly = true,
syntax = "<string botName> <string message>",
privilege = "Force Say",
onRun = function() end
})
15 changes: 13 additions & 2 deletions lilia/modules/core/permissions/commands/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ lia.command.add("globalbotsay", {
return
end

for _, bot in ipairs(player.GetAll()) do
for _, bot in player.Iterator() do
if bot:IsBot() then bot:Say(message) end
end
end
Expand All @@ -1201,7 +1201,7 @@ lia.command.add("botsay", {
local botName = arguments[1]
local message = table.concat(arguments, " ", 2)
local targetBot
for _, bot in ipairs(player.GetAll()) do
for _, bot in player.Iterator() do
if bot:IsBot() and string.find(string.lower(bot:Nick()), string.lower(botName)) then
targetBot = bot
break
Expand All @@ -1215,4 +1215,15 @@ lia.command.add("botsay", {

targetBot:Say(message)
end
})

lia.command.add("forcesay", {
superAdminOnly = true,
syntax = "<string botName> <string message>",
privilege = "Force Say",
onRun = function(client, arguments)
local target = lia.command.findPlayer(client, arguments[1])
local message = table.concat(arguments, " ", 2)
target:Say(message)
end
})
4 changes: 2 additions & 2 deletions lilia/modules/core/permissions/libraries/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ function GM:PlayerSpawnedVehicle(client, entity)
end

concommand.Add("kickbots", function()
for _, bot in ipairs(player.GetBots()) do
bot:Kick("All bots kicked")
for _, bot in player.Iterator() do
if bot:IsBot() then bot:Kick("All bots kicked") end
end
end)

Expand Down

0 comments on commit dadc3ec

Please sign in to comment.