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

{Request NPC} Santa Claus

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
After a long search, all Santa Claus NPC do not work 100% in dev 0.4.
Please I need a Npc with that options/chances. Thank You.

10% to get 10 Crystal Coins
15% to get 100 Platinum Coins
15% to get 10 Snowballs
15% to get 10 Cookies
15% to get Doll
15% to get bank
15% to get stone
15% to get christmas bundle
1% to get red gem
1% to get moon backpack
 
Try this o.0
Edit It Yourself :)

Santa Claus :
LUA:
<?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>



Santa.lua :
LUA:
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: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 (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
 
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())
 
10+15+15+15+15+15+15+15+1+1
117

qFf5L.png
?
 
Try this o.0
Edit It Yourself :)

Santa Claus :
LUA:
<?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>



Santa.lua :
LUA:
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: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 (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
 
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())

Still don't work fine, I tried with 15 chars, after it shows error in console like all scripts tried
 
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local presents = {
	[{1,   10}]	= {2160, 10},	-- 10%		10 crystal coins
	[{11,  25}]	= {2152, 100},	-- 15%		100 platinum coins
	[{26,  40}]	= {2111, 10},	-- 15%		10 snowballs
	[{41,  55}]	= {2687, 10},	-- 15%		10 cookies
	[{56,  70}]	= 2110,			-- 15%		doll
	[{71,  85}]	= 2114,			-- 15%		piggy bank
	[{86, 100}]	= 1294,			-- 15%		small stone
	[{101,105}]	= 6507,			-- 5%		red christmas bundle
	[{106,110}]	= 6508,			-- 5%		blue christmas bundle
	[{111,115}]	= 6509,			-- 5%		green christmas bundle
	[{116,116}]	= 2156,			-- 1%		red gem
	[{117,117}]	= 10521,		-- 1%		moon backpack
}

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 (msgcontains(msg, 'hello') or msgcontains(msg, 'hi')) and not npcHandler:isFocused(cid) then
		npcHandler:say('Merry Christmas, little '..getCreatureName(cid)..'!', cid)
		npcHandler:addFocus(cid)
	elseif not npcHandler:isFocused(cid) then
		return false
	elseif msgcontains(msg, 'present') then
		if getPlayerStorageValue(cid, 65054) == -1 then
			local rand = math.random(117)
			for k, v in pairs(presents) do
				if rand >= k[1] and rand <= k[2] then
					doPlayerAddItem(cid, type(v)=='table' and v[1] or v, type(v)=='table' and v[2] or 1)
					npcHandler:say('Here is your present! Enjoy!', cid)
					setPlayerStorageValue(cid, 65054, 1)
					break
				end
			end
		else
			npcHandler:say('You already got your present! Don\'t be greedy!', cid)
		end
		npcHandler:releaseFocus(cid)
	elseif msgcontains(msg, 'bye') or msgcontains(msg, 'farewell') then
		npcHandler:say('Farewell, '..getCreatureName(cid)..'!', cid)
		npcHandler:releaseFocus(cid)
	elseif msgcontains(msg, 'job') then
		npcHandler:say('Ho ho ho! You don\'t know Santa Claus? Never mind. You may ask me for a {present}.', cid)
	elseif msgcontains(msg, 'name') then
		npcHandler:say('Sorry, I don\'t have time to chat. Please ask for your present.', cid)
	end
	return true
end

npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye, little |PLAYERNAME|!')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
Last edited:
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local presents = {
	[{1,   10}]	= {2160, 10},	-- 10%		10 crystal coins
	[{11,  25}]	= {2152, 100},	-- 15%		100 platinum coins
	[{26,  40}]	= {2111, 10},	-- 15%		10 snowballs
	[{41,  55}]	= {2687, 10},	-- 15%		10 cookies
	[{56,  70}]	= 2110,			-- 15%		doll
	[{71,  85}]	= 2114,			-- 15%		piggy bank
	[{86, 100}]	= 1294,			-- 15%		small stone
	[{101,105}]	= 6507,			-- 5%		red christmas bundle
	[{106,110}]	= 6508,			-- 5%		blue christmas bundle
	[{111,115}]	= 6509,			-- 5%		green christmas bundle
	[{116,116}]	= 2156,			-- 1%		red gem
	[{117,117}]	= 10521,		-- 1%		moon backpack
}

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 (msgcontains(msg, 'hello') or msgcontains(msg, 'hi')) and not npcHandler:isFocused(cid) then
		npcHandler:say('Merry Christmas, little '..getCreatureName(cid)..'!', cid)
		npcHandler:addFocus(cid)
	elseif not npcHandler:isFocused(cid) then
		return false
	elseif msgcontains(msg, 'present') then
		if getPlayerStorageValue(cid, 65054) == -1 then
			local rand = math.random(117)
			for k, v in pairs(presents) do
				if rand >= k[1] and rand <= k[2] then
					doPlayerAddItem(cid, type(v)=='table' and v[1] or v, type(v)=='table' and v[2] or 1)
					npcHandler:say('Here is your present! Enjoy!', cid)
					setPlayerStorageValue(cid, 65054, 1)
					break
				end
			end
		else
			npcHandler:say('You already got your present! Don\'t be greedy!', cid)
		end
		npcHandler:releaseFocus(cid)
	elseif msgcontains(msg, 'bye') or msgcontains(msg, 'farewell') then
		npcHandler:say('Farewell, '..getCreatureName(cid)..'!', cid)
		npcHandler:releaseFocus(cid)
	elseif msgcontains(msg, 'job') then
		npcHandler:say('Ho ho ho! You don\'t know Santa Claus? Never mind. You may ask me for a {present}.', cid)
	elseif msgcontains(msg, 'name') then
		npcHandler:say('Sorry, I don\'t have time to chat. Please ask for your present.', cid)
	end
	return true
end

npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye, little |PLAYERNAME|!')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)


35066817.jpg
 
Back
Top