Coder Social home page Coder Social logo

Comments (4)

luanluciano93 avatar luanluciano93 commented on June 17, 2024 1

yes, KVs are saved only in Server Save and Server Shutdown

I think it's right that developers don't worry about "if it possibly crashes then" conditions, but worry about making the server not crash.

from canary.

pedrohfk avatar pedrohfk commented on June 17, 2024

I made a simple multishot and single shot system, using KV and actually during the open server at a certain point, it seems that the KV is lost, I don't know what the point is, I know that changing from 0 to 1 or 1 to 0 it simply return the default (in this case I did it to avoid null)

from canary.

elsongabriel avatar elsongabriel commented on June 17, 2024

Use our discord to ask questions. it's not a real issue.
but..
you can check your line local completed = player:kv():scoped("quests"):scoped('TEST QUEST'):get("completed") or false
if this is not null, return false, and continue your script.

from canary.

Decretis avatar Decretis commented on June 17, 2024

I'm not sure you understood what I meant. When a player logs off his Storages are saved to the database (KVs don't), so even if the server crashes after that, the player will not be able to collect the reward again. Take a look at the video I prepared.
@elsongabriel

kvvsstoragequest.mp4
local KVQuest = Action()

function KVQuest.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local completed = player:kv():scoped("quests"):scoped('TEST QUEST'):get("completed") or false

    if completed then
        player:say("[KVQuest]: Empty", TALKTYPE_MONSTER_SAY)
        return true
    end

    local reward = player:addItem(3365, 1)

    player:say("[KVQuest]: Reward", TALKTYPE_MONSTER_SAY)
    player:kv():scoped("quests"):scoped('TEST QUEST'):set("completed", true)

    return true
end

KVQuest:uid(50005)
KVQuest:register()

local StorageQuest = Action()

function StorageQuest.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local completed = player:getStorageValue(50006)

    if completed > 0 then
        player:say("[StorageQuest]: Empty", TALKTYPE_MONSTER_SAY)
        return true
    end

    local reward = player:addItem(3555, 1)
    player:say("[StorageQuest]: Reward", TALKTYPE_MONSTER_SAY)
    player:setStorageValue(50006, 1)

    return true
end

StorageQuest:uid(50006)
StorageQuest:register()

from canary.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.