• 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!

Solved NPC

freddzor11

Member
Joined
May 25, 2009
Messages
695
Reaction score
5
I getting theese errors when I start up my server
Code:
[Error - LuaScriptInterface::loadFile] data/npc/scripts/goldnuggets.lua:5: funct
ion arguments expected near ':'
[Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/goldnugget
s.lua
data/npc/scripts/goldnuggets.lua:5: function arguments expected near ':'

Here is npc/scripts/goldnuggets.lua
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() 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 shopWindow = {}

local t = {
[7724] = {price = 50, currency = 2157}, 
[5785] = {price = 400, currency = 2157}, 
[5080] = {price = 200, currency = 2157}, 
}
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if t[item] and not doPlayerRemoveItem(cid, t[item].currency, t[item].price) then
selfSay("You dont have "..t[item].price.." "..getItemNameById(t[item].currency), cid)
else
doPlayerAddItem(cid, item)
selfSay("Here you go!", cid)
end
return true
end
if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
for var, ret in pairs(t) do
table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)})
end
openShopWindow(cid, shopWindow, onBuy, onSell)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
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 shopWindow = {}

    local t = {
        [7724] = {price = 50, currency = 2157},
        [5785] = {price = 400, currency = 2157},
        [5080] = {price = 200, currency = 2157}
    }
    local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
        if (t[item] and not doPlayerRemoveItem(cid, t[item].currency, t[item].price)) then
            selfSay("You dont have "..t[item].price.." "..getItemNameById(t[item].currency), cid)
        else
            doPlayerAddItem(cid, item)
            selfSay("Here you go!", cid)
        end
    return true
    end
    if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
        for var, ret in pairs(t) do
            table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)})
        end
        openShopWindow(cid, shopWindow, onBuy, onSell)
    end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
npcHandler:eek:n?

Should be npcHandler:on


- edit -

Above replied faster :p
 
Code:
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 shopWindow = {}

    local t = {
        [7724] = {price = 50, currency = 2157},
        [5785] = {price = 400, currency = 2157},
        [5080] = {price = 200, currency = 2157}
    }
    local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
        if (t[item] and not doPlayerRemoveItem(cid, t[item].currency, t[item].price)) then
            selfSay("You dont have "..t[item].price.." "..getItemNameById(t[item].currency), cid)
        else
            doPlayerAddItem(cid, item)
            selfSay("Here you go!", cid)
        end
    return true
    end
    if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
        for var, ret in pairs(t) do
            table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)})
        end
        openShopWindow(cid, shopWindow, onBuy, onSell)
    end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Thank you it works! SOLVED
 
Back
Top