Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Para pessoal que usa o znote website:

 

Adicione esta em GlobalEvents / globalevents.xml

<globalevent name="Znote Shop" interval="30000" script="znoteShop.lua"/>

E vamos pra GlobalEvents / scripts e criar nova lua e nomeá-la 'znoteShop'

function onThink(interval, lastExecution)
    local players = Game.getPlayers()
    if #players == 0 then -- 0 players online, no need to execute the script
        return true
    end

    local player
    for i = 1, #players do
        player = players[i]
        local orderQuery = db.storeQuery('SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = '.. player:getAccountId() ..' LIMIT 1;')
        if orderQuery then --Lets check if the players online have orderd something from the shop
            local orderId = result.getDataInt(orderQuery, 'id')
            local orderType = result.getDataInt(orderQuery, 'type')
            local orderItemId = result.getDataInt(orderQuery, 'itemid')
            local orderCount = result.getDataInt(orderQuery, 'count')
            result.free(orderQuery)

            if orderType == 1 then
                if player:addItemEx(Game.createItem(orderItemId, orderCount or 1)) ~= RETURNVALUE_NOERROR or
                    player:getFreeCapacity() < ItemType(orderItemId):getWeight(orderCount or 1) then --Lets check if player have slot or cape left. Else send to player inbox

                    local parcel = player:getInbox():addItem(2596, 1, false, 1)
                    if not parcel then --If not being able to create parcel we stop the script and retry again.
                        print('[ERROR Znote Shop Globalevents] = Error on creating a parcel.')
                        return true
                    end

                    local letter = parcel:addItem(2598, 1, false, 1)
                    letter:setAttribute(ITEM_ATTRIBUTE_TEXT, 'You have received your shop item. Thanks for donating.')
                    parcel:addItem(orderItemId, orderCount or 1, false, 1)
                end
 
                db.query('DELETE FROM `znote_shop_orders` WHERE `id` = '.. orderId ..';')
                player:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations! You have received '.. orderCount ..'x '.. ItemType(orderItemId):getName() ..'!')
            end
        end
    end
    return true
end

Desfrutar

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo