xml :
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Name Changer" script="nome do arquivo.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="128" head="17" body="54" legs="114" feet="0" addons="2"/>
<parameters>
<parameter key="message_greet" value="Ola, diga {change} para trocar seu nome."/>
</parameters>
</npc>
Script:
local configs = {
max = 14, -- tamanho maximo do nome
invalid = {"!", ".", ",", "@", "#", "GOD", "ADM"}, -- caracters invalidos
gold = 2160, -- id do dinheiro
count = 100 -- tantos de dinheiro q vai precizar
}
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'change') and talkState ~= 1 then
c = configs
if getPlayerItemCount(cid, c.gold) < c.count then
return selfSay('Voce precisa pelo menos de '..c.count.." "..getItemNameById(c.gold).." para trocar seu nome.", cid)
end
talkState = 1
elseif talkState == 1 and msg ~= "" then
for _,d in pairs(c.invalid) do
if string.find(msg, d) then
return selfSay('Caracters invalidos não são permitidos.')
end
end
if string.len(msg) > c.max then
return selfSay('Você ultrapasou o limite de caracters.')
end
doPlayerRemoveItem(cid, c.gold, c.count)
db.executeQuery("UPDATE `players` SET `name` = '"..msg.."' WHERE `id` = "..getPlayerGUID(cid)..";")
doPlayerSendTextMessage(cid, 25, "Você será relogado em 5 segundos.")
addEvent(doRemoveCreature, 5*1000, cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Ve ai se funcion!! :Xd
Abraços





info
Grupo: Campones
Registrado: 13/07/11
Posts: 11
Reputação: 0
Char no Tibia: Kina da War
Olá queria pedi um NPC que troca nome de player por 1KK alguem pode me ajudar
Desde já Obrigado quem me ajudar dou +REP