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

Windows Npc Problem

kozmo

Member
Joined
Jan 30, 2009
Messages
433
Solutions
2
Reaction score
22
When i say Hi, First citizen addon or any other like that i get error on line 34 NIL VALUE.

This line of script.

"items_list = items_list .. item[2] .. ' ' .. getItemName(item[1])"
 
Tfs 1.0 wont let me post script to BIG.


First Part:

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)


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

npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. Can you help me? If you help me, I will reward you with beautiful addons! Say {addons} or {help} if you do not know what to do.")

function playerBuyAddonNPC(cid, message, keywords, parameters, node)
    local player = Player(cid)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    if (parameters.confirm ~= true) and (parameters.decline ~= true) then
        if(player:getPremiumDays(cid) == 0) and (parameters.premium == true) then
            npcHandler:say('Sorry, but this addon and only for premium players!', cid)
            npcHandler:resetNpc()
            return true
        end
        if (player:getStorageValue(parameters.storageID) ~= -1) then
            npcHandler:say('You already have this addon!', cid)
            npcHandler:resetNpc()
            return true
        end
        local itemsTable = parameters.items
        local items_list = ''
        if table.maxn(itemsTable) > 0 then
            for i = 1, table.maxn(itemsTable) do
                local item = itemsTable[i]
                items_list = items_list .. item[2] .. ' ' .. getItemName(item[1])
                if i ~= table.maxn(itemsTable) then
                    items_list = items_list .. ', '
                end
            end
        end
        local text = ''
        if (parameters.cost > 0) and table.maxn(parameters.items) then
            text = items_list .. ' and ' .. parameters.cost .. ' gp'
        elseif (parameters.cost > 0) then
            text = parameters.cost .. ' gp'
        elseif table.maxn(parameters.items) then
            text = items_list
        end
        npcHandler:say('Brought me ' .. text .. ' by ' .. keywords[1] .. '?', cid)
        return true
    elseif (parameters.confirm == true) then
        local addonNode = node:getParent()
        local addoninfo = addonNode:getParameters()
        local items_number = 0
        if table.maxn(addoninfo.items) > 0 then
            for i = 1, table.maxn(addoninfo.items) do
                local item = addoninfo.items[i]
                if (player:getItemCount(item[1]) >= item[2]) then
                    items_number = items_number + 1
                end
            end
        end
        if(player:getMoney(cid) >= addoninfo.cost) and (items_number == table.maxn(addoninfo.items)) then
            player:removeMoney(addoninfo.cost)
            if table.maxn(addoninfo.items) > 0 then
                for i = 1, table.maxn(addoninfo.items) do
                    local item = addoninfo.items[i]
                    player:removeItem(item[1],item[2])
                end
            end
            player:addOutfitAddon(addoninfo.outfit_male, addoninfo.addon)
            player:addOutfitAddon(addoninfo.outfit_female, addoninfo.addon)
            player:setStorageValue(addoninfo.storageID,1)
            npcHandler:say('Here it is.', cid)
        else
            npcHandler:say('You do not have the necessary items or money!', cid)
        end
        npcHandler:resetNpc()
        return true
    elseif (parameters.decline == true) then
        npcHandler:say('This does not interest you? Try another!', cid)
        npcHandler:resetNpc()
        return true
    end
    return false
end

local noNode = KeywordNode:new({'no'}, playerBuyAddonNPC, {decline = true})
local yesNode = KeywordNode:new({'yes'}, playerBuyAddonNPC, {confirm = true})
 
Last edited:
Back
Top