1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-09-30 16:30:32 +02: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:
LeMagnesium 2015-03-28 17:35:26 +01:00
parent 400a5b01ea
commit 64a58936dd

View File

@ -1,4 +1,5 @@
irc.whereis_timer = {}
irc.whereis_timer_max_limit = 120
irc.bot_commands = {}
function irc:check_botcmd(msg)
@ -116,8 +117,18 @@ irc:register_bot_command("whereis", {
if not player then
return false, "There is no player named '"..args.."'"
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 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)
end
})