• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Christmas[Pack]

Dalt0n

Hiho:)
Joined
Dec 14, 2011
Messages
536
Reaction score
31
Location
Italia
1º Paso.
Ir a...
tuot/data/action/script/

Create a lua with name "santadoll.lua".
And add this;

Code:
-- Script by DJ Death and Fixed by Miisael para Blacktibia--
local t = {
[1] = {2157},
[2] = {6531},
[3] = {2112},
[4] = {2111},
[5] = {2688}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[math.random(1,5)]
if v then
doPlayerAddItem (cid,v[1],1)
doPlayerSendTextMessage(cid,22,"JOJOJO Feliz Navidad!.")
doSendAnimatedText(getPlayerPosition(cid), "Regalo Otorgado!", math.random(1, 255))
doSendMagicEffect(getCreaturePosition(cid),12)
return TRUE
end
end

2º Paso.
go to
tuot/data/action/

Actions.xml add this;

Code:
<action itemid="6512" script="santadoll.lua" />

And with this finish a santa doll

Preview:
Santa1.png

Santa3.png

~~*Santa Claus*~~


1º Paso.
Go to.
tuot/data/npc/script/tuot/data/npc/script/

Create a lua,with name santa.lua
And add

Code:
local gifts = {
        {10, 6531, 1}, -- 1% to get Santa Hat [10]
        {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]
        {250, 2675, 10}, -- 25% to get 10 Orange [250]
        {350, 2674, 15}, -- 35% to get 10 Red Apples [350]
        {400, 6512, 1}, -- 40% to get Santa Doll [40]
    }

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
      selfSay("No me Pidas Mas ¬¬'! Ya te habia Dado un Regalo...", cid)
      return true
  end

        local item = {}
        local reward = 0
        local count = ""
        for i = 1, #gifts do
            item = gifts[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! Tengo ' .. count .. getItemNameById(reward) .. ' para ti :).', cid)
    else
        npcHandler:say('Vuele hasta la Otra Navidad c:', cid)
    end
    npcHandler:resetNpc()
    return true
end

npcHandler:setMessage(MESSAGE_GREET, "HO-HO-HO, Feliz Navidad |PLAYERNAME|. Yo Tengo Regalos para los que se Portan Mal.")

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

local node = keywordHandler:addKeyword({'regalo'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Te Haz Portado Mal En Este Año?...'})
    node:addChildKeywordNode(yesNode)
    node:addChildKeywordNode(noNode)

npcHandler:addModule(FocusModule:new())


3º Paso.
Ir a...
tuot/data/npc/

Create a xml,with name "Santa Claus.xml"
and add;
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>


with this finish,the npc!

Preview:
Santa2.png

Santa4.png

Lucky,and thanks(;

Creditos:
Unise -> 100% Santa Claus
Miisael -> 50% Santa Doll
ĐJ ĐєaŦђ -> 50 Santa Doll
 
Npc error --
[20/12/2012 15:42:19] [Error - NpcScript Interface]
[20/12/2012 15:42:19] data/npc/scripts/santa.lua:eek:nCreatureSay
[20/12/2012 15:42:19] Description:
[20/12/2012 15:42:19] (luaDoPlayerAddItem) Item not found

[20/12/2012 15:42:19] [Error - NpcScript Interface]
[20/12/2012 15:42:19] data/npc/scripts/santa.lua:eek:nCreatureSay
[20/12/2012 15:42:19] Description:
[20/12/2012 15:42:19] data/lib/100-shortcut.lua:260: attempt to index a boolean value
[20/12/2012 15:42:19] stack traceback:
[20/12/2012 15:42:19] data/lib/100-shortcut.lua:260: in function 'getItemNameById'
[20/12/2012 15:42:19] data/npc/scripts/santa.lua:54: in function 'callback'
[20/12/2012 15:42:19] data/npc/lib/npcsystem/keywordhandler.lua:42: in function 'processMessage'
[20/12/2012 15:42:19] data/npc/lib/npcsystem/keywordhandler.lua:177: in function 'processNodeMessage'
[20/12/2012 15:42:19] data/npc/lib/npcsystem/keywordhandler.lua:129: in function 'processMessage'
[20/12/2012 15:42:19] data/npc/lib/npcsystem/npchandler.lua:453: in function 'onCreatureSay'
[20/12/2012 15:42:19] data/npc/scripts/santa.lua:20: in function <data/npc/scripts/santa.lua:20>

Fix down!
 
Last edited:
opaa i use this one and works very good for me, + it's english version...

Try this..

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())
and if still errors , so that's your lib problem ;s i will try fix on morning..
 
I only edit items and get same error :S
EDIT : i can solves this bugs.. if for this i thinks..

if (math.random(0,999) < item[1]) then
if ramdom get .. 500 ... and i have

{400, 6512, 1} -- lasted items..

Get bug!
you need put
{999, 6512, 1} -- and working =)
 
Last edited:
Back
Top