mirror of
https://codeberg.org/AntumLuanti/mod-cleaner.git
synced 2025-03-21 15:41:22 +00:00
Check chat command radius parameter & limit max to 100
This commit is contained in:
parent
09d6475ce0
commit
95adf18f23
1 changed files with 37 additions and 0 deletions
37
chat.lua
37
chat.lua
|
@ -188,6 +188,23 @@ local function format_help(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function check_radius(radius, pname)
|
||||||
|
local is_admin = core.check_player_privs(pname, {server=true})
|
||||||
|
|
||||||
|
if not is_admin and radius > 10 then
|
||||||
|
radius = 10
|
||||||
|
return radius, S("You do not have permission to set radius that high. Reduced to @1.", radius)
|
||||||
|
end
|
||||||
|
|
||||||
|
if radius > 100 then
|
||||||
|
radius = 100
|
||||||
|
return radius, S("Radius is too high. Reduced to @1.", radius)
|
||||||
|
end
|
||||||
|
|
||||||
|
return radius
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Removes nearby entities.
|
--- Removes nearby entities.
|
||||||
--
|
--
|
||||||
-- @chatcmd remove_entities
|
-- @chatcmd remove_entities
|
||||||
|
@ -216,6 +233,11 @@ core.register_chatcommand(cmd_repo.entity.cmd, {
|
||||||
err = cmd_repo.param.mal_radius
|
err = cmd_repo.param.mal_radius
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local radius, msg = check_radius(radius, name)
|
||||||
|
if msg then
|
||||||
|
core.chat_send_player(name, msg)
|
||||||
|
end
|
||||||
|
|
||||||
if err then
|
if err then
|
||||||
return false, err .. "\n\n" .. format_help(cmd_repo.entity.cmd)
|
return false, err .. "\n\n" .. format_help(cmd_repo.entity.cmd)
|
||||||
end
|
end
|
||||||
|
@ -271,6 +293,11 @@ core.register_chatcommand(cmd_repo.rem_node.cmd, {
|
||||||
err = cmd_repo.param.mal_radius
|
err = cmd_repo.param.mal_radius
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local radius, msg = check_radius(radius, name)
|
||||||
|
if msg then
|
||||||
|
core.chat_send_player(name, msg)
|
||||||
|
end
|
||||||
|
|
||||||
if err then
|
if err then
|
||||||
return false, err .. "\n\n" .. format_help(cmd_repo.rem_node.cmd)
|
return false, err .. "\n\n" .. format_help(cmd_repo.rem_node.cmd)
|
||||||
end
|
end
|
||||||
|
@ -349,6 +376,11 @@ core.register_chatcommand(cmd_repo.rep_node.cmd, {
|
||||||
return false, cmd_repo.param.mal_radius .. "\n\n" .. help
|
return false, cmd_repo.param.mal_radius .. "\n\n" .. help
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local radius, msg = check_radius(radius, name)
|
||||||
|
if msg then
|
||||||
|
core.chat_send_player(name, msg)
|
||||||
|
end
|
||||||
|
|
||||||
if not core.registered_nodes[tgt] then
|
if not core.registered_nodes[tgt] then
|
||||||
return false, S('Cannot use unknown node "@1" as replacement.', tgt)
|
return false, S('Cannot use unknown node "@1" as replacement.', tgt)
|
||||||
end
|
end
|
||||||
|
@ -395,6 +427,11 @@ core.register_chatcommand(cmd_repo.find_node.cmd, {
|
||||||
return false, cmd_repo.param.mal_radius .. "\n\n" .. help
|
return false, cmd_repo.param.mal_radius .. "\n\n" .. help
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local radius, msg = check_radius(radius, name)
|
||||||
|
if msg then
|
||||||
|
core.chat_send_player(name, msg)
|
||||||
|
end
|
||||||
|
|
||||||
local ppos = core.get_player_by_name(name):get_pos()
|
local ppos = core.get_player_by_name(name):get_pos()
|
||||||
|
|
||||||
local checked_nodes = {}
|
local checked_nodes = {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue