Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add /deleteaccount command to delete player account #4847

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions data/scripts/talkactions/ban.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function ipban.onSay(player, words, param)
result.free(resultId)

if targetIp == "0" then
player:sendTextMessage(MESSAGE_STATUS_WARNING, string.format("Invalid IP for player %s.", targetName))
player:sendCancelMessage(string.format("Invalid IP for player %s.", targetName))
return true
end

Expand Down Expand Up @@ -107,7 +107,7 @@ local unban = TalkAction("/unban")

function unban.onSay(player, words, param)
if param == "" then
player:sendTextMessage(MESSAGE_STATUS_WARNING, "Command requires 1 parameter: /unban <player name>")
player:sendCancelMessage("Command requires 1 parameter: /unban <player name>")
return true
end

Expand All @@ -130,3 +130,33 @@ end
unban:access(true)
unban:separator(" ")
unban:register()

local deleteAccount = TalkAction("/deleteaccount")

function deleteAccount.onSay(player, words, param)
if param == "" then
player:sendCancelMessage("Command requires 1 parameter: /deleteaccount <player name>")
return true
end

local targetName = param:trim()
local accountId = Game.getPlayerAccountId(targetName)

if accountId == 0 then
return true
end

local target = Player(targetName)
if target then
target:remove()
end

db.query("DELETE FROM `accounts` WHERE `id` = " .. accountId)

player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("The account of %s has been deleted.", targetName))
return true
end

deleteAccount:access(true)
deleteAccount:separator(" ")
deleteAccount:register()
Loading