Skip to content

Commit 43a7e40

Browse files
committed
refactor(mainFunctions): Improve Account Create function
1 parent a251ced commit 43a7e40

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

Commands/Commands_Main.lua

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,29 @@ function GmClear()
327327
end
328328

329329
function AcctCreate()
330-
local param = ma_parameter:GetText()
331-
MangAdmin:ChatMsg(".account create "..param)
332-
MangAdmin:LogAction("Created account: "..param)
330+
local input = ma_parameter:GetText()
331+
local params = {}
332+
local fail = false
333+
for w in input:gmatch("%S+") do table.insert(params, w) end
334+
if(params[1] == nil or params[2] == nil) then
335+
print("|cffFF0000You must enter 2 parameters!|r")
336+
return
337+
end
338+
if (string.len(params[1]) <2 or string.len(params[1]) >12) then
339+
print("|cffFF0000" .. params[1] .."|r is not a valid username\n|cff00FF00Account username must be betweem 2 and 12 characters!|r")
340+
fail = true
341+
end
342+
if (string.len(params[2]) > 16 or string.len(params[2]) < 3) then
343+
print("|cffFF0000" .. params[2] .."|r is not a valid password\n|cff00FF00Account password must be betweem 3 and 16 characters!|r")
344+
fail = true
345+
end
346+
if(fail) then
347+
print("|cffFF0000Creation aborted!|r")
348+
return
349+
end
350+
MangAdmin:ChatMsg(".account create ".. params[1] .. " " .. params[2])
351+
print("|cff00FF00Account created successfully|r")
352+
MangAdmin:LogAction("Created account: ".. params[1] .. " " .. params[2])
333353
end
334354

335355
function AcctDelete()

0 commit comments

Comments
 (0)