mirror of
https://github.com/minetest-mods/xban2.git
synced 2025-01-09 11:30:18 +01:00
parent
974b47f8f6
commit
63e3600352
12
init.lua
12
init.lua
@ -73,6 +73,9 @@ end
|
|||||||
|
|
||||||
function xban.ban_player(player, source, expires, reason) --> bool, err
|
function xban.ban_player(player, source, expires, reason) --> bool, err
|
||||||
local e = xban.find_entry(player, true)
|
local e = xban.find_entry(player, true)
|
||||||
|
if e.banned then
|
||||||
|
return nil, "Already banned"
|
||||||
|
end
|
||||||
local rec = {
|
local rec = {
|
||||||
source = source,
|
source = source,
|
||||||
time = os.time(),
|
time = os.time(),
|
||||||
@ -195,8 +198,8 @@ minetest.register_chatcommand("xban", {
|
|||||||
if not (plname and reason) then
|
if not (plname and reason) then
|
||||||
return false, "Usage: /xban <player> <reason>"
|
return false, "Usage: /xban <player> <reason>"
|
||||||
end
|
end
|
||||||
xban.ban_player(plname, name, nil, reason)
|
local ok, e = xban.ban_player(plname, name, nil, reason)
|
||||||
return true, ("Banned %s."):format(plname)
|
return ok, ok and ("Banned %s."):format(plname) or e
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -214,8 +217,9 @@ minetest.register_chatcommand("xtempban", {
|
|||||||
return false, "You must ban for at least 60 seconds."
|
return false, "You must ban for at least 60 seconds."
|
||||||
end
|
end
|
||||||
local expires = os.time() + time
|
local expires = os.time() + time
|
||||||
xban.ban_player(plname, name, expires, reason)
|
local ok, e = xban.ban_player(plname, name, expires, reason)
|
||||||
return true, ("Banned %s until %s."):format(plname, os.date("%c", expires))
|
return ok, (ok and ("Banned %s until %s."):format(
|
||||||
|
plname, os.date("%c", expires)) or e)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user