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

NPC Santa Claus

[21/12/2009 17:31:32] luaDoCreateNpc(). Npc name(santa claus) not found
[21/12/2009 17:31:36] Raker has logged in.
[21/12/2009 17:31:41] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/santa.lua
[21/12/2009 17:31:41] data/npc/scripts/santa.lua:1: unexpected symbol near '{'

What program you use to edit scripts?

Use Notepad++, try again and reply:p
 
doesnt work for 8.60......

[24/11/2014 17:12:35] [Warning - Npc::loadFromXml] Cannot load npc file (data/npc/santa claus.xml).
[24/11/2014 17:12:35] Info: failed to load external entity "data/npc/santa claus.xml"
 
Change script="data/npc/scripts/santa.lua" to script="santa.lua"
 
Sorry for bumping this old thread! I have this script:
Code:
random_items = {
{5,2112,1}, --  0.5% to get teddy bear
{20,6512,1}, -- 2% to get santa doll
{40,2114,1}, -- 4% to get piggy bank
{80,2111,5}, -- 8% to get 5 snowballs
{80,2688,8}, -- 8% to get 8 candy canes
{80,2110,1}, -- 8% to get doll
{400,2674,15}, -- 40% to get 15 red apples
{450,2675,10}, -- 45% to get 10 oranges
{1000,2687,8} -- 100% to get 8 cookies
}
PRESENT_STORAGE = 54163 -- storage ID
minLevelReq = 80
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
function santaNPC(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    if (getPlayerLevel(cid) >= minLevelReq and isPremium(cid) == TRUE) then
        if (parameters.present == true) then
            if (getPlayerStorageValue(cid, PRESENT_STORAGE) < 1) then
                local item = {}
                local reward = 0
                local count = ""
                for i = 1, #random_items do
                    item = random_items[i]
                    if (math.random(0,999) < item[1]) then
                        reward = item[2]
                        subType = item[3]
                        if subType > 1 then
                            count = subType .. " "
                        end
                        break
                    end
                end
                doPlayerAddItem(cid, reward, subType)
                setPlayerStorageValue(cid, PRESENT_STORAGE, 1)
                npcHandler:say('HO HO HO! You were good like a little dwarf this year! I got ' .. count .. getItemNameById(reward) .. ' for you.', cid)
            else
                npcHandler:say('I gave you a present already.', cid)
            end
        else
            npcHandler:say('Come back when you start behaving good.', cid)
        end
        npcHandler:resetNpc()
        return true
    end
end
npcHandler:setMessage(MESSAGE_GREET, "Merry Christmas |PLAYERNAME|. I'm Santa Claus. I got presents for good children.")
local noNode = KeywordNode:new({'no'}, santaNPC, {present = false})
local yesNode = KeywordNode:new({'yes'}, santaNPC, {present = true})
local node = keywordHandler:addKeyword({'pre'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Were you good this year?'})
    node:addChildKeywordNode(yesNode)
    node:addChildKeywordNode(noNode)
npcHandler:addModule(FocusModule:new())

But I need to send mensage if player doesnt have enought level to receive the gift! Something like
Code:
if minLevelReq = 80 then 
npcHandler:say('You dont have enought level to receive gift!', cid)

Thanks in advance!!

Sorry for double-posting. I saw that my NPC doesnt say any message after giving the present, or if u already have pick the present. I guess that npcHandler:say function is not working, what i should use in replacement on tfs 0.3??? thanks!!
 
Last edited by a moderator:
Back
Top