mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-05 18:10:26 +01:00
Added time restriction for whereis command
- Added a time limit for whereis command - Added a notice sent to user whom position is querryed
This commit is contained in:
parent
400a5b01ea
commit
64a58936dd
|
@ -1,4 +1,5 @@
|
||||||
|
irc.whereis_timer = {}
|
||||||
|
irc.whereis_timer_max_limit = 120
|
||||||
irc.bot_commands = {}
|
irc.bot_commands = {}
|
||||||
|
|
||||||
function irc:check_botcmd(msg)
|
function irc:check_botcmd(msg)
|
||||||
|
@ -116,8 +117,18 @@ irc:register_bot_command("whereis", {
|
||||||
if not player then
|
if not player then
|
||||||
return false, "There is no player named '"..args.."'"
|
return false, "There is no player named '"..args.."'"
|
||||||
end
|
end
|
||||||
|
if irc.whereis_timer[user.nick] ~= nil then
|
||||||
|
local timer_player = os.difftime(os.time(),irc.whereis_timer[user.nick])
|
||||||
|
if timer_player < irc.whereis_timer_max_limit then
|
||||||
|
local answer = "Command used too often, retry in %d seconds."
|
||||||
|
return false,answer:format(irc.whereis_timer_max_limit - timer_player)
|
||||||
|
end
|
||||||
|
end
|
||||||
local fmt = "Player %s is at (%.2f,%.2f,%.2f)"
|
local fmt = "Player %s is at (%.2f,%.2f,%.2f)"
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
|
irc.whereis_timer[user.nick] = os.time()
|
||||||
|
minetest.log("action","IRC user ".. user.nick.."!"..user.username.."@"..user.host.." asked for position of player "..player:get_player_name())
|
||||||
|
minetest.chat_send_player(player:get_player_name(),"IRC user ".. user.nick.."!"..user.username.."@"..user.host.." asked for your position")
|
||||||
return true, fmt:format(args, pos.x, pos.y, pos.z)
|
return true, fmt:format(args, pos.x, pos.y, pos.z)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user