addCommandHandler("secure",
function (player)
local serial = getPlayerSerial(player)
if not isGuestAccount (getPlayerAccount(player)) then
local acc = getAccountName(getPlayerAccount(player))
setAccountData(getPlayerAccount(player),"secured","true")
setAccountData(getPlayerAccount(player),"ows",serial)
outputChatBox("* Your account '"..acc.."' now is secured.",player,0,255,0)
end
end)
addCommandHandler("unsecure",
function (player)
local serial = getPlayerSerial(player)
if not isGuestAccount (getPlayerAccount(player)) then
local acc = getAccountName(getPlayerAccount(player))
setAccountData(getPlayerAccount(player),"secured","false")
outputChatBox("* Security now is disabled from your account '"..acc.."'.",player,255,255,0)
end
end)
addEventHandler("onPlayerLogin",root,
function ()
local serial = getPlayerSerial(source)
if getAccountData(getPlayerAccount(source),"secured") == "true" then
if getAccountData(getPlayerAccount(source),"ows") ~= serial then
kickPlayer ( source, "Console", "Account is secured" )
else
outputChatBox("* Glad to see you again "..getPlayerNameClean(source).." ",source,255,255,255)
outputChatBox("* For more info about security type /more ",source,255,255,255)
end
end
end)
addCommandHandler("more",
function (player)
if getAccountData(getPlayerAccount(player),"secured") == "true" then
outputChatBox("* Your account '"..getAccountName(getPlayerAccount(player)).."' is secured.",player,0,255,0)
outputChatBox("* This means that no one except you can use it.",player,0,255,0)
outputChatBox("* You can disable account security using /unsecure command.",player,255,255,0)
end
end)
addCommandHandler("kme",
function (player)
kickPlayer ( player, "Console", "Account is secured" )
end)
function getPlayerNameClean(player)
local name = getPlayerName(player)
if name:find("#%x%x%x%x%x%x") then
name = name:gsub("#%x%x%x%x%x%x","")
return name
else
return name
end
end