• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Npc script don't work

Helliot1

Owner of Empire Online
Joined
Jul 26, 2017
Messages
315
Solutions
1
Reaction score
60
My Npc don't work. I have some errors in Script.
somebody can tell me what I need to fix it ?

Error
Code:
[Warning - NpcScript::NpcScript] Can not load script: alexander.lua
data/npc/scripts/alexander.lua:59: 'end' expected (to close 'if' at line 30) near '<eof>'
[Warning - NpcScript::NpcScript] Can not load script: thomas.lua
data/npc/scripts/thomas.lua:49: 'end' expected (to close 'if' at line 20) near '<eof>'
[Warning - NpcScript::NpcScript] Can not load script: nicholas.lua
data/npc/scripts/nicholas.lua:27: unexpected symbol near '=='
[Warning - NpcScript::NpcScript] Can not load script: nicholas.lua
data/npc/scripts/nicholas.lua:27: unexpected symbol near '=='

Script.Lua
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
local storage = 5003
function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    if msgcontains(msg, "sim") or msgcontains(msg, "ajuda") then
            if getPlayerStorageValue(cid, storage) == -1 then
            selfSay("Como você pode ver, eu estou um pouco ocupado e não posso sair de meu posto. Eu tenho um amigo que precisa de ajuda, você pode ir até o Thomas para ver do que ele precisa?", cid)
            talkState[talkUser] = 1
            setPlayerStorageValue(cid, storage, 0)
          
        elseif getPlayerStorageValue(cid, storage) == 1 then
             selfSay("Já visitou meu amigo Thomas, diga-me o que ele precisa, anda! Não tenho o dia todo para tagarelar.", cid)
             talkState[talkUser] = 1
          
            if msgcontains(msg, "pocao da vida") then
            selfSay("Ah... Apenas isso? Muito fácil de resolver, vá em outro amigo, Nicholas, e peça para ele que faça sua melhor mistura, e volte aqui para que eu cheque se realmente está a altura que eu desejo.", cid)
            setPlayerStorageValue(cid, storage, 2)
         
        elseif getPlayerStorageValue(cid, storage) == 4 then
            selfSay("Trouxe o que lhe pedi?", cid)
                if msgcontains(msg, "pocao da vida") then
                selfSay("Uhum... Parece boa, pelo aroma. Entregue a meu amigo Thomas e volte até mim para receber a recompensa... Ah!... Nao se esqueca de me tazer a nota, pois este favor nao e de graca!", cid)          
                talkState[talkUser] = 1 
                setPlayerStorageValue(cid, storage, 5)

        elseif getPlayerStorageValue(cid, storage) == 6 then
            selfSay("Trouxe minha nota?", cid)
                if msgcontains(msg, "nota") then
                if doPlayerRemoveItem(cid, 1815, 1) then
                selfSay("Muito obrigado pelo seu favor, aqui está sua recompensa.", cid)
                doPlayerAddItem(cid, 1813, 5)
                talkState[talkUser] = 1 
                setPlayerStorageValue(cid, storage, 7)                 
          
         else
             selfSay("Obrigado pela poção da vida.", cid)
         end
      
     end
     return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
try
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

local storage = 5003

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

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if msgcontains(msg, "sim") or msgcontains(msg, "ajuda") then
        if getPlayerStorageValue(cid, storage) == -1 then
            selfSay("Como você pode ver, eu estou um pouco ocupado e não posso sair de meu posto. Eu tenho um amigo que precisa de ajuda, você pode ir até o Thomas para ver do que ele precisa?", cid)
            talkState[talkUser] = 1
            setPlayerStorageValue(cid, storage, 0)
        elseif getPlayerStorageValue(cid, storage) == 1 then
            selfSay("Já visitou meu amigo Thomas, diga-me o que ele precisa, anda! Não tenho o dia todo para tagarelar.", cid)
            talkState[talkUser] = 1
            if msgcontains(msg, "pocao da vida") then
                selfSay("Ah... Apenas isso? Muito fácil de resolver, vá em outro amigo, Nicholas, e peça para ele que faça sua melhor mistura, e volte aqui para que eu cheque se realmente está a altura que eu desejo.", cid)
                setPlayerStorageValue(cid, storage, 2)
            end
        elseif getPlayerStorageValue(cid, storage) == 4 then
            selfSay("Trouxe o que lhe pedi?", cid)
            if msgcontains(msg, "pocao da vida") then
                selfSay("Uhum... Parece boa, pelo aroma. Entregue a meu amigo Thomas e volte até mim para receber a recompensa... Ah!... Nao se esqueca de me tazer a nota, pois este favor nao e de graca!", cid)       
                talkState[talkUser] = 1
                setPlayerStorageValue(cid, storage, 5)
            end
        elseif getPlayerStorageValue(cid, storage) == 6 then
            selfSay("Trouxe minha nota?", cid)
            if msgcontains(msg, "nota") then
                if doPlayerRemoveItem(cid, 1815, 1) then
                    selfSay("Muito obrigado pelo seu favor, aqui está sua recompensa.", cid)
                    doPlayerAddItem(cid, 1813, 5)
                    talkState[talkUser] = 1
                    setPlayerStorageValue(cid, storage, 7)
                end
            end           
        else
            selfSay("Obrigado pela poção da vida.", cid) -- player doesn't have any of the storages
        end
    else
        selfSay("blabla..") -- the msg is not "sim" or "ajuda"
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited by a moderator:
Back
Top