diff --git a/data/scripts/talkactions/ban.lua b/data/scripts/talkactions/ban.lua index f91853c050..39ff4319a6 100644 --- a/data/scripts/talkactions/ban.lua +++ b/data/scripts/talkactions/ban.lua @@ -1,6 +1,6 @@ -local talk = TalkAction("/ban") +local ban = TalkAction("/ban") -function talk.onSay(player, words, param) +function ban.onSay(player, words, param) if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GAMEMASTER then return true end @@ -45,6 +45,36 @@ function talk.onSay(player, words, param) return true end -talk:separator(" ") -talk:groupType("gamemaster") -talk:register() +ban:separator(" ") +ban:register() + +local unban = TalkAction("/unban") + +function unban.onSay(player, words, param) + if not player:getGroup():getAccess() then + return true + end + + if param == "" then + player:sendTextMessage(MESSAGE_STATUS_WARNING, "Command requires 1 parameter: /unban ") + return true + end + + local resultId = db.storeQuery("SELECT `account_id`, `lastip` FROM `players` WHERE `name` = " .. db.escapeString(param)) + if not resultId then + return true + end + + local accountId = result.getNumber(resultId, "account_id") + local lastIp = result.getString(resultId, "lastip") + result.free(resultId) + + db.asyncQuery("DELETE FROM `account_bans` WHERE `account_id` = " .. db.escapeString(tostring(accountId))) + db.asyncQuery("DELETE FROM `ip_bans` WHERE `ip` = " .. db.escapeString(lastIp)) + + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, param .. " has been unbanned.") + return true +end + +unban:separator(" ") +unban:register() diff --git a/data/talkactions/scripts/unban.lua b/data/talkactions/scripts/unban.lua deleted file mode 100644 index 7e47f4d347..0000000000 --- a/data/talkactions/scripts/unban.lua +++ /dev/null @@ -1,16 +0,0 @@ -function onSay(player, words, param) - if not player:getGroup():getAccess() then - return true - end - - local resultId = db.storeQuery("SELECT `account_id`, `lastip` FROM `players` WHERE `name` = " .. db.escapeString(param)) - if not resultId then - return false - end - - db.asyncQuery("DELETE FROM `account_bans` WHERE `account_id` = " .. result.getNumber(resultId, "account_id")) - db.asyncQuery("DELETE FROM `ip_bans` WHERE `ip` = " .. result.getNumber(resultId, "lastip")) - result.free(resultId) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, param .. " has been unbanned.") - return false -end diff --git a/data/talkactions/talkactions.xml b/data/talkactions/talkactions.xml index fd89ea6125..4d99b9e221 100644 --- a/data/talkactions/talkactions.xml +++ b/data/talkactions/talkactions.xml @@ -3,7 +3,6 @@ -