Skip to content

Commit

Permalink
feat: add /deleteaccount command to delete player account
Browse files Browse the repository at this point in the history
  • Loading branch information
omarcopires committed Nov 21, 2024
1 parent 14ba662 commit 34e1f7a
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 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,28 @@ 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

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()

0 comments on commit 34e1f7a

Please sign in to comment.