• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Mikolaj sie zbliza... skrypt

BugaS

Donżuan
Joined
Mar 12, 2009
Messages
1,219
Reaction score
9
Location
NYC
Witam, hohoho ;d

Mam taki skrypt:

LUA:
gifts = {
        {10, 7735, 1}, -- 1% to get Santa Hat [10]
        {30, 2348, 1}, -- 3% to get Santa Doll [30]
        {40, 2296, 1}, --  4% to get Teddy Bear [40]
        {100, 8982, 1}, -- 10% to get 10 Crystal Coins [100]
        {150, 6391, 1}, -- 15% to get 10 Candy Canes [150]
        {150, 2640, 1}, -- 15% to get 100 Platinum Coins [150]
        {200, 3968, 1}, -- 20% to get 10 Snowballs [200]
        {250, 5785, 1}, -- 25% to get 10 Orange [250]
        {350, 2160, 100}, -- 35% to get 10 Red Apples [350]
        {500, 9774, 1} -- 50% to get 10 Cookies [500]
}

PRESENT_STORAGE = 27875 -- Storage ID
time = 3 -- Hours

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, #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, os.time() + time * 60 * 60)
            npcHandler:say('HO-HO-HO! I have ' .. count .. getItemNameById(reward) .. ' for you.', cid)
        else
            npcHandler:say('Ho-Ho-Ho, Dalem Ci prezent wroc za '.. timeString(getPlayerStorageValue(cid, PRESENT_STORAGE) - os.time()).. '.', cid)
        end
    else
        npcHandler:say('Wroc jak bedzie gotowy.', cid)
    end
    npcHandler:resetNpc()
    return true
end

 
npcHandler:setMessage(MESSAGE_GREET, "HO-HO-HO, Merry Christmas |PLAYERNAME|. Mam prezenty! Wpisz 'prezent'.")

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

local node = keywordHandler:addKeyword({'prezent'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Byles grzeczny? tak czy nie?...'})
    node:addChildKeywordNode(yesNode)
    node:addChildKeywordNode(noNode)

npcHandler:addModule(FocusModule:new())

I nie działa w nim prawidłowo funkcja która ma powodować że co 3 godziny można brać item. Czas jest najpierw obliczany dobrze, ale gdy minie te 3h to pisze, że już dał item i że trzeba wrócić za 23h :|

Oto funkcja:

LUA:
  function timeString(timeDiff)
    local dateFormat = {
        {"day", timeDiff / 60 / 60 / 24},
        {"hour", timeDiff / 60 / 60 % 24},
        {"minute", timeDiff / 60 % 60},
        {"second", timeDiff % 60}
    }

    local out = {}
    for k, t in ipairs(dateFormat) do
        local v = math.floor(t[2])
        if(v > 0) then
            table.insert(out, (k < #dateFormat and (#out > 0 and ', ' or '') or ' and ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or ''))
        end
    end
   
    return table.concat(out)
end

Drugą sprawą jest minimalny lvl aby móc korzystać z tego NPC.
Proszę o pomoc!
 
Code:
if (getPlayerStorageValue(cid, PRESENT_STORAGE) < 1) then
zmień na
Code:
if (getPlayerStorageValue(cid, PRESENT_STORAGE) < os.time()) then
 
Back
Top