Ir para conteúdo
  • 0

[Npc] Dando Um Errozinho Do Then , Facil De Arrumar


tonynamoral

Pergunta

8 respostass a esta questão

Posts Recomendados

  • 0

Tó:

 

 

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 time = 5

---------------------------------

npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|, I can {create} wings or {information} about wings.") -- muda a frase só yes q não muda

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

---------------------------------

local function Sucesso(cid,id)

if isPlayer(cid) then

doPlayerAddItem(cid,id,1)

doPlayerSendTextMessage(cid, 27, "Success -> You created an ".. getItemNameById(id).."")

end

end

---------------------------------

local function Falha(cid, id)

if isPlayer(cid) then

doPlayerSendTextMessage(cid, 27, "Failed -> Trying to create your ".. getItemNameById(id).." failed.")

end

end

---------------------------------

local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

---------------------------------

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

selfSay("Well .. I can only create three types of wings. {angelic wings}, {dragon wings} and {fairy wings}.", cid)

talkState[talkUser] = 1

return true

elseif msgcontains(msg, 'information') then

selfSay("Well .. I can show you informations about three wings, these wings are {angelic wings}, {dragon wings} and {fairy wings}.", cid)

talkState[talkUser] = 2

return true

elseif msgcontains(msg, 'angelic wings') and talkState[talkUser] == 2 then

doShowTextDialog(cid,2407,"####--> Informations <--####\n\nName: Angelic Wigns\nVocation: Mage\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")

return true

elseif msgcontains(msg, 'dragon wings') and talkState[talkUser] == 2 then

doShowTextDialog(cid,2417,"####--> Informations <--####\n\nName: Dragon Wings\nVocation: Warrior\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")

return true

elseif msgcontains(msg, 'fairy wings') and talkState[talkUser] == 2 then

doShowTextDialog(cid,2412,"####--> Informations <--####\n\nName: Fairy Wings\nVocation: Elf\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")

return true

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

selfSay("Ok .. You to create an angelic wing, 1kk you need, and you will have 35% chance of success, yet you want to create your wing?", cid)

talkState[TalkUser] = 3

return true

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

selfSay("Ok .. You to create an dragon wings, 1kk you need, and you will have 35% chance of success, yet you want to create your wing?", cid)

talkState[TalkUser] = 4

return true

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

selfSay("Ok .. You to create an fairy wings, 1kk you need, and you will have 35% chance of success, yet you want to create your wing?", cid)

talkState[TalkUser] = 5

return true

------------------------------------------------------------

elseif(msgcontains(msg, 'yes')) and talkState[talkUser] == 3 then

if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Sucesso, time*1000, cid, 2407)

talkState[talkUser] = 0

return true

elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Falha, time*1000, cid, 2407)

talkState[talkUser] = 0

return true

elseif getPlayerItemCount(cid,2160) < 100 then

selfSay("Você não tem dinheiro suficiente!", cid)

return true

-------------------------------------------------------------

elseif(msgcontains(msg, 'yes')) and talkState[talkUser] == 4 then

if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Sucesso, time*1000, cid, 2417)

talkState[talkUser] = 0

return true

elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Falha, time*1000, cid, 2417)

talkState[talkUser] = 0

return true

elseif getPlayerItemCount(cid,2160) < 100 then

selfSay("Você não tem dinheiro suficiente!", cid)

return true

-------------------------------------------------------------

elseif(msgcontains(msg, 'yes')) and talkState[talkUser] == 5 then

if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Sucesso, time*1000, cid, 2412)

talkState[talkUser] = 0

return true

elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Falha, time*1000, cid, 2412)

talkState[talkUser] = 0

return true

elseif getPlayerItemCount(cid,2160) < 100 then

selfSay("Você não tem dinheiro suficiente!", cid)

return true

end

end

return true

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Link para o comentário
Compartilhar em outros sites

  • 0

pronto.

 

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 time = 5
---------------------------------
npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|, I can {create} wings or {information} about wings.") -- muda a frase só yes q não muda
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
---------------------------------
local function Sucesso(cid,id)
if isPlayer(cid) then
doPlayerAddItem(cid,id,1)
doPlayerSendTextMessage(cid, 27, "Success -> You created an ".. getItemNameById(id).."")
end
end
---------------------------------
local function Falha(cid, id)
if isPlayer(cid) then
doPlayerSendTextMessage(cid, 27, "Failed -> Trying to create your ".. getItemNameById(id).." failed.")
end
end
---------------------------------
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
---------------------------------
if(msgcontains(msg, 'create')) then
selfSay("Well .. I can only create three types of wings. {angelic wings}, {dragon wings} and {fairy wings}.", cid)
talkState[talkUser] = 1
return true
elseif(msgcontains(msg, 'information')) then
selfSay("Well .. I can show you informations about three wings, these wings are {angelic wings}, {dragon wings} and {fairy wings}.", cid)
talkState[talkUser] = 2
return true
elseif msgcontains(msg, 'angelic wings') and talkState[talkUser] then
doShowTextDialog(cid,2407,"####--> Informations <--####\n\nName: Angelic Wigns\nVocation: Mage\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")
return true
elseif msgcontains(msg, 'dragon wings') and talkState[talkUser] == 2 then
doShowTextDialog(cid,2417,"####--> Informations <--####\n\nName: Dragon Wings\nVocation: Warrior\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")
return true
elseif msgcontains(msg, 'fairy wings') and talkState[talkUser] == 2 then
doShowTextDialog(cid,2412,"####--> Informations <--####\n\nName: Fairy Wings\nVocation: Elf\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")
return true
elseif msgcontains(msg, 'angelical wings') and talkState[talkUser] == 1 then
selfSay("Ok .. You to create an angelic wing, 1kk you need, and you will have 35% chance of success, yet you want to create your wing?", cid)
talkState[TalkUser] = 3
return true
elseif msgcontains(msg, 'dragon wings') and talkState[talkUser] == 1 then
selfSay("Ok .. You to create an dragon wings, 1kk you need, and you will have 35% chance of success, yet you want to create your wing?", cid)
talkState[TalkUser] = 4
return true
elseif msgcontains(msg, 'fairy wings') and talkState[talkUser] == 1 then
selfSay("Ok .. You to create an fairy wings, 1kk you need, and you will have 35% chance of success, yet you want to create your wing?", cid)
talkState[TalkUser] = 5
return true
------------------------------------------------------------
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then
doPlayerRemoveItem(cid,2160,100)
addEvent(Sucesso, time*1000, cid, 2407)
talkState[talkUser] = 0
return true
elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then
doPlayerRemoveItem(cid,2160,100)
addEvent(Falha, time*1000, cid, 2407)
talkState[talkUser] = 0
return true
elseif getPlayerItemCount(cid,2160) < 100 then
selfSay("Você não tem dinheiro suficiente!", cid)
return true
-------------------------------------------------------------
elseif(msgcontains(msg, 'yes')) and talkState[talkUser] == 4 then
if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then
doPlayerRemoveItem(cid,2160,100)
addEvent(Sucesso, time*1000, cid, 2417)
talkState[talkUser] = 0
return true
elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then
doPlayerRemoveItem(cid,2160,100)
addEvent(Falha, time*1000, cid, 2417)
talkState[talkUser] = 0
return true
elseif getPlayerItemCount(cid,2160) < 100 then
selfSay("Você não tem dinheiro suficiente!", cid)
return true
-------------------------------------------------------------
elseif(msgcontains(msg, 'yes')) and talkState[talkUser] == 5 then
if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then
doPlayerRemoveItem(cid,2160,100)
addEvent(Sucesso, time*1000, cid, 2412)
talkState[talkUser] = 0
return true
elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then
doPlayerRemoveItem(cid,2160,100)
addEvent(Falha, time*1000, cid, 2412)
talkState[talkUser] = 0
return true
elseif getPlayerItemCount(cid,2160) < 100 then
selfSay("Você não tem dinheiro suficiente!", cid)
return true
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Link para o comentário
Compartilhar em outros sites

  • 0

Não Funcionou .

 

 

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 time = 5

---------------------------------

npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|, I can {create} wings or {information} about wings.") -- muda a frase só yes q não muda

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

end

---------------------------------

local function Sucesso(cid,id)

if isPlayer(cid) then

doPlayerAddItem(cid,id,1)

doPlayerSendTextMessage(cid, 27, "Success -> You created an ".. getItemNameById(id).."")

end

end

---------------------------------

local function Falha(cid, id)

if isPlayer(cid) then

doPlayerSendTextMessage(cid, 27, "Failed -> Trying to create your ".. getItemNameById(id).." failed.")

end

end

---------------------------------

local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

---------------------------------

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

selfSay("Well .. I can only create three types of wings. {angelic wings}, {dragon wings} and {fairy wings}.", cid)

talkState[talkUser] = 1

return true

elseif(msgcontains(msg, 'information')) then

selfSay("Well .. I can show you informations about three wings, these wings are {angelic wings}, {dragon wings} and {fairy wings}.", cid)

talkState[talkUser] = 2

return true

elseif msgcontains(msg, 'angelic wings') and talkState[talkUser] then

doShowTextDialog(cid,2407,"####--> Informations <--####\n\nName: Angelic Wigns\nVocation: Mage\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")

return true

elseif msgcontains(msg, 'dragon wings') and talkState[talkUser] == 2 then

doShowTextDialog(cid,2417,"####--> Informations <--####\n\nName: Dragon Wings\nVocation: Warrior\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")

return true

elseif msgcontains(msg, 'fairy wings') and talkState[talkUser] == 2 then

doShowTextDialog(cid,2412,"####--> Informations <--####\n\nName: Fairy Wings\nVocation: Elf\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")

return true

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

selfSay("Ok .. You to create an angelic wing, 1kk you need, and you will have 35% chance of success, yet you want to create your wing?", cid)

talkState[TalkUser] = 3

return true

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

selfSay("Ok .. You to create an dragon wings, 1kk you need, and you will have 35% chance of success, yet you want to create your wing?", cid)

talkState[TalkUser] = 4

return true

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

selfSay("Ok .. You to create an fairy wings, 1kk you need, and you will have 35% chance of success, yet you want to create your wing?", cid)

talkState[TalkUser] = 5

return true

------------------------------------------------------------

elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then

if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Sucesso, time*1000, cid, 2407)

talkState[talkUser] = 0

return true

elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Falha, time*1000, cid, 2407)

talkState[talkUser] = 0

return true

elseif getPlayerItemCount(cid,2160) < 100 then

selfSay("Você não tem dinheiro suficiente!", cid)

return true

-------------------------------------------------------------

elseif(msgcontains(msg, 'yes')) and talkState[talkUser] == 4 then

if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Sucesso, time*1000, cid, 2417)

talkState[talkUser] = 0

return true

elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Falha, time*1000, cid, 2417)

talkState[talkUser] = 0

return true

elseif getPlayerItemCount(cid,2160) < 100 then

selfSay("Você não tem dinheiro suficiente!", cid)

return true

-------------------------------------------------------------

elseif(msgcontains(msg, 'yes')) and talkState[talkUser] == 5 then

if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Sucesso, time*1000, cid, 2412)

talkState[talkUser] = 0

return true

elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Falha, time*1000, cid, 2412)

talkState[talkUser] = 0

return true

elseif getPlayerItemCount(cid,2160) < 100 then

selfSay("Você não tem dinheiro suficiente!", cid)

return true

end

end

return true

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

 

 

Erro :

 

 

[14/10/2012 13:51:52] [Error - LuaScriptInterface::loadFile] data/npc/scripts/npc5.lua:115: 'end' expected (to close 'if' at line 35) near '<eof>'

[14/10/2012 13:51:52] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/npc5.lua

[14/10/2012 13:51:52] data/npc/scripts/npc5.lua:115: 'end' expected (to close 'if' at line 35) near '<eof>'

Editado por tonynamoral
Link para o comentário
Compartilhar em outros sites

  • 0

Dei umas edits no NPC. Vê ai se funciona:

 

 

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 time = 5

---------------------------------

npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|, I can {create} wings or {information} about wings.") -- muda a frase só yes q não muda

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

---------------------------------

local function Sucesso(cid,id)

if isPlayer(cid) then

doPlayerAddItem(cid,id,1)

doPlayerSendTextMessage(cid, 27, "Success -> You created an ".. getItemNameById(id).."")

end

end

---------------------------------

local function Falha(cid, id)

if isPlayer(cid) then

doPlayerSendTextMessage(cid, 27, "Failed -> Trying to create your ".. getItemNameById(id).." failed.")

end

end

---------------------------------

local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

---------------------------------

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

selfSay("Well .. I can only create three types of wings. {angelic wings}, {dragon wings} and {fairy wings}.", cid)

talkState[talkUser] = 1

return true

elseif msgcontains(msg, 'information') then

selfSay("Well .. I can show you informations about three wings, these wings are {angelic wings}, {dragon wings} and {fairy wings}.", cid)

talkState[talkUser] = 2

return true

elseif msgcontains(msg, 'angelic wings') and talkState[talkUser] == 2 then

doShowTextDialog(cid,2407,"####--> Informations <--####\n\nName: Angelic Wigns\nVocation: Mage\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")

return true

elseif msgcontains(msg, 'dragon wings') and talkState[talkUser] == 2 then

doShowTextDialog(cid,2417,"####--> Informations <--####\n\nName: Dragon Wings\nVocation: Warrior\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")

return true

elseif msgcontains(msg, 'fairy wings') and talkState[talkUser] == 2 then

doShowTextDialog(cid,2412,"####--> Informations <--####\n\nName: Fairy Wings\nVocation: Elf\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")

return true

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

selfSay("Ok .. You to create an angelic wing, 1kk you need, and you will have 35% chance of success, yet you want to create your wing?", cid)

talkState[TalkUser] = 3

return true

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

selfSay("Ok .. You to create an dragon wings, 1kk you need, and you will have 35% chance of success, yet you want to create your wing?", cid)

talkState[TalkUser] = 4

return true

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

selfSay("Ok .. You to create an fairy wings, 1kk you need, and you will have 35% chance of success, yet you want to create your wing?", cid)

talkState[TalkUser] = 5

return true

-----------------------------------------------------------

elseif msgcontains(msg, 'yes') then

if talkState[talkUser] == 3 then

if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Sucesso, time*1000, cid, 2407)

talkState[talkUser] = 0

return true

elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Falha, time*1000, cid, 2407)

talkState[talkUser] = 0

return true

elseif getPlayerItemCount(cid,2160) < 100 then

selfSay("Você não tem dinheiro suficiente!", cid)

return true

-------------------------------------------------------------

elseif talkState[talkUser] == 4 then

if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Sucesso, time*1000, cid, 2417)

talkState[talkUser] = 0

return true

elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Falha, time*1000, cid, 2417)

talkState[talkUser] = 0

return true

elseif getPlayerItemCount(cid,2160) < 100 then

selfSay("Você não tem dinheiro suficiente!", cid)

return true

-------------------------------------------------------------

elseif talkState[talkUser] == 5 then

if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Sucesso, time*1000, cid, 2412)

talkState[talkUser] = 0

return true

elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Falha, time*1000, cid, 2412)

talkState[talkUser] = 0

return true

elseif getPlayerItemCount(cid,2160) < 100 then

selfSay("Você não tem dinheiro suficiente!", cid)

return true

end

end

end

end

end

return true

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Link para o comentário
Compartilhar em outros sites

  • 0

O Sistema de Information está 100% , mais o de create não

 

Quando eu falo . Hi / Create

 

Ai eu falo / angelical wings (ou qualquer outras das 3) , ai ele fala as chances e talz . ai eu falo yes. e nao acontece nada ...

 

 

 

 

[14/10/2012 14:33:19] [Error - Npc interface]

[14/10/2012 14:33:19] data/npc/scripts/npc5.lua:onCreatureSay

[14/10/2012 14:33:19] Description:

[14/10/2012 14:33:19] data/npc/scripts/npc5.lua:53: table index is nil

[14/10/2012 14:33:19] stack traceback:

[14/10/2012 14:33:19] data/npc/scripts/npc5.lua:53: in function 'callback'

[14/10/2012 14:33:20] data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'

[14/10/2012 14:33:20] data/npc/scripts/npc5.lua:7: in function <data/npc/scripts/npc5.lua:7>

Editado por tonynamoral
Link para o comentário
Compartilhar em outros sites

  • 0

Prontim, testado e funcionando:

 

 

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 time = 5

---------------------------------

npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|, I can {create} wings or {information} about wings.") -- muda a frase só yes q não muda

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

---------------------------------

local function Sucesso(cid,id)

if isPlayer(cid) then

doPlayerAddItem(cid,id,1)

doPlayerSendTextMessage(cid, 27, "Success -> You created an ".. getItemNameById(id).."")

end

end

---------------------------------

local function Falha(cid, id)

if isPlayer(cid) then

doPlayerSendTextMessage(cid, 27, "Failed -> Trying to create your ".. getItemNameById(id).." failed.")

end

end

---------------------------------

local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

---------------------------------

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

selfSay("Well... I can only create three types of wings. {angelical wings}, {dragon wings} and {fairy wings}.", cid)

talkState[talkUser] = 1

return true

elseif msgcontains(msg, 'information') then

selfSay("Well... I can show you informations about three wings, these wings are {angelical wings}, {dragon wings} and {fairy wings}.", cid)

talkState[talkUser] = 2

return true

elseif msgcontains(msg, 'angelical wings') and talkState[talkUser] == 2 then

doShowTextDialog(cid,2407,"####--> Informations <--####\n\nName: Angelical Wigns\nVocation: Mage\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")

return true

elseif msgcontains(msg, 'dragon wings') and talkState[talkUser] == 2 then

doShowTextDialog(cid,2417,"####--> Informations <--####\n\nName: Dragon Wings\nVocation: Warrior\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")

return true

elseif msgcontains(msg, 'fairy wings') and talkState[talkUser] == 2 then

doShowTextDialog(cid,2412,"####--> Informations <--####\n\nName: Fairy Wings\nVocation: Elf\nLevel: 40\nPrice NPC: $40.000,00\nWeighs: 40.00 oz\n ")

return true

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

selfSay("Ok... If you want to create angelical wings, you need 1kk and you will have 35% chance of success. Do you want to create your wing yet?", cid)

talkState[talkUser] = 3

return true

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

selfSay("Ok... If you want to create dragon wings, you need 1kk and you will have 35% chance of success. Do you want to create your wing yet?", cid)

talkState[talkUser] = 4

return true

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

selfSay("Ok... If you want to create fairy wings, you need 1kk and you will have 35% chance of success. Do you want to create your wing yet?", cid)

talkState[talkUser] = 5

return true

-----------------------------------------------------------

elseif talkState[talkUser] == 3 and msgcontains(msg, 'yes') then

if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Sucesso, time*1000, cid, 2407)

talkState[talkUser] = 0

elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Falha, time*1000, cid, 2407)

talkState[talkUser] = 0

elseif getPlayerItemCount(cid,2160) < 100 then

selfSay("Você não tem dinheiro suficiente!", cid)

talkState[talkUser] = 0

end

-------------------------------------------------------------

elseif talkState[talkUser] == 4 and msgcontains(msg, 'yes') then

if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Sucesso, time*1000, cid, 2417)

talkState[talkUser] = 0

elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Falha, time*1000, cid, 2417)

talkState[talkUser] = 0

elseif getPlayerItemCount(cid,2160) < 100 then

selfSay("Você não tem dinheiro suficiente!", cid)

talkState[talkUser] = 0

end

-------------------------------------------------------------

elseif talkState[talkUser] == 5 and msgcontains(msg, 'yes') then

if math.random(1,100) <= 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Sucesso, time*1000, cid, 2412)

talkState[talkUser] = 0

elseif math.random(1,100) > 35 and getPlayerItemCount(cid,2160) >= 100 then

doPlayerRemoveItem(cid,2160,100)

addEvent(Falha, time*1000, cid, 2412)

talkState[talkUser] = 0

elseif getPlayerItemCount(cid,2160) < 100 then

selfSay("Você não tem dinheiro suficiente!", cid)

talkState[talkUser] = 0

end

end

return true

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Editado por LuckOake
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...