Ir para conteúdo
  • Cadastre-se

(Resolvido)[Erro] NPC ajudem please!!


Ir para solução Resolvido por Vodkart,

Posts Recomendados

BASE PDA!

 

Eai galerinha estou tendo um problema com um npc.

Bem eu queria um npc Teleport que teleporta o player por um certo valor, já peguei todo tipo de scripts em sites e sempre da esse mesmo erro poderiam me ajudar soluciona-lo?

 

Erro:

Spoiler

help.thumb.png.436a80df2c4dc490e117905e64dfcc7d.png

 

SCRIPT:

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 0 or cid

local a = {
levelcidade1 = 30, -- Level que necessita para ir na cidade 1
levelcidade2 = 60, -- Level que necessita para ir na cidade 2
itemcidade1 = 2160, -- Item que necessita para viajar para cidade 1
itemcidade2 = 2190, -- Item que necessita para viajar para cidade 2
goldcidade1 = 1, -- Gold que precisa para viajar para cidade 1
goldcidade2 = 2000, -- Gold que precisa para viajar para cidade 2
poscidade1 = {x = 1054, y = 1058, z = 7}, -- Posição da cidade 1
poscidade2 = {x = 168, y = 58, z = 7}, -- Posição da cidade 2
}
 
   
 if msgcontains(msg, 'carlin') then
  if getPlayerItemCount(cid, a.itemcidade1) >= 1 then
   if getPlayerLevel(cid) >= a.levelcidade1 then
    if getPlayerMoney(cid) >= a.goldcidade1 then
     doTeleportThing(cid, a.poscidade1)
     doPlayerRemoveMoney(cid, a.goldcidade1)
     selfSay('Você foi teleportado para carlin!', cid)
    else
     selfSay('Você precisa de '..a.goldcidade1..' gold coins para viajar para {carlin}.', cid)
    end
   else
     selfSay('Você precisa ser '..a.levelcidade1..' para viajar para {carlin}.', cid)
   end
  else
   selfSay('Você precisa de uma '..getItemNameById(a.itemcidade1)..' para ir até {carlin}!', cid)
  end
 end
 
  if msgcontains(msg, 'thais') then
  if getPlayerItemCount(cid, a.itemcidade2) >= 1 then
   if getPlayerLevel(cid) >= a.levelcidade2 then
    if getPlayerMoney(cid) >= a.goldcidade2 then
     doTeleportThing(cid, a.poscidade2)
     doPlayerRemoveMoney(cid, a.goldcidade2)
     selfSay('Você foi teleportado para thais!', cid)
    else
     selfSay('Você precisa de '..a.goldcidade2..' gold coins para viajar para {thais}.', cid)
    end
   else
     selfSay('Você precisa ser '..a.levelcidade2..' para viajar para {thais}.', cid)
   end
  else
   selfSay('Você precisa de uma '..getItemNameById(a.itemcidade2)..' para ir até {thais}!', cid)
  end
 end
return true
end

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

 

Pode ser outro script não tem problema desde que funcione, obrigado.

Link para o post
Compartilhar em outros sites

@admelite 

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 0 or cid
  
 	local moeda = 2160 -- ID do item que será a moeda
  
    -- ["name"] = {Quantidade da moeda, Onde será teleportado, Level, vip(true or false)}
    local t = {
        
        ["konoha"] = {1, {x = 1012, y = 905, z = 7}, 1, false}, 
        
    }
    
    if (msgcontains(msg, 'viajar')) then
        local str = ""
        str = str .. "Eu posso lhe levar para esses lugares: "
        for name, pos, d, c in pairs(t) do
            str = str.." {"..name.."} por {"..pos[1].."} gold bars, "
        end
        str = str .. "."
        npcHandler:say(str, cid)
        
    elseif t[msg] then
        
        if t[msg][4] == true and not isPremium(cid) then
            npcHandler:say("Apenas Premium Players podem viajar à essa ilha, procure outra!!", cid)
            return false
        end
        
        if getPlayerLevel(cid) < t[msg][3] then
            npcHandler:say("Voce precisa ser level ".. tonumber(t[msg][3]) .." ou maior para viajar à essa ilha.", cid)
            return false
        end 
        
        if getCreatureSkullType(cid) == 3 then
            npcHandler:say("PK's não podem viajar.", cid)
            return false
        end 
        
        if doPlayerRemoveItem(cid, moeda, t[msg][1]) then
            doTeleportThing(cid, t[msg][2])
            npcHandler:say("Obrigado! Espero que volte em breve.", cid)
        else
            npcHandler:say("Voce nao tem gold bars suficientes para viajar.", cid)
        end
    end
    return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

XML

<?xml version="1.0"?>
<npc name="Minoru" script="data/npc/scripts/Minoru.lua" walkinterval="5000" floorchange="0">
<health now="100" max="100"/>
<look type="407" head="95" body="116" legs="121" feet="115" addons="0"/>
<parameters>
<parameter key="message_greet" value="Ola |PLAYERNAME|. Deseja {viajar} ??" />
</parameters>
</npc>

 

Link para o post
Compartilhar em outros sites
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,msg = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, msg:lower()
	local tabble = {
		["carlin"] = {item = {2160,1}, money = 1, level = 30, pos = {x = 1054, y = 1058, z = 7}},
		["thais"] = {item = {2190, 1}, money = 2000, level = 60, pos = {x = 168, y = 58, z = 7}}
	}

		if not tabble[msg] then
			npcHandler:say('somente posso te levar para {carlin} ou {thais}...', cid) return true
		end
		local t = tabble[msg]
  if getPlayerItemCount(cid, t.item[1]) >= t.item[2] then
   	if getPlayerLevel(cid) >= t.level then
    		if getPlayerMoney(cid) >= t.money then
			npcHandler:say('Você foi teleportado para '..msg..'!', cid)
     			doTeleportThing(cid, t.pos)
     			doPlayerRemoveMoney(cid, t.money) return true
		else
			npcHandler:say('Você precisa de '..t.money..' gold coins para viajar para '..msg..'.', cid)
		end
	else
			npcHandler:say('Você precisa ter '..t.level..' level ou mais para viajar para '..msg..'.', cid)
	end
else
	npcHandler:say('Você precisa de '..t.item[2]..' '..getItemNameById(t.item[1])..' para viajar para '..msg..'.', cid)
end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
8 horas atrás, Vodkart disse:

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,msg = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, msg:lower()
	local tabble = {
		["carlin"] = {item = {2160,1}, money = 1, level = 30, pos = {x = 1054, y = 1058, z = 7}},
		["thais"] = {item = {2190, 1}, money = 2000, level = 60, pos = {x = 168, y = 58, z = 7}}
	}

		if not tabble[msg] then
			npcHandler:say('somente posso te levar para {carlin} ou {thais}...', cid) return true
		end
		local t = tabble[msg]
  if getPlayerItemCount(cid, t.item[1]) >= t.item[2] then
   	if getPlayerLevel(cid) >= t.level then
    		if getPlayerMoney(cid) >= t.money then
			npcHandler:say('Você foi teleportado para '..msg..'!', cid)
     			doTeleportThing(cid, t.pos)
     			doPlayerRemoveMoney(cid, t.money) return true
		else
			npcHandler:say('Você precisa de '..t.money..' gold coins para viajar para '..msg..'.', cid)
		end
	else
			npcHandler:say('Você precisa ter '..t.level..' level ou mais para viajar para '..msg..'.', cid)
	end
else
	npcHandler:say('Você precisa de '..t.item[2]..' '..getItemNameById(t.item[1])..' para viajar para '..msg..'.', cid)
end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

 

Infelizmente ainda persiste o erro =/

Editado por admelite
errei a escrita (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
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,msg = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, msg:lower()
	local tabble = {
		["carlin"] = {item = {2160,1}, money = 1, level = 30, pos = {x = 1054, y = 1058, z = 7}},
		["thais"] = {item = {2190, 1}, money = 2000, level = 60, pos = {x = 168, y = 58, z = 7}}
	}

		if not tabble[msg] then
			npcHandler:say('somente posso te levar para {carlin} ou {thais}...', cid) return true
		end
		local t = tabble[msg]
  if getPlayerItemCount(cid, t.item[1]) >= t.item[2] then
   	if getPlayerLevel(cid) >= t.level then
    		if getPlayerMoney(cid) >= t.money then
			npcHandler:say('Você foi teleportado para '..msg..'!', cid)
     			doTeleportThing(cid, t.pos)
     			doPlayerRemoveMoney(cid, t.money) return true
		else
			npcHandler:say('Você precisa de '..t.money..' gold coins para viajar para '..msg..'.', cid)
		end
	else
			npcHandler:say('Você precisa ter '..t.level..' level ou mais para viajar para '..msg..'.', cid)
	end
else
	npcHandler:say('Você precisa de '..t.item[2]..' '..getItemNameById(t.item[1])..' para viajar para '..msg..'.', cid)
end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

testado.

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites

@admelite cara faz assim, abre seu arquivo que está dando erro como Notepad e vai linha por linha procurando algum caractere no final da linha e apaga eles, os possíveis caractere que faz com que esse erro te atrapalhe sao: - ? eu sei disso por que sempre que eu pego um script do TK e tento executar no meu servidor da esse erro e para não acontecer mais isso, tentar apertar só uma vez o comando CTRL +C e CTRL + V

Link para o post
Compartilhar em outros sites

@Emanueldk entendo vou tentarm obrigado a todos que tentaram ajudar ai

nao tem nenhum script de comando ex: !teleport tal lugar que cobra "x" valor para usar o comando?

Link para o post
Compartilhar em outros sites

@admelite 

local t = {
    
    ["local1"] = {{x=96, y=119, z=5}, 5000}, -- ["O que o player terá que digitar"] = {onde será levado, custo de money}
    ["local2"] = {{x=96, y=119, z=7}, 5000},
    
}

function onSay(cid, words, param, channel)
    
    local exaust = 1 -- Minutos para usar o comando novamente
    local storage = 435569
    
    local teleport = t[param]
    
    if os.time() - getPlayerStorageValue(cid, storage) <= exaust * 60 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "O Comando está em exaustão")
        return true
    end
    
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Digite o nome da quest que você quer")
        return true
    end

    if not teleport then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Local não encontrado.")
        return true
    end
    
    if getCreatureCondition(cid, CONDITION_INFIGHT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Não pode estar em Battle")
        return true
    end
    
    if doPlayerRemoveMoney(cid, teleport[2]) then
        doPlayerSendTextMessage(cid, 25, "Teleportado")
        doTeleportThing(cid, teleport[1])
        doSendMagicEffect(getCreaturePosition(cid), 2)
        setPlayerStorageValue(cid, storage, os.time())
    	return true
    else
        doPlayerSendTextMessage(cid, 27, "Voce nao tem dinheiro suficiente")
        doSendMagicEffect(getCreaturePosition(cid), 2)
    end
    return true
end

 

Link para o post
Compartilhar em outros sites

Olha o seu pedido:

Em 27/07/2018 em 12:30, admelite disse:

!teleport tal lugar que cobra "x" valor para usar o comando?

 

 

Agora olha o que você disse:

15 horas atrás, admelite disse:

esse não deu errom porém voce fala (Hi) e o npc nao responde nada, fala o Local para teleportar e tmb nada acontece!

 

 

É npc ou comando ? :olhinho:

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

Link para o post
Compartilhar em outros sites

 

Em 27/07/2018 em 07:46, Vodkart disse:

 

testado.

 

Esse deu certo podem fechar o tópico.

@Vodkart Mano funcionou porém nao esta recolhendo o item apenas o money

Editado por admelite
organizar (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • Solução

mas no seu tbm não estava, por isso que coloquei para não remover!!

 

 

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,msg = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, msg:lower()
	local tabble = {
		["carlin"] = {item = {2160,1}, money = 1, level = 30, pos = {x = 1054, y = 1058, z = 7}},
		["thais"] = {item = {2190, 1}, money = 2000, level = 60, pos = {x = 168, y = 58, z = 7}}
	}

		if not tabble[msg] then
			npcHandler:say('somente posso te levar para {carlin} ou {thais}...', cid) return true
		end
		local t = tabble[msg]
  if getPlayerItemCount(cid, t.item[1]) >= t.item[2] then
   	if getPlayerLevel(cid) >= t.level then
    		if getPlayerMoney(cid) >= t.money then
			npcHandler:say('Você foi teleportado para '..msg..'!', cid)
     			doTeleportThing(cid, t.pos)
			doPlayerRemoveItem(cid,t.item[1],t.item[2])
     			doPlayerRemoveMoney(cid, t.money) return true
		else
			npcHandler:say('Você precisa de '..t.money..' gold coins para viajar para '..msg..'.', cid)
		end
	else
			npcHandler:say('Você precisa ter '..t.level..' level ou mais para viajar para '..msg..'.', cid)
	end
else
	npcHandler:say('Você precisa de '..t.item[2]..' '..getItemNameById(t.item[1])..' para viajar para '..msg..'.', cid)
end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo