• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

NPC [MySQL] Account Manager

mattos123

New Member
Joined
Sep 28, 2011
Messages
16
Best answers
0
Reaction score
2
felt the need to do this
PHP:
<?xml version="1.0"?>

<npc name="Account Manager" script="data/npc/scripts/accmaker.lua" access="3" walkinterval="2000" lookdir="2">
<mana now="800" max="800"/>
<health now="200" max="200"/>
<look type="110" head="1" body="1" legs="1" feet="1" addons="0"/>
</npc>[/code]

Now create a file on data/npcs/scripts called accmaker.lua and paste this:
[code=lua]local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

npcHandler:setMessage(MESSAGE_GREET, "Hello, type {account} to create a new account, {character} to add a new character or {manage} to see all available features.")

local config =
{
newPlayerChooseVoc = getConfigValue("newPlayerChooseVoc"),
newPlayerSpawnPosX = getConfigValue("newPlayerSpawnPosX"),
newPlayerSpawnPosY = getConfigValue("newPlayerSpawnPosY"),
newPlayerSpawnPosZ = getConfigValue("newPlayerSpawnPosZ"),
newPlayerTownId = getConfigValue("newPlayerTownId"),
newPlayerLevel = getConfigValue("newPlayerLevel"),
newPlayerMagicLevel = getConfigValue("newPlayerMagicLevel"),
generateAccountNumber = getConfigValue("generateAccountNumber")
}

local account =
{
name = {},
pass = {}
}

local character =
{
name = {},
voc = {},
sex = {}
}
local toBe = 0
local capMax = 400
local voc =
{
["sorcerer"] = 1,
["druid"] = 2,
["paladin"] = 3,
["knight"] = 4
}
function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
if msgcontains(msg, "account") then
npcHandler:say("What would you like your password to be?", cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if msg ~= "" or msg ~= nil then
toBe = string.gsub(msg, "[!'·#$%&/()=?¿¡.*\|;:,><{}]", "")
npcHandler:say(toBe .. " is it {yes} or {no}?", cid)
talkState[talkUser] = 2
else
npcHandler:say("What would you like your password to be?", cid)
end
elseif talkState[talkUser] == 2 and msgcontains(msg, "no") then
npcHandler:say("What would you like your password to be?", cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 2 and msgcontains(msg, "yes") then
account.pass[cid] = toBe
if config.generateAccountNumber then
toBe = string.format("%s%s%s%s%s%s%s", math.random(1, 9), math.random(1, 9), math.random(1, 9), math.random(1, 9), math.random(1, 9), math.random(1, 9), math.random(1, 9))
local query = db.getResult("select id from accounts where name = " .. toBe .. ";")
if query:getID() == -1 then
account.name[cid] = toBe
local query_ = db.executeQuery("insert into accounts (name, password) values (" .. db.escapeString(account.name[cid]) .. ", " .. db.escapeString(account.pass[cid]) .. ");")
if query_ then
npcHandler:say("Your account has been created, you may {manage} it now, but remember your account name: {" .. account.name[cid] .. "} and password: {" .. account.pass[cid] .. "}!", cid)
talkState[talkUser] = 0
else
npcHandler:say("Your account cannot be created.", cid)
talkState[talkUser] = 0
end
end
else
npcHandler:say("What would you like your account name to be?", cid)
talkState[talkUser] = 3
end
elseif talkState[talkUser] == 3 then
if msg ~= "" or msg ~= nil then
toBe = string.gsub(msg, "[!·#$%&¬/()=?'¿¡.*\|;:,><{}]", "")
if toBe == account.pass[cid] then
npcHandler:say("Your account name cannot be the same as your password.", cid)
talkState[talkUser] = 3
else
npcHandler:say(toBe .. " is it {yes} or {no}?", cid)
talkState[talkUser] = 4
end
else
npcHandler:say("What would you like your account name to be?", cid)
end
elseif talkState[talkUser] == 4 and msgcontains(msg, "no") then
npcHandler:say("Od... then what would you like your account name to be?", cid)
talkState[talkUser] = 3
elseif talkState[talkUser] == 4 and msgcontains(msg, "yes") then
local query = db.getResult("select id from accounts where name = " .. db.escapeString(toBe) .. ";")
local deny = false
if query:getID() ~= -1 then
deny = true
query:free()
end
if deny then
npcHandler:say("An account with that name already exists, please try another account name.", cid)
talkState[talkUser] = 3
else
account.name[cid] = toBe
local query = db.executeQuery("insert into accounts (name, password) values (" .. db.escapeString(account.name[cid]) .. ", " .. db.escapeString(account.pass[cid]) .. ");")
if query then
npcHandler:say("Your account has been created, you may {manage} it now, but remember your account name: {" .. account.name[cid] .. "} and password: {" .. account.pass[cid] .. "}!", cid)
talkState[talkUser] = 0
else
npcHandler:say("Your account cannot be created.", cid)
talkState[talkUser] = 0
end
end
elseif msgcontains(msg, "manage") then
account.name[cid] = (account.name[cid] or getPlayerAccount(cid))
local query = db.getResult("select password from accounts where name = " .. db.escapeString(account.name[cid]) .. ";")
if query:getID() ~= -1 then
account.pass[cid] = (account.pass[cid] or query:getDataString("password"))
query:free()
end
npcHandler:say("You can {change} your pass or create a new {character}.", cid)
talkState[talkUser] = 5
elseif msgcontains(msg, "change") then
npcHandler:say("Tell me your new password please.", cid)
talkState[talkUser] = 6
elseif talkState[talkUser] == 6 then
if msg ~= "" or msg ~= nil then
toBe = string.gsub(msg, "[!'·#$%&/()=?¿¡.*\|;:,><{}]", "")
if string.len(toBe) < 6 then
npcHandler:say("That password is too short, at least 6 digits are required. Please select a longer password.", cid)
else
npcHandler:say("Should {" .. toBe .. "} be your new password?", cid)
talkState[talkUser] = 7
end
else
npcHandler:say("What would you like your new password to be?", cid)
end
elseif talkState[talkUser] == 7 and msgcontains(msg, "no") then
npcHandler:say("Then not.", cid)
talkState[talkUser] = 0
elseif talkState[talkUser] == 7 and msgcontains(msg, "yes") then
local query = db.executeQuery("update accounts set password = " .. db.escapeString(toBe) .. " where name = " .. db.escapeString(getPlayerAccount(cid)).. ";")
if query then
npcHandler:say("Your password has been changed.", cid)
talkState[talkUser] = 0
else
npcHandler:say("Your password cannot be changed.", cid)
talkState[talkUser] = 0
end
elseif msgcontains(msg, "character") then
local query = db.getResult("select count(id) as count from players where account_id = " .. getPlayerAccountId(cid) .. ";")
if query:getID() ~= -1 then
local t = query:getDataInt("count")
if t >= 15 then
npcHandler:say("Your account reach the limit of 15 players, you need delete a character if you want to create a new one.", cid)
talkState[talkUser] = 0
else
npcHandler:say("What would you like as your character name?", cid)
talkState[talkUser] = 8
end
query:free()
end
elseif talkState[talkUser] == 8 then
if msg ~= "" or msg ~= nil then
toBe = string.gsub(msg, "[!'·#$%&/()=?¿¡.*\|;:,><{}]", "")
if string.len(toBe) < 4 then
npcHandler:say("Your name you want is too short, please select a longer name.", cid)
elseif string.len(toBe) > 20 then
npcHandler:say("Your name you want is too long, please select a longer name.", cid)
elseif string.sub(toBe, 0, 4) == "god " or isInArray({"gm ", "cm "}, string.sub(toBe, 0, 3)) then
npcHandler:say("Your character is not a staff member, please tell me another name!", cid)
elseif string.sub(toBe, 0, 1) == string.sub(toBe, 0, 1):lower() then
npcHandler:say("Your name can not be the first letter in lower case.", cid)
else
local query = db.getResult("select id from players where name = " .. db.escapeString(toBe) .. ";")
if query:getID() ~= - 1 then
npcHandler:say("A player with that name already exists, please choose another name.", cid)
query:free()
else
npcHandler:say(toBe .. " is it {yes} or {no}?", cid)
talkState[talkUser] = 9
end
end
else
npcHandler:say("What would you like as your character name?", cid)
end
elseif talkState[talkUser] == 9 and msgcontains(msg, "no") then
npcHandler:say("What else would you like to name your character?", cid)
talkState[talkUser] = 8
elseif talkState[talkUser] == 9 and msgcontains(msg, "yes") then
character.name[cid] = toBe
npcHandler:say("Should your character be a {male} or a {female}.", cid)
talkState[talkUser] = 10
elseif talkState[talkUser] == 10 and msgcontains(msg, "male") or msgcontains(msg, "female") then
toBe = (msg == "male" and 1 or 0)
npcHandler:say("A " .. msg .. ", are you sure?", cid)
talkState[talkUser] = 11
elseif talkState[talkUser] == 11 and msgcontains(msg, "no") then
npcHandler:say("Tell me... would you like to be a {male} or a {female}?", cid)
talkState[talkUser] = 10
elseif talkState[talkUser] == 11 and msgcontains(msg, "yes") then
character.sex[cid] = toBe
if config.newPlayerChooseVoc then
npcHandler:say("What do you want to be... {sorcerer}, {druid}, {paladin} or {knight}.", cid)
talkState[talkUser] = 12
else
character.voc[cid] = 0
local query = db.executeQuery("insert into players (id, name, world_id, group_id, account_id, level, vocation, health, healthmax, experience, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, maglevel, mana, manamax, manaspent, soul, town_id, posx, posy, posz, conditions, cap, sex, lastlogin, lastip, skull, skulltime, save, rank_id, guildnick, lastlogout, blessings, online) VALUES (NULL, " .. db.escapeString(character.name[cid]) .. ", " .. getConfigValue("worldId") .. ", 1, " .. getAccountIdByAccount(account.name[cid]) .. ", " .. config.newPlayerLevel .. ", " .. character.voc[cid] .. ", " .. getVocationInfo(character.voc[cid]).healthGain * config.newPlayerLevel .. ", " .. getVocationInfo(character.voc[cid]).healthGain * config.newPlayerLevel .. ", " .. (config.newPlayerLevel < 2 and 0 or getExperienceForLevel(config.newPlayerLevel)) .. ", 68, 76, 78, 39, " .. (character.sex[cid] == 1 and 136 or 128) .. ", 0, " .. config.newPlayerMagicLevel .. ", 0, 0, 0, 100, " .. config.newPlayerTownId .. ", " .. config.newPlayerSpawnPosX .. ", " .. config.newPlayerSpawnPosY .. ", " .. config.newPlayerSpawnPosZ .. ", 0, " .. capMax + getVocationInfo(character.voc[cid]).capacity * config.newPlayerLevel .. ", " .. character.sex[cid] .. ", 0, 0, 0, 0, 1, 0, '', 0, 0, 0);")
if query then
npcHandler:say("Your character has been created.", cid)
talkState[talkUser] = 0
else
npcHandler:say("Your character couldn't be created, please try again.", cid)
talkState[talkUser] = 5
end
end
elseif talkState[talkUser] == 12 then
if voc[msg] then
npcHandler:say("So you would like to be " .. msg .. "... are you sure?", cid)
toBe = voc[msg]
talkState[talkUser] = 13
else
npcHandler:say("I don't understand what vocation you would like to be... could you please repeat it?", cid)
end
elseif talkState[talkUser] == 13 and msgcontains(msg, "no") then
npcHandler:say("No? Then what would you like to be?", cid)
talkState[talkUser] = 12
elseif talkState[talkUser] == 13 and msgcontains(msg, "yes") then
character.voc[cid] = toBe
local query = db.executeQuery("insert into players (id, name, world_id, group_id, account_id, level, vocation, health, healthmax, experience, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, maglevel, mana, manamax, manaspent, soul, town_id, posx, posy, posz, conditions, cap, sex, lastlogin, lastip, skull, skulltime, save, rank_id, guildnick, lastlogout, blessings, online) VALUES (NULL, " .. db.escapeString(character.name[cid]) .. ", " .. getConfigValue("worldId") .. ", 1, " .. getAccountIdByAccount(account.name[cid]) .. ", " .. config.newPlayerLevel .. ", " .. character.voc[cid] .. ", " .. getVocationInfo(character.voc[cid]).healthGain * config.newPlayerLevel .. ", " .. getVocationInfo(character.voc[cid]).healthGain * config.newPlayerLevel .. ", " .. (config.newPlayerLevel < 2 and 0 or getExperienceForLevel(config.newPlayerLevel)) .. ", 68, 76, 78, 39, " .. (character.sex[cid] == 1 and 136 or 128) .. ", 0, " .. config.newPlayerMagicLevel .. ", 0, 0, 0, 100, " .. config.newPlayerTownId .. ", " .. config.newPlayerSpawnPosX .. ", " .. config.newPlayerSpawnPosY .. ", " .. config.newPlayerSpawnPosZ .. ", 0, " .. capMax + getVocationInfo(character.voc[cid]).capacity * config.newPlayerLevel .. ", " .. character.sex[cid] .. ", 0, 0, 0, 0, 1, 0, '', 0, 0, 0);")
if query then
npcHandler:say("Your character has been created.", cid)
talkState[talkUser] = 0
else
npcHandler:say("Your character couldn't be created, please try again.", cid)
talkState[talkUser] = 5
end
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 

Zatjin

Advanced OT User
Joined
Sep 18, 2011
Messages
2,219
Best answers
0
Reaction score
191
Location
Norway
You felt the need to bump a 4 year old thread regarding an account manager?
 

manic91

New Member
Joined
Dec 2, 2012
Messages
6
Best answers
0
Reaction score
0
cant get it to work.. dosnt let me get in..
:/
 

salisbury

New Member
Joined
Sep 6, 2010
Messages
3
Best answers
0
Reaction score
0
Bumping an oldie.

Im trying to create a character, but once I choose vocation and type yes, it says "05:49 Account Manager: A player with this name already exists, please choose another name."

It was happening before when I tried choosing a character name, so I put a new account manager script in and now it starts happening when I get to vocation, any ideas?

This is on a brand new server I have just made
 

Tazza

New Member
Joined
Jul 16, 2019
Messages
2
Best answers
0
Reaction score
0
Hello, this is a request from narko, you can see it here -> [Request] [NPC] Account Maker (acc and player) or ideas to make it (http://otland.net/f132/request-npc-account-maker-acc-player-ideas-make-107556/)

  • Updated At: Wednesday December 08th, 2010 at 21:36 P.M (GMT -4:30)
  • Last Tested At: Wednesday December 08th, 2010 at 21:34 P.M (GMT -4:30)
  • Tested On: The Forgotten Server 0.3.6pl1


Update Log:
Code:
[B]V0.1.1: [08 / 12 / 2010][/B]
- Now the plauer name cannot be too long.
[B]V0.1: [08 / 12 / 2010][/B]
- Release of the new script
Features:
Code:
[LIST]
[*]Player can create a new account.
[*]Player can change the/him account password. (If you say "change" before creating a new account, you'll change the created account's password)
[*]Player can create a new character on the/him account. (If you create a new character before creating a new account, you'll create a character on the new account)
[*]All npc messages almost the account manager.
[*]You can't type character/account/password with invalid characters.
[*]You can't create a character with the first letter on lower case.
[*]You can't create a new character if your account has reached the character's limit (15)
[*]You can't create a new character if the name contains "gm", "cm" or "god".
[*]You can't create account/password/character if the text is too short.
[*]You can't create an account name if is the same as the password.
[/LIST]
-- Same restriction as account manager.
--- Coming features (Delete character, new recovery key)
Create a new npc file on data/npcs and paste this (Default):
XML:
<?xml version="1.0"?>

<npc name="Account Manager" script="data/npc/scripts/accmaker.lua" access="3" walkinterval="2000" lookdir="2">
    <mana now="800" max="800"/>
    <health now="200" max="200"/>
<look type="110" head="1" body="1" legs="1" feet="1" addons="0"/>
</npc>
Now create a file on data/npcs/scripts called accmaker.lua and paste this:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                          npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)                  npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                                      npcHandler:onThink() end

npcHandler:setMessage(MESSAGE_GREET, "Hello, type {account} to create a new account, {character} to add a new character or {manage} to see all available features.")

local config =
{
    newPlayerChooseVoc = getConfigValue("newPlayerChooseVoc"),
    newPlayerSpawnPosX = getConfigValue("newPlayerSpawnPosX"),
    newPlayerSpawnPosY = getConfigValue("newPlayerSpawnPosY"),
    newPlayerSpawnPosZ = getConfigValue("newPlayerSpawnPosZ"),
    newPlayerTownId = getConfigValue("newPlayerTownId"),
    newPlayerLevel = getConfigValue("newPlayerLevel"),
    newPlayerMagicLevel = getConfigValue("newPlayerMagicLevel"),
    generateAccountNumber = getConfigValue("generateAccountNumber")
}

local account =
{
    name = {},
    pass = {}
}

local character =
{
    name = {},
    voc = {},
    sex = {}
}
local toBe = 0
local capMax = 400
local voc =
{
    ["sorcerer"] = 1,
    ["druid"] = 2,
    ["paladin"] = 3,
    ["knight"] = 4
}
function creatureSayCallback(cid, type, msg)

    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
    if msgcontains(msg, "account") then
        npcHandler:say("What would you like your password to be?", cid)
        talkState[talkUser] = 1
    elseif talkState[talkUser] == 1 then
        if msg ~= "" or msg ~= nil then
            toBe = string.gsub(msg, "[!'·#$%&/()=?¿¡.*\|;:,><{}]", "")
            npcHandler:say(toBe .. " is it {yes} or {no}?", cid)
            talkState[talkUser] = 2
        else
            npcHandler:say("What would you like your password to be?", cid)
        end
    elseif talkState[talkUser] == 2 and msgcontains(msg, "no") then
        npcHandler:say("What would you like your password to be?", cid)
        talkState[talkUser] = 1
    elseif talkState[talkUser] == 2 and msgcontains(msg, "yes") then
        account.pass[cid] = toBe
        if config.generateAccountNumber then
            toBe = string.format("%s%s%s%s%s%s%s", math.random(1, 9), math.random(1, 9), math.random(1, 9), math.random(1, 9), math.random(1, 9), math.random(1, 9), math.random(1, 9))
            local query = db.getResult("select id from accounts where name = " .. toBe .. ";")
            if query:getID() == -1 then
                account.name[cid] = toBe
                local query_ = db.executeQuery("insert into accounts (name, password) values (" .. db.escapeString(account.name[cid]) .. ", " .. db.escapeString(account.pass[cid]) .. ");")
                if query_ then
                    npcHandler:say("Your account has been created, you may {manage} it now, but remember your account name: {" .. account.name[cid] .. "} and password: {" .. account.pass[cid] .. "}!", cid)
                    talkState[talkUser] = 0
                else
                    npcHandler:say("Your account cannot be created.", cid)
                    talkState[talkUser] = 0
                end
            end
        else
            npcHandler:say("What would you like your account name to be?", cid)
            talkState[talkUser] = 3
        end
    elseif talkState[talkUser] == 3 then
        if msg ~= "" or msg ~= nil then
            toBe = string.gsub(msg, "[!·#$%&¬/()=?'¿¡.*\|;:,><{}]", "")
            if toBe == account.pass[cid] then
                npcHandler:say("Your account name cannot be the same as your password.", cid)
                talkState[talkUser] = 3
            else
                npcHandler:say(toBe .. " is it {yes} or {no}?", cid)
                talkState[talkUser] = 4
            end
        else
            npcHandler:say("What would you like your account name to be?", cid)
        end
    elseif talkState[talkUser] == 4 and msgcontains(msg, "no") then
        npcHandler:say("Od... then what would you like your account name to be?", cid)
        talkState[talkUser] = 3
    elseif talkState[talkUser] == 4 and msgcontains(msg, "yes") then
        local query = db.getResult("select id from accounts where name = " .. db.escapeString(toBe) .. ";")
        local deny = false
        if query:getID() ~= -1 then
            deny = true
            query:free()
        end
        if deny then
            npcHandler:say("An account with that name already exists, please try another account name.", cid)
            talkState[talkUser] = 3
        else
            account.name[cid] = toBe
            local query = db.executeQuery("insert into accounts (name, password) values (" .. db.escapeString(account.name[cid]) .. ", " .. db.escapeString(account.pass[cid]) .. ");")
            if query then
                npcHandler:say("Your account has been created, you may {manage} it now, but remember your account name: {" .. account.name[cid] .. "} and password: {" .. account.pass[cid] .. "}!", cid)
                talkState[talkUser] = 0
            else
                npcHandler:say("Your account cannot be created.", cid)
                talkState[talkUser] = 0
            end
        end
    elseif msgcontains(msg, "manage") then
        account.name[cid] = (account.name[cid] or getPlayerAccount(cid))
        local query = db.getResult("select password from accounts where name = " .. db.escapeString(account.name[cid]) .. ";")
        if query:getID() ~= -1 then
            account.pass[cid] = (account.pass[cid] or query:getDataString("password"))
            query:free()
        end
        npcHandler:say("You can {change} your pass or create a new {character}.", cid)
        talkState[talkUser] = 5
    elseif msgcontains(msg, "change") then
        npcHandler:say("Tell me your new password please.", cid)
        talkState[talkUser] = 6
    elseif talkState[talkUser] == 6 then
        if msg ~= "" or msg ~= nil then
            toBe = string.gsub(msg, "[!'·#$%&/()=?¿¡.*\|;:,><{}]", "")
            if string.len(toBe) < 6 then
                npcHandler:say("That password is too short, at least 6 digits are required. Please select a longer password.", cid)
            else
                npcHandler:say("Should {" .. toBe .. "} be your new password?", cid)
                talkState[talkUser] = 7
            end
        else
            npcHandler:say("What would you like your new password to be?", cid)
        end
    elseif talkState[talkUser] == 7 and msgcontains(msg, "no") then
        npcHandler:say("Then not.", cid)
        talkState[talkUser] = 0
    elseif talkState[talkUser] == 7 and msgcontains(msg, "yes") then
        local query = db.executeQuery("update accounts set password = " .. db.escapeString(toBe) .. " where name = " .. db.escapeString(getPlayerAccount(cid)).. ";")
        if query then
            npcHandler:say("Your password has been changed.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Your password cannot be changed.", cid)
            talkState[talkUser] = 0
        end
    elseif msgcontains(msg, "character") then
        local query = db.getResult("select count(id) as count from players where account_id = " .. getPlayerAccountId(cid) .. ";")
        if query:getID() ~= -1 then
            local t = query:getDataInt("count")
            if t >= 15 then
                npcHandler:say("Your account reach the limit of 15 players, you need delete a character if you want to create a new one.", cid)
                talkState[talkUser] = 0
            else
                npcHandler:say("What would you like as your character name?", cid)
                talkState[talkUser] = 8
            end
            query:free()
        end
    elseif talkState[talkUser] == 8 then
        if msg ~= "" or msg ~= nil then
            toBe = string.gsub(msg, "[!'·#$%&/()=?¿¡.*\|;:,><{}]", "")
            if string.len(toBe) < 4 then
                npcHandler:say("Your name you want is too short, please select a longer name.", cid)
            elseif string.len(toBe) > 20 then
                npcHandler:say("Your name you want is too long, please select a longer name.", cid)
            elseif string.sub(toBe, 0, 4) == "god " or isInArray({"gm ", "cm "}, string.sub(toBe, 0, 3)) then
                npcHandler:say("Your character is not a staff member, please tell me another name!", cid)
            elseif string.sub(toBe, 0, 1) == string.sub(toBe, 0, 1):lower() then
                npcHandler:say("Your name can not be the first letter in lower case.", cid)
            else
                local query = db.getResult("select id from players where name = " .. db.escapeString(toBe) .. ";")
                if query:getID() ~= - 1 then
                    npcHandler:say("A player with that name already exists, please choose another name.", cid)
                    query:free()
                else
                    npcHandler:say(toBe .. " is it {yes} or {no}?", cid)
                    talkState[talkUser] = 9
                end
            end
        else
            npcHandler:say("What would you like as your character name?", cid)
        end
    elseif talkState[talkUser] == 9 and msgcontains(msg, "no") then
        npcHandler:say("What else would you like to name your character?", cid)
        talkState[talkUser] = 8
    elseif talkState[talkUser] == 9 and msgcontains(msg, "yes") then
        character.name[cid] = toBe
        npcHandler:say("Should your character be a {male} or a {female}.", cid)
        talkState[talkUser] = 10
    elseif talkState[talkUser] == 10 and msgcontains(msg, "male") or msgcontains(msg, "female") then
        toBe = (msg == "male" and 1 or 0)
        npcHandler:say("A " .. msg .. ", are you sure?", cid)
        talkState[talkUser] = 11
    elseif talkState[talkUser] == 11 and msgcontains(msg, "no") then
        npcHandler:say("Tell me... would you like to be a {male} or a {female}?", cid)
        talkState[talkUser] = 10
    elseif talkState[talkUser] == 11 and msgcontains(msg, "yes") then
        character.sex[cid] = toBe
        if config.newPlayerChooseVoc then
            npcHandler:say("What do you want to be... {sorcerer}, {druid}, {paladin} or {knight}.", cid)
            talkState[talkUser] = 12
        else
            character.voc[cid] = 0
            local query = db.executeQuery("insert into players (id, name, world_id, group_id, account_id, level, vocation, health, healthmax, experience, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, maglevel, mana, manamax, manaspent, soul, town_id, posx, posy, posz, conditions, cap, sex, lastlogin, lastip, skull, skulltime, save, rank_id, guildnick, lastlogout, blessings, online) VALUES (NULL, " .. db.escapeString(character.name[cid]) .. ", " .. getConfigValue("worldId") .. ", 1, " .. getAccountIdByAccount(account.name[cid]) .. ", " .. config.newPlayerLevel .. ", " .. character.voc[cid] .. ", " .. getVocationInfo(character.voc[cid]).healthGain * config.newPlayerLevel .. ", " .. getVocationInfo(character.voc[cid]).healthGain * config.newPlayerLevel .. ", " .. (config.newPlayerLevel < 2 and 0 or getExperienceForLevel(config.newPlayerLevel)) .. ", 68, 76, 78, 39, " .. (character.sex[cid] == 1 and 136 or 128) .. ", 0, " .. config.newPlayerMagicLevel .. ", 0, 0, 0, 100, " .. config.newPlayerTownId .. ", " .. config.newPlayerSpawnPosX .. ", " .. config.newPlayerSpawnPosY .. ", " .. config.newPlayerSpawnPosZ .. ", 0, " .. capMax + getVocationInfo(character.voc[cid]).capacity * config.newPlayerLevel .. ", " .. character.sex[cid] .. ", 0, 0, 0, 0, 1, 0, '', 0, 0, 0);")
            if query then
                npcHandler:say("Your character has been created.", cid)
                talkState[talkUser] = 0
            else
                npcHandler:say("Your character couldn't be created, please try again.", cid)
                talkState[talkUser] = 5
            end
        end
    elseif talkState[talkUser] == 12 then
        if voc[msg] then
            npcHandler:say("So you would like to be " .. msg .. "... are you sure?", cid)
            toBe = voc[msg]
            talkState[talkUser] = 13
        else
            npcHandler:say("I don't understand what vocation you would like to be... could you please repeat it?", cid)
        end
    elseif talkState[talkUser] == 13 and msgcontains(msg, "no") then
        npcHandler:say("No? Then what would you like to be?", cid)
        talkState[talkUser] = 12
    elseif talkState[talkUser] == 13 and msgcontains(msg, "yes") then
        character.voc[cid] = toBe
        local query = db.executeQuery("insert into players (id, name, world_id, group_id, account_id, level, vocation, health, healthmax, experience, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, maglevel, mana, manamax, manaspent, soul, town_id, posx, posy, posz, conditions, cap, sex, lastlogin, lastip, skull, skulltime, save, rank_id, guildnick, lastlogout, blessings, online) VALUES (NULL, " .. db.escapeString(character.name[cid]) .. ", " .. getConfigValue("worldId") .. ", 1, " .. getAccountIdByAccount(account.name[cid]) .. ", " .. config.newPlayerLevel .. ", " .. character.voc[cid] .. ", " .. getVocationInfo(character.voc[cid]).healthGain * config.newPlayerLevel .. ", " .. getVocationInfo(character.voc[cid]).healthGain * config.newPlayerLevel .. ", " .. (config.newPlayerLevel < 2 and 0 or getExperienceForLevel(config.newPlayerLevel)) .. ", 68, 76, 78, 39, " .. (character.sex[cid] == 1 and 136 or 128) .. ", 0, " .. config.newPlayerMagicLevel .. ", 0, 0, 0, 100, " .. config.newPlayerTownId .. ", " .. config.newPlayerSpawnPosX .. ", " .. config.newPlayerSpawnPosY .. ", " .. config.newPlayerSpawnPosZ .. ", 0, " .. capMax + getVocationInfo(character.voc[cid]).capacity * config.newPlayerLevel .. ", " .. character.sex[cid] .. ", 0, 0, 0, 0, 1, 0, '', 0, 0, 0);")
        if query then
            npcHandler:say("Your character has been created.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Your character couldn't be created, please try again.", cid)
            talkState[talkUser] = 5
        end
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

i have created a character but i cant find it or account manager in my files, does anyone know where i can find?
 
Top