Ir para conteúdo

Featured Replies

Postado

Olá,

 

A Script e simples, eu ate já encontrei aqui no TK! Mais tipo, o jogador fala " Hi " dps " Nome " e o Npc não cobra nada, e ainda não troca o nome.. o Npc que eu quero ele deve coletar o item e trocar o nome do jogador, logo isso relogar.

Mais ou menos assim:

Jogador: Hi

Npc: Olha Fulano, Deseja trocar seu nome por apenas 5 Pontos?

Jogador: Yes

Npc: Ok, Qual o nome Desejado?

Jogador: NooBEmAcAo <<< Apos isso coletar o item e trocar o nome e relogar ( não precisa estar na ordem, eu arrumo )

OBS: BEM EXPLICADO, SOU BURRO!

Quem puder me ajudar dou REP++

 

Obg^^

Editado por MaRqUiiM
Falta de Explicação (veja o histórico de edições)

  • Respostas 23
  • Visualizações 1.6k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Ta na mão: Vá em data/npc/scripts e crie um arquivo chamado Troca de Nick.lua e coloque esse Script dentro:   Agora vá em: data/npc e crie um arquivo chamado Troca de Nick.xml e coloque is

  • Amigo não entendi o "negócio de 5 pontos", mais editei esse script aqui e traduzi para você usar no caso ele renomeia o player por certo item e quantidade. "CONFIGURAVEL"   Em Npc crie um ar

Posted Images

Postado

Ta na mão: Vá em data/npc/scripts e crie um arquivo chamado Troca de Nick.lua e coloque esse Script dentro:

Spoiler

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
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and  or cid
    local item = 2160 						 --ID do item necessario para trocar de nome.
    local characters = {}                    --Configure nesta tabela os caracteres (ou palavras) proibidos.
    local delay = 5                          --Tempo para o jogador ser desconectado após trocar o nome.
    if msgcontains(msg:lower(), "name") or msgcontains(msg:lower(), "change") then
        selfSay("Voce deseja trocar de nome ? Essa troca vai custar 5 {"..getItemNameById(item).."}.", cid)
        talkState[talkUser] = 1
        return true
    elseif msgcontains(msg:lower(), "yes") and talkState[talkUser] == 1 then
        if getPlayerItemCount(cid, item) >= 5 then  -- Quantidade de item que você deseja.
            selfSay("OK, me fale o novo nome que voce deseja.", cid)
            talkState[talkUser] = 2
            return true
        else
            selfSay("Voce nao tem os itens nescessario.", cid)
            talkState[talkUser] = 
            return true
        end
    elseif talkState[talkUser] == 2 then
        local query = db.getResult("SELECT name FROM players")
        if query:getID() == -1 then
            selfSay("Database inexistent.", cid)
            talkState[talkUser] = 
            return true
        end
        repeat
            local name = query:getDataString("name")
            if msg == name then
                selfSay("Esse Nome ja existe.", cid)
                talkState[talkUser] = 
                return true
            end
        until not query:next()
        query:free()
        for i = 1, #characters do
            if msg:find(characters[i]) then
                selfSay("Desculpe, voce nao pode criar personagem com esse Nick, pois ele e proibido.", cid)
                talkState[talkUser] = 
                return true
            end
        end
        local guid = getPlayerGUID(cid)
        db.executeQuery("UPDATE `players` SET `name` = " .. db.escapeString(msg) .. " WHERE `id` = " .. guid .. " LIMIT 1;")
        doPlayerRemoveMoney(cid, price)
		doPlayerRemoveItem(cid, item, 5) -- quantidade de itens que precisa para se trocar de nome.
        selfSay("Voce trocou seu nome para {"..msg.."}. Em "..delay.." segundo"..(delay > 1 and "s" or "")..", voce sera desconectado.", cid)
        addEvent(function()
            if isPlayer(cid) then
                doRemoveCreature(cid)
            end
        end, delay * 1000)
        talkState[talkUser] = 
        return true
    elseif msgcontains(msg:lower(), "no") and talkState[talkUser] == 1 then
        selfSay("Ok, tchau.", cid)
        talkState[talkUser] = 
        return true
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

Agora vá em: data/npc e crie um arquivo chamado Troca de Nick.xml e coloque isso dentro:

Spoiler

<?xml version="1.0" encoding="UTF-8"?>

<npc name="Troca de Nick" script="data/npc/scripts/changer name.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="118" head="0" body="0" legs="0" feet="0" addons="0"/>

<parameters>

		<parameter key="message_greet" value="Olá |PLAYERNAME|. Eu posso trocar seu Nick. Diga {Name} ou {Changer} caso queira trocar o seu."/>

			<parameter key="message_farewell" value="Até mais!" />

		<parameter key="message_walkaway" value="Até mais!" />

</parameters>

</npc>

 

 

Agora basta usar... xD

 

Bom dentro do Script coloquei comentários para  você ver onde alterar e o que alterar para ficar a seu gosto. Caso não entenda é só falar...

 

Esse Script peguei aqui no TK, estava para trocar o nick por dinheiro apenas, então alterei para troca por itens, e pela quantidade que você deseja.

 

Qualquer coisa to aqui. ^^

Editado por KotZletY (veja o histórico de edições)

                                                              ezgif-1-98aab239f3.gif.1a897c9c3225228909e7b356a5cfb8e4.gif

Postado

Amigo não entendi o "negócio de 5 pontos", mais editei esse script aqui e traduzi para você usar no caso ele renomeia o player por certo item e quantidade. "CONFIGURAVEL"

 

Em Npc crie um arquivo chamado renameplayers.xml, após isso coloque o seguinte código nele.

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Renomeador" script="renn.lua" walkinterval="0" floorchange="0">
<health now="150" max="150"/>
<look type="299" head="114" body="119" legs="114" feet="114" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Olá |PLAYERNAME|, Deseja trocar seu nome por apenas 5 Pontos?"/>
</parameters>
</npc>

Em Npc/script crie um arquivo chamado renn.lua, após isso coloque o seguinte código nele.

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talk = {}
local name = {}

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 onPlayerEndTrade(cid) npcHandler:nPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid) npcHandler:nPlayerCloseChannel(cid) end

function creatureGreetCallback(cid)
talk[cid] = 
name[cid] = ''
return true
end

local chars = {' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}

RET_VALID = 1
RET_EXISTS = 2
RET_INVALID = 3

local function validName(name)
if getPlayerGUIDByName(name) ~= nil then
return RET_EXISTS
end

local notAllowed = {"god", "gm", "cm", "tutor", "help", "admin"}
for _, naw in pairs(notAllowed) do
if (name:lower():find(naw .. " ") or name:lower() == naw or name:lower():find("admin")) then
return RET_INVALID
end
end

for i = 1, name:len() do
if not(isInArray(chars, name:sub(i,i))) then
return RET_INVALID
end
end
return RET_VALID
end

local function getValid(name, opt)
local function tchelper(first, rest)
return first:upper()..rest:lower()
end

return opt and name:gsub("(%a)([%w_']*)", tchelper) or name:gsub("^%l", string.upper)
end

local config = {
type = 'item',
money = 10000, -- = ignore
item = {2159, 20}, -- Item, quantidade
everyFirstLetterCapital = true
}

function messageDefaultCallback(cid, type, msg)
if not(npcHandler:isFocused(cid)) then
return false
end

if msgcontains(msg, "yes") and talk[cid] ==  then
selfSay("Ok, Qual o nome Desejado?", cid)
talk[cid] = 1
elseif talk[cid] == 1 then
local v = getValid(msg:lower(), config.everyFirstLetterCapital)
local ret = validName(v)
if ret == RET_VALID then
selfSay("Então você quer '" .. v .. "' para ser seu nickname novo, irá custar: " .. (config.type == "money" and (config.money .. " gold") or (config.item[2] .. ' ' .. (config.item[2] > 1 and getItemPluralNameById(config.item[1]) or getItemNameById(config.item[1])))) .. "?", cid)
talk[cid], name[cid] = 2, v
else
if ret == RET_INVALID then
selfSay(msg .. " Não é um nome válido, diga me outro nome", cid)
elseif ret == RET_EXISTS then
selfSay(msg .. " Já existe diga-me outro nome", cid)
end
end
elseif talk[cid] == 2 then
if msgcontains(msg, "yes") then
if (config.type == 'money' and doPlayerRemoveMoney(cid, config.money)) or (config.type ~= 'money' and doPlayerRemoveItem(cid, config.item[1], config.item[2])) then
local curName = getPlayerName(cid)
doRemoveCreature(cid)
db.executeQuery("UPDATE players SET name = '"..name[cid].."' WHERE name = '"..curName.."';")
else
selfSay("Você não tem 5 Pontos :(", cid)
talk[cid] = 
end
else
selfSay("Talvez mais tarde.", cid)
talk[cid] = 
end
end


return true
end

npcHandler:setMessage(MESSAGE_FAREWELL, "Tchau.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Até logo!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, messageDefaultCallback) 
npcHandler:setCallback(CALLBACK_FAREWELL, creatureFarewell)
npcHandler:setCallback(CALLBACK_CREATURE_DISAPPEAR, creatureFarewell)
npcHandler:setCallback(CALLBACK_GREET, creatureGreetCallback)
npcHandler:addModule(FocusModule:new())

Como configurar: 

 

local config = {  
type = 'item',
-- Não mecha 
money = 10000, -- ignore
item = {2159, 20}, -- Item, quantidade
everyFirstLetterCapital = true

Postado
9 minutos atrás, MaRqUiiM disse:

REP++ aos Dois, pois foram os unicos que ajudaram xD

Thankz, mas... Qual você testou e qual conseguiu fazer o que você queria realmente ? :hum:

                                                              ezgif-1-98aab239f3.gif.1a897c9c3225228909e7b356a5cfb8e4.gif

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo