Ir para conteúdo

Featured Replies

Postado
  • Este é um post popular.

Serei breve enquanto a explicação.
Esta função serve para "forçar" o value de uma storage key a mudar, independentemente do player estar on ou offline.

Adicione o seguinte script à lib do seu servidor (data\lib):

forceSetStorageValue = function (name, key, value)
    if not tostring(name) or not tonumber(key) then return nil end
    
    local p = getPlayerByName(name)
    
    if p then
        setPlayerStorageValue(p, key, value)
    else
        local have = db.storeQuery("SELECT `key` FROM `player_storage` WHERE `player_id` = ".. getPlayerGUIDByName(name) .." and `key` = ".. key)
        
        if have then
            db.query("UPDATE `player_storage` SET `value` = '".. value .."' WHERE `player_id` = '".. getPlayerGUIDByName(name) .."' AND `key` = ".. key)
        else
            db.query("INSERT INTO `player_storage` (`player_id` ,`key` ,`value`) VALUES ('".. getPlayerGUIDByName(name) .."', '".. key .."', '".. value .."');")
        end
    end
    
    return true
end




A seguir, preparei uma talkaction para o uso da função.

fstorage.lua (data\talkactions\scripts):

function onSay(cid, words, param)
    local w = string.explode(param, ",")
    
    if param == '' then
        return doPlayerSendCancel(cid, 'Enter the player name, the storage key and the storage value (number or string). Ex: /forcestorage Player, 1234, 5')
    elseif not tostring(w[1]) or not tonumber(w[2]) or not w[3] or w[4] then
        return doPlayerSendCancel(cid, 'Invalid parameter specified.')
    end
    
    forceSetStorageValue(w[1], w[2], w[3])
    return true
end




talkactions.xml (data\talkactions):

<talkaction log="yes" words="/forcestorage" access="5" event="script" value="fstorage.lua"/>

(o formato da tag varia de acordo com a versão do servidor utilizado)




Uso da talkaction:

/forcestorage Player, key, value
~
/forcestorage Wise, 1234, 5

Enfim, na minha mente ela me parece bem eficaz.
Espero que gostem.

The corrupt fear us.

The honest support us.

The heroic join us.

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo