Postado Julho 8, 2015 9 anos Estou criando um servidor do naruto do zero e estou usando o ot 7.9 do tibia como base para isso, até agora consegui me virar sozinho porém na hora de criar minha conta, o Account Manager não registra meu Nickname na pasta Data (Players e Accounts), no distro aparece que o erro é: attempt to global 'io' <a nil value> (segue as imagens e o code abaixo). Distro (exe): Pasta players do server 7.81 (De onde tirei o código, que funfa normalmente. O erro do nickname se dá na 7.9): Pasta players do server 7.9 do tibia que estou editando (Onde surgiu o arquivo players.xml): Onde o código dá erro (provavelmente deve haver um código que registre o player no players.xml como mostrado na img acima): elseif accstatus == 2 then myname = origmsg mynamecheck = msg if string.len(mynamecheck) <= maxnamelen then if string.find(mynamecheck, allow_pattern) then if io.open("data/players/"..myname..".xml" , "r") == nil then selfSay('Will you use '..myname..' as your name ?') accstatus = 3 else selfSay('Seu nome já está usado, escolha outro.') end Código completo (funcionando no 7.81): ---little config----------------------------------------- templex = 49 templey = 42 templez = 7 maxnamelen = 18 maxpasslen = 14 startlvl = 1 startexp = 0 vocations = 0 healthstart = 150 manastart = 0 depoitemid = 3440 promoted = 0 ---------skills------------------------- --knight------- kmlvl = 0 kfist = 10 kclub = 10 ksword = 10 kaxe = 10 kdist = 10 kshield = 10 kfish = 0 kcap = 300 --pall------------ pmlvl = 0 pfist = 10 pclub = 10 psword = 10 paxe = 10 pdist = 10 pshield = 10 pfish = 0 pcap = 400 ---drut i sorc---- mmlvl = 0 mfist = 10 mclub = 10 msword = 10 maxe = 10 mdist = 10 mshield = 10 mfish = 0 mcap = 400 ---end skills ------------------------------- --~Tr0p5 (20% and players.xml) ---end little config----------------------------------------- focus = 0 talk_start = 0 target = 0 following = false attacking = false accstatus = 0 seksik = 3 myname = '' mypass = '' allow_pattern = '^[a-zA-Z -]+$' allow_pattern2 = '^[a-zA-Z0-9 -]+$' origmsg = '' mypasscheck = '' mynamecheck = '' vocation = 0 function onThingMove(creature, thing, oldpos, oldstackpos) end function onCreatureAppear(creature) end function onCreatureDisappear(cid, pos) if focus == cid then selfSay('Good bye then.') focus = 0 talk_start = 0 end end function onCreatureTurn(creature) end function msgcontains(txt, str) return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)')) end function onCreatureSay(cid, type, msg) origmsg = msg msg = string.lower(msg) if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 then selfSay('Ola, bem vindo ao Dream Naruto! Sou o npc que crio accounts. Você é homem ou mulher?') accstatus = 1 myname = '' mypass = '' myaccnumber = 0 focus = cid talk_start = os.clock() elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then selfSay('Espere..') elseif focus == cid then talk_start = os.clock() if accstatus == 1 then if msgcontains(msg, 'homem') then selfSay('Qual é seu nome?') seksik = 28 outfit = 171 accstatus = 2 elseif msgcontains(msg, 'mulher') then selfSay('Qual é seu nome?') seksik = 0 outfit = 189 accstatus = 2 end elseif accstatus == 66 then if msgcontains(msg, 'yes') then vocation = 0 selfSay('Now, we\'ll make your account. So, let\'s start?') elseif msgcontains(msg, 'asdsdf') then vocation = 0 selfSay('The dangerous magic casting sorcerer?') elseif msgcontains(msg, 'asdpois') then vocation = 0 selfSay('The magical warrior of nature?') elseif msgcontains(msg, 'coiusiotuyd') then vocation = 0 selfSay('The heavy built warrior?') else selfSay('Spell properly.') end accstatus = 67 elseif accstatus == 2 then myname = origmsg mynamecheck = msg if string.len(mynamecheck) <= maxnamelen then if string.find(mynamecheck, allow_pattern) then if io.open("data/players/"..myname..".xml" , "r") == nil then selfSay('Will you use '..myname..' as your name ?') accstatus = 3 else selfSay('Seu nome já está usado, escolha outro.') end else selfSay('seu nome é ilegal.') end else selfSay('Seu nome está muito longo.') end elseif msgcontains(msg, 'yes') then if accstatus == 3 then if vocations == 0 then selfSay('Ok, fale sua senha.') vocation = 0 accstatus = 4 else selfSay('You\'ll be a student, right?') accstatus = 66 end elseif accstatus == 5 then if seksik == 0 then selfSay('Perfeito! Você é uma mulher chamada: '..myname..' sua senha é: '..mypass..'. Certo?') else selfSay('Perfeito! Você é um homem chamado: '..myname..' sua senha é: '..mypass..'. Certo?') end accstatus = 6 elseif accstatus == 6 then selfSay('Ok, agora vamos ver sua account. Diga "pronto" para continuar.') accstatus = 7 elseif accstatus == 67 then selfSay('Fale-me sua senha.') accstatus = 4 end elseif msgcontains(msg, 'not') then if accstatus == 3 then selfSay('Choose another.') accstatus = 2 elseif accstatus == 5 then selfSay('Choose another.') accstatus = 4 elseif accstatus == 6 then selfSay('Start again, tell me your gender') accstatus = 1 elseif accstatus == 67 then selfSay('Are you able to be a Student?') accstatus = 66 end elseif accstatus == 4 then mypass = origmsg mypasscheck = msg if string.len(mypasscheck) <= maxpasslen then if string.find(mypasscheck, allow_pattern2) then selfSay('Sua senha é '..mypass..' certo?') accstatus = 5 else selfSay('Ilegal.') end else selfSay('Too long.') end elseif msgcontains(msg, 'pronto') and accstatus == 7 then if manastart == 0 then manastartc = 1 else manastartc = manastart end if healthstart == 0 then healthstartc = 1 else healthstartc = healthstart end if vocations == 0 then mlvl = 1 fist = 10 club = 10 sword = 10 axe = 10 dist = 10 shield = 10 fish = 10 cap = 100 else if vocation == 3 or vocation == 4 then mlvl = mmlvl fist = mfist club = mclub sword = msword axe = maxe dist = mdist shield = mshield fish = mfish cap = mcap elseif vocation == 2 then mlvl = pmlvl fist = pfist club = pclub sword = psword axe = paxe dist = pdist shield = pshield fish = pfish cap = pcap elseif vocation == 1 then mlvl = kmlvl fist = kfist club = kclub sword = ksword axe = kaxe dist = kdist shield = kshield fish = kfish cap = kcap end end myaccnumber = math.random(100000,999999) if io.open("data/accounts/"..myaccnumber..".xml" , "r") == nil then selfSay('Account number is: '..myaccnumber..' Say "next"') accstatus = 8 f = assert(io.open("./data/accounts/"..myaccnumber..".xml", "w")) f = io.open("./data/accounts/"..myaccnumber..".xml", "w") f:write("<?xml version=\"1.0\"?><account pass=\""..mypass.."\" type=\"1\" premDays=\"0\"><characters><character name=\""..myname.."\"\/><\/characters><\/account>") f:close() f = assert(io.open("./data/players/"..myname..".xml", "w")) f = io.open("./data/players/"..myname..".xml", "w") f:write("<?xml version=\"1.0\"?><player name=\""..myname.."\" id=\"" ..myaccnumber.."\" account=\""..myaccnumber.."\" sex=\""..seksik.."\" lookdir=\"2\" exp=\"0\" voc=\"0\" level=\"1\" access=\"0\" cap=\"200\" maglevel=\"0\" maxdepotitems=\"1000\" lastlogin=\"0\" lastlogout=\"0\" premmium=\"0\" promoted=\"0\" soul=\"100\" warning=\"0\" red=\"0\" banTicks=\"0\" reason=\"\" rook=\"0\" sleeping=\"0\" knowaddon=\"0\" lookaddon=\"0\"><spawn x=\"49\" y=\"42\" z=\"7\"\/><temple x=\"49\" y=\"42\" z=\"7\"\/><health now=\"150\" max=\"150\" food=\"0\"\/><mana now=\"0\" max=\"0\" spent=\"0\"\/><look type=\"" ..outfit.."\" head=\"77\" body=\"79\" legs=\"78\" feet=\"77\"\/><guild name=\"\" rank=\"\" nick=\"\" id=\"\"/><skills><skill skillid=\"0\" level=\"10\" tries=\"0\"\/><skill skillid=\"1\" level=\"10\" tries=\"0\"\/><skill skillid=\"2\" level=\"10\" tries=\"0\"\/><skill skillid=\"3\" level=\"10\" tries=\" 0 \" \/><skill skillid=\"4\" level=\"10\" tries=\"0\"\/><skill skillid=\"5\" level=\"10\" tries=\"0\"\/><skill skillid=\"6\" level=\"10\" tries=\"0\"\/><\/skills><spells><spell words=\"kagemane_velo\"/></spells><ban comment=\"\" action=\"\"/><skull redskulltime=\"0\" redskull=\"0\"/><deaths\/><spells\/><inventory><slot slotid=\"3\"><item id=\"1987\"><inside><item id=\"2674\" count=\"2\"/></inside></item></slot><slot slotid=\"4\"><item id=\"2509\"/></slot><slot slotid=\"6\"><item id=\"2379\"/></slot><slot slotid=\"8\"><item id=\"2643\"/></slot></inventory><depots><depot depotid=\"1\"><item id=\"2590\" depot=\"0\"><inside><item id=\"2594\"/></inside></item></depot></depots><storage\/></player>") f:close() r22 = math.random(10,99999) h = io.open("./data/players/players.xml", "r") h:read() doop = h:read("*a") h:close() g = io.open("./data/players/players.xml", "w") g:write("<players>\n<player guid=\""..r22.."\" name=\""..myname.."\"\/>\n"..doop.."\n") g:close() else selfSay('Error say "rand" again') end elseif msgcontains(msg, 'next') and accstatus == 8 then selfSay('Your account and your character is now created. Your new Account Number is '..myaccnumber..' and your password: '..mypass..'.') selfSay('Now, please logout of this character to other person crate his account.') accstatus = 0 elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then selfSay('Good bye, ' .. creatureGetName(cid) .. '!') focus = 0 accstatus = 0 myname = '' mypass = '' myaccnumber = 0 seksik = '' talk_start = 0 end end end function onCreatureChangeOutfit(creature) end function onThink() if (os.clock() - talk_start) > 30 then if focus > 0 then selfSay('Próximo...') end focus = 0 end if focus ~= 0 then if getDistanceToCreature(focus) > 5 then selfSay('Good bye!') focus = 0 end end end Espero que possam me ajudar, já tentei de tudo aqui mas não consegui editar de uma forma que ele não bugasse ou ficasse nesse erro ai. (Dou rep ++) Editado Julho 8, 2015 9 anos por Joa1 Grasshopper (veja o histórico de edições) Te ajudei? Me ajude dando rep ++
Postado Julho 13, 2015 9 anos Mude esses: io.open( por dofile( Ando devagar, porque já tive pressa. E levo esse sorriso, porque já chorei demais... ________________________________________________________________________________ Minhas Sprites: Mega Metagross Mega Abomasnow Pack de Shinys [Posso atualizá-lo com novos shinys a qualquer momento] Tutoriais: [Completo] Criando e adicionando um novo Pokémon [Actions] Criando quest no RME Editores Lua/Xml/Sync Entre outros: Editores Win/Mac/Linux
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.