Ir para conteúdo

[Npc]


monroll

Posts Recomendados

Eu tentei fazer isso mais eu não conssegui. Quando falo com o npc ele não me responde...

npc-n-reponde.JPG

eu tentei fazer ele por lua e por xml.

por lua fica tipo:

 

todos akeles negócio do começo

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

 

function onGreet(cid)

if(msgcontains(msg, "hi")) then

if(getPlayerStorageValue(cid, 8791) == -1) then

npcHandler:say("I need to ask you a {favor}.")

else

npcHandler:say("You've already got the talons?")

talkState[talkUser] = 2

end

end

end

 

esse é o script(só o começo). ai eu vou no arquivo do npc xml e ta assim:

 

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

<npc name="Zocreio" script="data/npc/scripts/npc/zocreio.lua" walkinterval="2000" floorchange="0">

<health now="100" max="100"/>

<look type="151" head="114" body="114" legs="114" feet="114" addons="2"/>

</npc>

 

Eu não sei se tem alguma coisa errada. Mais eu queria consseguir pelo menos fazer um NPC =/

 

Obs: Quando eu puis o npc no servidor, não apontou nenhum problema.

Link para o comentário
Compartilhar em outros sites

Está aqui o Lua:

 

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)

 

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

 

function onGreet(cid)

if(msgcontains(msg, "hi")) then

if(getPlayerStorageValue(cid, 8791) == -1) then

npcHandler:say("I need to ask you a {favor}.")

else

npcHandler:say("You've already got the talons?")

talkState[talkUser] = 2

return TRUE

end

end

end

 

function msgCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

 

if(msgcontains(msg, 'favor')) then

npcHandler:say("I need you to pick 10 talons for me. You can do it?")

talkState[talkUser] = 1

end

 

if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then

npcHandler:say("Oh... Thanks a lot. Just be sure you come with the talons ok? {bye}")

setPlayerStorageValue(cid, 8791, 1)

elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then

npcHandles:say("Come other time, when you're ready. Don't mess with me.")

end

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:setCallback(CALLBACK_GREET, onGreet)

npcHandler:addModule(FocusModule:new())

 

end

 

E aqui o xml do NPC:

 

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

<npc name="Zocreio" script="data/npc/scripts/npc/zocreio.lua" walkinterval="2000" floorchange="0">

<health now="100" max="100"/>

<look type="151" head="114" body="114" legs="114" feet="114" addons="2"/>

</npc>

 

Quando eu pus o NPC online surgiram vários erros, mas eu os corrigi e agora não aparece mais nenhum relacionado a esse NPC.

 

Eu também ja tentei por paremeters no .xml mais não funcionou.

 

espero que vocês achem meu erro :winksmiley02:

Link para o comentário
Compartilhar em outros sites

Compare as estruturas:

 

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

local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

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

if(msgcontains(msg, 'favor')) then
  npcHandler:say("I need you to pick 10 talons for me. You can do it?")
  talkState[talkUser] = 1

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
  npcHandler:say("Oh... Thanks a lot. Just be sure you come with the talons ok? {bye}")
  setPlayerStorageValue(cid, 8791, 1)

elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
npcHandles:say("Come other time, when you're ready. Don't mess with me.")
end
return TRUE
end

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

 

 

flw

Link para o comentário
Compartilhar em outros sites

Agora eu completei o .lua. Deve estar certo (É meu primeiro npc)

 

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)

 

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

 

function onGreet(cid)

if(msgcontains(msg, "hi")) then

if(getPlayerStorageValue(cid, 8791) == -1) then

npcHandler:say("I need to ask you a {favor}.")

else

npcHandler:say("You've already got the talons?")

talkState[talkUser] = 2

return TRUE

end

end

end

 

function msgCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

 

if(msgcontains(msg, 'favor')) then

npcHandler:say("I need you to pick 10 talons for me. You can do it?")

talkState[talkUser] = 1

end

 

if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then

npcHandler:say("Oh... Thanks a lot. Just be sure you come with the talons ok? {bye}")

setPlayerStorageValue(cid, 8791, 1)

elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then

npcHandles:say("Come other time, when you're ready. Don't mess with me.")

talkState[talkUser] == 2)

end

end

 

if(msgcontains(msg, 'yes') or (msgcontains(msg, 'talons') and talkState[talkUser] == 2) then

if getPlayerItemCount(cid, 2151) >= 5 then

setPlayerStorageValue(cid, 8791, 2)

doPlayerRemoveItem(cid, 2151, 5)

npcHandler:say("Thanks |PLAYERNAME|, you can take this, i'll not need it anymore.)

doPlayerAddExp(cid, 50000)

if getPlayerSkillLevel(cid, 2) > 30 then

doPlayerAddItem(uid, 7429)

elseif getPlayerSkillLevel(cid, 3) > 30 then

doPlayerAddItem(uid, 7418)

elseif getPlayerSkillLevel(cid, 4) > 30 then

doPlayerAddItem(uid, 2454)

else

doPlayerAddItem(uid, 2160)

end

else

npcHandler:say("I told you! Dont mess with me!)

DoPlayerAddHealth(cid, -200)

end

end

if(msgcontains(msg, 'no') and talkState[talkUser] == 2) then

npcHandler:say("So come back when you have talons with you.")

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:setCallback(CALLBACK_GREET, onGreet)

npcHandler:addModule(FocusModule:new())

 

end

 

Tem um trecho em que o player perde 200 de vida se ele falar que trouxe os talons e não os tiver.

É meio violento mais achei legal essa idéia e pus no npc

 

Compare as estruturas:

 

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

local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

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

if(msgcontains(msg, 'favor')) then
  npcHandler:say("I need you to pick 10 talons for me. You can do it?")
  talkState[talkUser] = 1

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
  npcHandler:say("Oh... Thanks a lot. Just be sure you come with the talons ok? {bye}")
  setPlayerStorageValue(cid, 8791, 1)

elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
npcHandles:say("Come other time, when you're ready. Don't mess with me.")
end
return TRUE
end

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

 

 

flw

 

Até onde eu vi você tirou toda a parte da function ongreet:

 

function onGreet(cid)

if(msgcontains(msg, "hi")) then

if(getPlayerStorageValue(cid, 8791) == -1) then

npcHandler:say("I need to ask you a {favor}.")

elseif(getPlayerStorageValue(cid, 8791) == 1) then

npcHandler:say("You've already got the talons?")

talkState[talkUser] = 2

return TRUE

end

end

end

 

Mais então como eu vou começar uma conversa??? não entendi.

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...