I created a "NPC", however long ago that I do not handle script I forgot many functions.
I used a lot of "storage" to offset the "talkState". Someone decreases the size of this script I made using "talkState"?
There's another problem too. After I finished the first mission, he is not giving me the option to start the second.
He keeps saying the same thing from the start when I say "hi": Hello. I am the guardian of this small town and I'm having some problems, if you {help} me I will give you a reward..
I used a lot of "storage" to offset the "talkState". Someone decreases the size of this script I made using "talkState"?
There's another problem too. After I finished the first mission, he is not giving me the option to start the second.
He keeps saying the same thing from the start when I say "hi": Hello. I am the guardian of this small town and I'm having some problems, if you {help} me I will give you a reward..
LUA:
local storOfNpc = 900001
local focuses = {}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)
if isFocused(cid, focuses) then
removeFocus(cid, focuses)
if isPlayer(cid) then
closeShopWindow(cid)
end
end
end
local function talkAnderson(cid)
local distance = getDistanceTo(cid) or 5
if distance > 4 then
return FALSE
else
if getPlayerStorageValue(cid, storOfNpc) > 0 then
setPlayerStorageValue(cid, storOfNpc, 0)
removeFocus(cid, focuses)
lookAtFocus(focuses)
else
return FALSE
end
end
return TRUE
end
function onCreatureSay(cid, type, msg)
local distance = getDistanceTo(cid) or 5
if distance > 4 then
return FALSE
else
if msgcontains(msg, "hi") or msgcontains(msg, "oi") then
if getPlayerStorageValue(cid, 800001) == 2 then
if getPlayerStorageValue(cid, storOfNpc) == 0 then
if getLanguage(cid) == 1 then
selfSay("Good job! Take your reward!", cid)
else
selfSay("Bom trabalho! Pegue sua recompensa!", cid)
end
addFocus(cid, focuses)
setPlayerStorageValue(cid, storOfNpc, 0)
doPlayerAddItem(cid, 7618, 1)
setPlayerStorageValue(cid, 800001, 3)
end
elseif getPlayerStorageValue(cid, 800001) == 2 and getPlayerStorageValue(cid, 800002) == -1 then
if getPlayerStorageValue(cid, storOfNpc) == 0 then
if getLanguage(cid) == 1 then
selfSay("I have a new mission for you ... Kill a {spider} and prove that you are able to protect this city.", cid)
else
selfSay("Tenho uma nova missão para você... Mate uma {aranha} e prove que você é capaz de proteger esta cidade.", cid)
end
addFocus(cid, focuses)
setPlayerStorageValue(cid, storOfNpc, 1)
setPlayerStorageValue(cid, 800002, 1)
addEvent(talkAnderson, 30000, cid)
end
elseif getPlayerStorageValue(cid, 800002) == 3 then
if getPlayerStorageValue(cid, storOfNpc) == 0 then
if getLanguage(cid) == 1 then
selfSay("Good job! Take your reward!", cid)
else
selfSay("Bom trabalho! Pegue sua recompensa!", cid)
end
addFocus(cid, focuses)
setPlayerStorageValue(cid, storOfNpc, 0)
doPlayerAddItem(cid, 2512, 1)
setPlayerStorageValue(cid, 800002, 4)
end
else
if getPlayerStorageValue(cid, storOfNpc) == 0 then
if getLanguage(cid) == 1 then
selfSay("Hello. I am the guardian of this small town and I'm having some problems, if you {help} me I will give you a reward.", cid)
else
selfSay("Olá. Sou o guardião desta pequena cidade e estou com alguns problemas, se quiser me {ajudar} eu irei lhe dar uma recompensa.", cid)
end
addFocus(cid, focuses)
setPlayerStorageValue(cid, storOfNpc, 1)
addEvent(talkAnderson, 30000, cid)
end
end
end
if msgcontains(msg, "help") or msgcontains(msg, "ajudar") then
if getPlayerStorageValue(cid, storOfNpc) == 1 then
if getPlayerStorageValue(cid, 800001) == -1 then
if getLanguage(cid) == 1 then
selfSay("I have a debt with a senior this small town. The name of this old and he is Olavio want three chicken feathers. Take him and seek reward with me. You want to do this for me?", cid)
setPlayerStorageValue(cid, storOfNpc, 2)
else
selfSay("Tenho uma dívida com um idoso desta pequena cidade. O nome deste idoso é Olavio e ele quer três penas de galinha. Leve para ele e busque a recompensa comigo. Você quer fazer isto por mim?", cid)
setPlayerStorageValue(cid, storOfNpc, 2)
end
elseif getPlayerStorageValue(cid, 800001) == 1 then
if getLanguage(cid) == 1 then
selfSay("You're already on a mission.", cid)
else
selfSay("Você já está em uma missão.", cid)
end
else
if getLanguage(cid) == 1 then
selfSay("You've done this mission.", cid)
else
selfSay("Você já fez esta missão.", cid)
end
end
stopEvent(talkAnderson)
addEvent(talkAnderson, 30000, cid)
else
return FALSE
end
end
if msgcontains(msg, "spider") or msgcontains(msg, "aranha") and getPlayerStorageValue(cid, 800002) == 1 then
if getPlayerStorageValue(cid, storOfNpc) == 1 then
if getPlayerStorageValue(cid, 800002) == 1 then
if getLanguage(cid) == 1 then
selfSay("You will even kill a spider? The reward is good.", cid)
setPlayerStorageValue(cid, storOfNpc, 2)
setPlayerStorageValue(cid, 800002, 2)
else
selfSay("Você vai mesmo matar uma aranha? A recompensa é boa.", cid)
setPlayerStorageValue(cid, storOfNpc, 2)
setPlayerStorageValue(cid, 800002, 2)
end
elseif getPlayerStorageValue(cid, 800002) == 2 then
if getLanguage(cid) == 1 then
selfSay("You're already on a mission.", cid)
else
selfSay("Você já está em uma missão.", cid)
end
else
if getLanguage(cid) == 1 then
selfSay("You've done this mission.", cid)
else
selfSay("Você já fez esta missão.", cid)
end
end
stopEvent(talkAnderson)
addEvent(talkAnderson, 30000, cid)
else
return FALSE
end
end
if msgcontains(msg, "yes") or msgcontains(msg, "sim") then
if getPlayerStorageValue(cid, storOfNpc) == 2 then
if getLanguage(cid) == 1 then
selfSay("I'll be waiting for you with your reward!", cid)
else
selfSay("Estarei lhe esperando com sua recompensa!", cid)
end
setPlayerStorageValue(cid, 800001, 1)
setPlayerStorageValue(cid, storOfNpc, 3)
stopEvent(talkAnderson)
addEvent(talkAnderson, 30000, cid)
else
return FALSE
end
end
if msgcontains(msg, "no") or msgcontains(msg, "nao") then
if getPlayerStorageValue(cid, storOfNpc) == 2 then
if getLanguage(cid) == 1 then
selfSay("Ok then.", cid)
else
selfSay("Você que sabe...", cid)
end
setPlayerStorageValue(cid, storOfNpc, 3)
stopEvent(talkAnderson)
addEvent(talkAnderson, 30000, cid)
end
end
if msgcontains(msg, "bye") or msgcontains(msg, "tchau") then
if getPlayerStorageValue(cid, storOfNpc) > 0 then
if getLanguage(cid) == 1 then
selfSay("Goodbye!", cid)
else
selfSay("Adeus!", cid)
end
setPlayerStorageValue(cid, storOfNpc, 0)
removeFocus(cid, focuses)
lookAtFocus(focuses)
else
return FALSE
end
end
end
end
function onThink()
for _, focus in pairs(focuses) do
if not isCreature(focus) then
removeFocus(focus, focuses)
setPlayerStorageValue(focus, storOfNpc, 0)
else
local distance = getDistanceTo(focus) or 5
if distance > 4 then
selfSay("...", focus)
removeFocus(focus, focuses)
setPlayerStorageValue(focus, storOfNpc, 0)
end
end
end
lookAtFocus(focuses)
end