• 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 (New) Santa Claus

StreamSide

Joseluis Gonzalez
Support Team
Joined
Aug 31, 2007
Messages
3,482
Solutions
45
Reaction score
1,052
Location
Arica - Chile
this doesnt work for 8.60....

[24/11/2014 17:07:57] [Warning - Npc::loadFromXml] Cannot load npc file (data/npc/santa claus.xml).
[24/11/2014 17:07:57] Info: failed to load external entity "data/npc/santa claus.xml"
fix the route/name of the script
 

Oldschool'er

Tibia since 1998'
Joined
Dec 14, 2010
Messages
2,201
Reaction score
146
Location
United States
fix the route/name of the script
still says same thing....
Code:
[24/11/2014 17:25:02] [Warning - Npc::loadFromXml] Cannot load npc file (data/npc/santa.xml).
[24/11/2014 17:25:02] Info: failed to load external entity "data/npc/santa.xml"
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Santa Claus" script="santa.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="160" head="0" body="112" legs="93" feet="95"/>
</npc>

Code:
local PRESENT_STORAGE = 29885 -- Storage ID
local gifts = {
{10, 6531, 1}, -- 1% to get Santa Hat [10]
{30, 6512, 1}, -- 3% to get Santa Doll [30]
{40, 2112, 1}, -- 4% to get Teddy Bear [40]
{100, 2160, 10}, -- 10% to get 10 Crystal Coins [100]
{150, 2688, 10}, -- 15% to get 10 Candy Canes [150]
{150, 2152, 100}, -- 15% to get 100 Platinum Coins [150]
{200, 2111, 5}, -- 20% to get 10 Snowballs [200]
{500, 2687, 10} -- 50% to get 10 Cookies [500]
}

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

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 SantaNPC(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if (parameters.present == true) then
if (getPlayerStorageValue(cid, PRESENT_STORAGE) == 1) then
selfSay("Do not try to trick me! You have already recieved your present...", cid)
return true
end

local item = {}
local reward = 0
local count = ""
for i = 1, #gifts do
item = gifts
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! I have ' .. count .. getItemNameById(reward) .. ' for you.', cid)
else
npcHandler:say('Come back when you start behaving.', cid)
end
npcHandler:resetNpc()
return true
end

npcHandler:setMessage(MESSAGE_GREET, "HO-HO-HO, Merry Christmas |PLAYERNAME|. I have presents for the good children.")

local noNode = KeywordNode:new({'no'}, SantaNPC, {present = false})
local yesNode = KeywordNode:new({'yes'}, SantaNPC, {present = true})

local node = keywordHandler:addKeyword({'present'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Have you been well behaved and good this year?...'})
node:addChildKeywordNode(yesNode)
node:addChildKeywordNode(noNode)

npcHandler:addModule(FocusModule:new())

i /reload npcs and it just keeps giving me this
Code:
[24/11/2014 17:30:27] [Warning - Npc::loadFromXml] Cannot load npc file (data/npc/Santa Claus.xml).
[24/11/2014 17:30:27] Info: failed to load external entity "data/npc/Santa Claus.xml"
 
Last edited:

StreamSide

Joseluis Gonzalez
Support Team
Joined
Aug 31, 2007
Messages
3,482
Solutions
45
Reaction score
1,052
Location
Arica - Chile
still says same thing....
Code:
[24/11/2014 17:25:02] [Warning - Npc::loadFromXml] Cannot load npc file (data/npc/santa.xml).
[24/11/2014 17:25:02] Info: failed to load external entity "data/npc/santa.xml"
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Santa Claus" script="santa.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="160" head="0" body="112" legs="93" feet="95"/>
</npc>

Code:
local PRESENT_STORAGE = 29885 -- Storage ID
local gifts = {
{10, 6531, 1}, -- 1% to get Santa Hat [10]
{30, 6512, 1}, -- 3% to get Santa Doll [30]
{40, 2112, 1}, -- 4% to get Teddy Bear [40]
{100, 2160, 10}, -- 10% to get 10 Crystal Coins [100]
{150, 2688, 10}, -- 15% to get 10 Candy Canes [150]
{150, 2152, 100}, -- 15% to get 100 Platinum Coins [150]
{200, 2111, 5}, -- 20% to get 10 Snowballs [200]
{500, 2687, 10} -- 50% to get 10 Cookies [500]
}

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

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 SantaNPC(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if (parameters.present == true) then
if (getPlayerStorageValue(cid, PRESENT_STORAGE) == 1) then
selfSay("Do not try to trick me! You have already recieved your present...", cid)
return true
end

local item = {}
local reward = 0
local count = ""
for i = 1, #gifts do
item = gifts
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! I have ' .. count .. getItemNameById(reward) .. ' for you.', cid)
else
npcHandler:say('Come back when you start behaving.', cid)
end
npcHandler:resetNpc()
return true
end

npcHandler:setMessage(MESSAGE_GREET, "HO-HO-HO, Merry Christmas |PLAYERNAME|. I have presents for the good children.")

local noNode = KeywordNode:new({'no'}, SantaNPC, {present = false})
local yesNode = KeywordNode:new({'yes'}, SantaNPC, {present = true})

local node = keywordHandler:addKeyword({'present'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Have you been well behaved and good this year?...'})
node:addChildKeywordNode(yesNode)
node:addChildKeywordNode(noNode)

npcHandler:addModule(FocusModule:new())

i /reload npcs and it just keeps giving me this
Code:
[24/11/2014 17:30:27] [Warning - Npc::loadFromXml] Cannot load npc file (data/npc/Santa Claus.xml).
[24/11/2014 17:30:27] Info: failed to load external entity "data/npc/Santa Claus.xml"

when you copy the script, this part got this icon :eek:
Code:
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
just remove the :eek: and change it to ":eek:"
 

Oldschool'er

Tibia since 1998'
Joined
Dec 14, 2010
Messages
2,201
Reaction score
146
Location
United States
when you copy the script, this part got this icon :eek:
Code:
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
just remove the :eek: and change it to ":eek:"
look what you did....when i try to copy what you told me to change it says this...

Code:
just remove the :eek: and change it to ":eek:"
 

StreamSide

Joseluis Gonzalez
Support Team
Joined
Aug 31, 2007
Messages
3,482
Solutions
45
Reaction score
1,052
Location
Arica - Chile
look what you did....when i try to copy what you told me to change it says this...

Code:
just remove the :eek: and change it to ":eek:"
rofl
Code:
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
 

amoxicilina

New Member
Joined
Jun 25, 2010
Messages
50
Reaction score
1
Hi, I like the system, more like to make a modification for me, instead of being an item storage, npc remove the item and the player randomly wins one of the items in the list, could someone do it for me? Thank you !!
 

StreamSide

Joseluis Gonzalez
Support Team
Joined
Aug 31, 2007
Messages
3,482
Solutions
45
Reaction score
1,052
Location
Arica - Chile
Hi, I like the system, more like to make a modification for me, instead of being an item storage, npc remove the item and the player randomly wins one of the items in the list, could someone do it for me? Thank you !!
explain it better via pm and I will surely do it
 

amoxicilina

New Member
Joined
Jun 25, 2010
Messages
50
Reaction score
1
I managed to put the function I wanted in npc, if someone wants it with the function I said here is:

santaDoll = -- aqui voce coloca o itemId do Santa Doll

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

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

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 santaNPC(cid, message, keywords, parameters, node)

if(not npcHandler:isFocused(cid)) then
return false
end

if (parameters.present == true) then
if getPlayerItemCount(cid, santaDoll) >= 1 then
doPlayerRemoveItem(cid, santaDoll, 1)
local item = {}
local reward = 0
local count = ""

for i = 1, #random_items do
item = random_items
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 por ser bueno este año te dare ' .. count .. getItemNameById(reward) .. ' para ti.', cid)

else
npcHandler:say('Voce nao tem a Santa Doll', cid)
end
else
npcHandler:say('regresa cuando seas bueno.', cid)
end

npcHandler:resetNpc()
return true
end

npcHandler:setMessage(MESSAGE_GREET, "Feliz Navidad |PLAYERNAME|.HO HO HO Yo soy Santa Claus. Y te dare un regalo por ser un buen niño.")

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 = 'fuistes bueno este año?'})
node:addChildKeywordNode(yesNode)
node:addChildKeywordNode(noNode)
npcHandler:addModule(FocusModule:new())


to those who tried to help me, thank you very much.


I managed to put the function I wanted in npc, if someone wants it with the function I said here is:

santaDoll = -- aqui voce coloca o itemId do Santa Doll

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

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

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 santaNPC(cid, message, keywords, parameters, node)

if(not npcHandler:isFocused(cid)) then
return false
end

if (parameters.present == true) then
if getPlayerItemCount(cid, santaDoll) >= 1 then
doPlayerRemoveItem(cid, santaDoll, 1)
local item = {}
local reward = 0
local count = ""

for i = 1, #random_items do
item = random_items
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 por ser bueno este año te dare ' .. count .. getItemNameById(reward) .. ' para ti.', cid)

else
npcHandler:say('Voce nao tem a Santa Doll', cid)
end
else
npcHandler:say('regresa cuando seas bueno.', cid)
end

npcHandler:resetNpc()
return true
end

npcHandler:setMessage(MESSAGE_GREET, "Feliz Navidad |PLAYERNAME|.HO HO HO Yo soy Santa Claus. Y te dare un regalo por ser un buen niño.")

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 = 'fuistes bueno este año?'})
node:addChildKeywordNode(yesNode)
node:addChildKeywordNode(noNode)
npcHandler:addModule(FocusModule:new())


to those who tried to help me, thank you very much.
 
Last edited by a moderator:
Top