--Player rename by Mock the bear (MTB) function sugested() --GName generator local cons = {'b','c','d','f','g','h','i','j','k','l','m','n',' p','q','r','s','t','v','x','y','z'} local vog = {"a",'e','i','o','u'} local sibalas = {} for i=1,#cons do for e=1,#vog do table.insert(sibalas,1,cons[i]..vog[e]) end end local total = "" for i=1,math.random(1,2) do local nam = "" for i=1,math.random(2,4) do nam = nam..sibalas[math.random(1,#sibalas)] end if math.random(1,2) == 1 then nam = nam..vog[math.random(1,#vog)] elseif math.random(1,2) == 2 then nam = nam..cons[math.random(1,#vog)] end total = total..(i == 2 and ' ' or '')..nam:sub(1,1):upper()..nam:sub(2,-1) end return total end function onSay(player, words, param) local split = param:splitTrimmed(" ") if param == 'gen' then player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sugestão de nome: " ..sugested()) return false end local param1, param2 = param:match('(.-)[;:,.]%s*(.+)') param = param1 or param param2 = param2 or sugested() if not param then player:popupFYI("Nenhum nome foi digitado.") return false end if param2:len() <= 2 or param2:len() > 20 then player:popupFYI("São necessários de 3 a 20 caracteres.") return false end if param2:match('[%a%d%s%u%l]+') ~= param2 then player:popupFYI("Somente letras de A-Z ou Numeros de 0-9.") return false end param2 = param2:sub(1,1):upper()..param2:sub(2,-1) local p2 = Creature(param) if p2 and p2:isPlayer() and param1 == player:getName() then if param2 ~= player:getName() then local newname = param2:gsub(" ", "") local Test = db.storeQuery("SELECT name FROM players WHERE name = '" ..newname.. "';") if Test then player:popupFYI("Já existe um jogador com este nome.") return false end if Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then local SALDO_VIP = PlayerVipCoins(player, 00) if SALDO_VIP >= 250 then local id = p2:getGuid() PlayerVipCoins(player, 01, 250) doPlayerSendTextMessage(p2, MESSAGE_INFO_DESCR, "Nome alterado com sucesso!\nVocê será deslogado em instantes.") p2:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) addEvent(doRemoveCreature, 3000, p2.uid) addEvent(function(id, newname) db.query("UPDATE `players` SET `name` = '"..newname.."' WHERE `id` = "..id) end, 3100, id, newname) return false else player:popupFYI("Você não possui VIP Coins suficientes.") return false end else player:popupFYI("Somente em Protection Zone (PZ).") return false end else player:popupFYI("Você precisa digitar um nome diferente\ndo nome seu personagem atual.") return false end else player:popupFYI("Você digitou seu nome errado.") return false end return false end