S
Shadow_
Guest
Hey guys,
I got santa NPC in 1.X couldn't find it here before, so I decided to share it with the community for this Christmas celebrations to be in your server ^^.
Santa.xml
santa.lua
This NPC should give each player 1 reward from the array in the top of the lua file.
Cheers
I got santa NPC in 1.X couldn't find it here before, so I decided to share it with the community for this Christmas celebrations to be in your server ^^.
Santa.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Santa Claus" script="santa.lua" walkinterval="0" speed="100" walkradius="0" floorchange="0">
<health max="100" now="100"/>
<look type="634" head="0" body="94" legs="94" feet="0" addons="3" mount="644"/>
<parameters>
<parameter key="message_greet" value="Merry Christmas |PLAYERNAME|. I'm Santa Claus. I got {present}s for good children."/>
</parameters>
</npc>
Lua:
local random_items = {
{chance = 5, itemid = 2112}, -- 0.5% to get teddy bear
{chance = 20, itemid = 6512}, -- 2% to get santa doll
{chance = 40, itemid = 2114}, -- 4% to get piggy bank
{chance = 40, itemid = 15515, count = 50},
{chance = 80, itemid = 2111, count = 5},
{chance = 80, itemid = 2688, count = 8},
{chance = 80, itemid = 2110, count = 1},
{chance = 400, itemid = 2688, count = 15},
{chance = 100, itemid = 6527, count = 1},
{chance = 100, itemid = 24115, count = 1},
{chance = 100, itemid = 21401, count = 1},
{chance = 100, itemid = 11259, count = 1},
{chance = 300, itemid = 15515, count = 20},
{chance = 200, itemid = 26439, count = 4},
{chance = 200, itemid = 26443, count = 2},
{chance = 200, itemid = 26442, count = 4},
{chance = 200, itemid = 26441, count = 4},
{chance = 200, itemid = 26440, count = 4},
{chance = 50, itemid = 9653, count = 1},
{chance = 150, itemid = 18423, count = 5},
{chance = 150, itemid = 18422, count = 5},
{chance = 150, itemid = 26144, count = 5},
{chance = 100, itemid = 26147, count = 1},
{chance = 100, itemid = 26148, count = 1},
{chance = 100, itemid = 26149, count = 1},
{chance = 250, itemid = 18413, count = 20},
{chance = 250, itemid = 18414, count = 20},
{chance = 250, itemid = 18415, count = 20},
}
local PRESENT_TIMER = 54164
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
local voices = {
{ text = 'HO HO HO! MERRY CHRISTMAS', yell = true },
{ text = 'Hi there young ones, have you been good this year?' }
}
local PRESENT_STORAGE = 88888
function santaNPC(cid, message, keywords, present, node)
if not npcHandler:isFocused(cid) then
return false
end
if not present then
npcHandler:say('Come back when you start behaving good.', cid)
return true
end
local player = Player(cid)
local item, reward = nil, {}
for i = 1, #random_items do
item = random_items
if math.random(1000) < item[i].chance then
reward.itemid = item[i].itemid
reward.subType = item[i].count or 1
break
end
end
if player:getStorageValue(PRESENT_STORAGE) <= os.time() then
player:addItem(reward.itemid, reward.subType)
npcHandler:say("HO HO HO! You were good like a little dwarf this year!", cid)
npcHandler:resetNpc()
player:setStorageValue(PRESENT_STORAGE, os.time() + (24 * 60 * 60)) -- sets the next time for 1 day later than current time
return true
else
npcHandler:say('You\'ve already received a present, come back tomorrow', cid)
end
end
npcHandler:setMessage(MESSAGE_GREET, "Merry Christmas |PLAYERNAME|. I'm Santa Claus. I got {present}s for good children.")
local node = keywordHandler:addKeyword({'present'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Were you good this year?'})
node:addChildKeywordNode(KeywordNode:new({'yes'}, santaNPC, true))
node:addChildKeywordNode(KeywordNode:new({'no'}, santaNPC, false))
npcHandler:addModule(FocusModule:new())
Cheers
Last edited by a moderator: