• 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!

AAC Gesior Shop.lua

bok

Member
Joined
Apr 28, 2009
Messages
332
Reaction score
6
Location
127.0.0.1/Brasil/Goias
shop.lua
Lua:
function onThink(interval, lastExecution)
 
    local queryShop = db.storeQuery('SELECT * FROM `z_ots_comunication`')
    if queryShop ~= false then
        repeat
            local id, player = result.getNumber(queryShop, 'id'), Player(result.getString(queryShop, 'name'))
            if player then
                local item_id, item_count = result.getNumber(queryShop, 'param1'), result.getNumber(queryShop, 'param2')
                local container_id, container_count = result.getNumber(queryShop, 'param3'), result.getNumber(queryShop, 'param4')
                local offer_type = result.getString(queryShop, 'param5')
                local item_name = result.getString(queryShop, 'param6')

                -- ITEM
                if offer_type == 'item' then
                    player:getInbox():addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do OT Shop em seu depot.')
           
                -- ITEM NEWS
           
                elseif offer_type == 'novos' then
                    player:getInbox():addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do OT Shop em seu depot.')
               
                -- ITEM UMBRAL
           
                elseif offer_type == 'umbral' then
                    player:getInbox():addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do OT Shop em seu depot.')
               
               
                -- ITEM CUSTOM
           
                elseif offer_type == 'custom' then
                    player:getInbox():addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do OT Shop em seu depot.')
               
                -- CONTAINER
                elseif offer_type == 'container' then
                    local container_id, container_count = result.getNumber(queryShop, 'param3'), result.getNumber(queryShop, 'param4')
                    local i, new_container = 0, player:getInbox():addItem(container_id, 1, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    while i ~= container_count do
                        new_container:addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
                        i = i + 1
                    end
           
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do OT Shop em seu depot.')
           
                -- ADDON
                elseif offer_type == 'addon' then
                    player:addOutfitAddon(item_id, 3)
                    player:addOutfitAddon(item_count, 3)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..'.')
               
                -- MOUNT
                elseif offer_type == 'mount' then
                    player:addMount(item_id)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..'.')
                end

                db.asyncQuery('DELETE FROM `z_ots_comunication` WHERE `id` = ' .. id)
                db.asyncQuery('UPDATE `z_shop_history_item` SET `trans_state` = \'realized\', `trans_real` = ' .. os.time() .. ' WHERE id = ' .. id)
            end
   
        until not result.next(queryShop)
        result.free(queryShop)
    end

    return true
end
Would it be possible to add Premium Account to deliver to shop.lua?

Edit: My TFS 1.2x
SQL:
PHP:
INSERT INTO `z_ots_comunication` (`id`, `name`, `type`, `action`, `param1`, `param2`, `param3`, `param4`, `param5`, `param6`, `param7`, `delete_it`) VALUES
(ID, 'Player Name', 'login', 'pacc', '0', '15(Days)', 'Null', 'Null', 'Null', '15x Days of Premium Account( Offer Name)', 'Null', 1);
 
Last edited:
Solution
@WibbenZ

Is correct?

Lua:
-- <globalevent name="shop" interval="30000" script="others/shop.lua"/>

function onThink(interval, lastExecution)
    local queryShop = db.storeQuery('SELECT * FROM `z_ots_comunication`')
    if queryShop ~= false then
        repeat
            local id, player = result.getNumber(queryShop, 'id'), Player(result.getString(queryShop, 'name'))
            if player then
                local item_id, item_count = result.getNumber(queryShop, 'param1'), result.getNumber(queryShop, 'param2')
                local container_id, container_count = result.getNumber(queryShop, 'param3'), result.getNumber(queryShop, 'param4')
                local offer_type = result.getString(queryShop, 'param5')...
Yes it it posible, by using Player:addPremiumDays(days)
You still need to modify shopsystem.php but this should work, also merged all the "items"
Lua:
function onThink(interval, lastExecution)
    local queryShop = db.storeQuery('SELECT * FROM `z_ots_comunication`')
    if queryShop ~= false then
        repeat
            local id, player = result.getNumber(queryShop, 'id'), Player(result.getString(queryShop, 'name'))
            if player then
                local item_id, item_count = result.getNumber(queryShop, 'param1'), result.getNumber(queryShop, 'param2')
                local container_id, container_count = result.getNumber(queryShop, 'param3'), result.getNumber(queryShop, 'param4')
                local offer_type = result.getString(queryShop, 'param5')
                local item_name = result.getString(queryShop, 'param6')

                -- ITEMS
                if isInArray({'item', 'novos', 'umbral', 'custom', offer_type}) then
                    player:getInbox():addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do Edge OT Shop em seu depot.')

                -- CONTAINER
                elseif offer_type == 'container' then
                    local container_id, container_count = result.getNumber(queryShop, 'param3'), result.getNumber(queryShop, 'param4')
                    local i, new_container = 0, player:getInbox():addItem(container_id, 1, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    while i ~= container_count do
                        new_container:addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
                        i = i + 1
                    end

                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do OT Shop em seu depot.')

                -- ADDON
                elseif offer_type == 'addon' then
                    player:addOutfitAddon(item_id, 3)
                    player:addOutfitAddon(item_count, 3)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..'.')

                -- MOUNT
                elseif offer_type == 'mount' then
                    player:addMount(item_id)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..'.')
                elseif offer_type == 'premium' then
                    player:addPremiumDays(30)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..'.')
                end

                db.asyncQuery('DELETE FROM `z_ots_comunication` WHERE `id` = ' .. id)
                db.asyncQuery('UPDATE `z_shop_history_item` SET `trans_state` = \'realized\', `trans_real` = ' .. os.time() .. ' WHERE id = ' .. id)
            end

        until not result.next(queryShop)
        result.free(queryShop)
    end

    return true
end
 
Yes it it posible, by using Player:addPremiumDays(days)
You still need to modify shopsystem.php but this should work, also merged all the "items"
Lua:
function onThink(interval, lastExecution)
    local queryShop = db.storeQuery('SELECT * FROM `z_ots_comunication`')
    if queryShop ~= false then
        repeat
            local id, player = result.getNumber(queryShop, 'id'), Player(result.getString(queryShop, 'name'))
            if player then
                local item_id, item_count = result.getNumber(queryShop, 'param1'), result.getNumber(queryShop, 'param2')
                local container_id, container_count = result.getNumber(queryShop, 'param3'), result.getNumber(queryShop, 'param4')
                local offer_type = result.getString(queryShop, 'param5')
                local item_name = result.getString(queryShop, 'param6')

                -- ITEMS
                if isInArray({'item', 'novos', 'umbral', 'custom', offer_type}) then
                    player:getInbox():addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do OT Shop em seu depot.')

                -- CONTAINER
                elseif offer_type == 'container' then
                    local container_id, container_count = result.getNumber(queryShop, 'param3'), result.getNumber(queryShop, 'param4')
                    local i, new_container = 0, player:getInbox():addItem(container_id, 1, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    while i ~= container_count do
                        new_container:addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
                        i = i + 1
                    end

                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do OT Shop em seu depot.')

                -- ADDON
                elseif offer_type == 'addon' then
                    player:addOutfitAddon(item_id, 3)
                    player:addOutfitAddon(item_count, 3)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..'.')

                -- MOUNT
                elseif offer_type == 'mount' then
                    player:addMount(item_id)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..'.')
                elseif offer_type == 'premium' then
                    player:addPremiumDays(30)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..'.')
                end

                db.asyncQuery('DELETE FROM `z_ots_comunication` WHERE `id` = ' .. id)
                db.asyncQuery('UPDATE `z_shop_history_item` SET `trans_state` = \'realized\', `trans_real` = ' .. os.time() .. ' WHERE id = ' .. id)
            end

        until not result.next(queryShop)
        result.free(queryShop)
    end

    return true
end
In this case would the player: addPremiumDays (30) command add 30 days of Premium Account?
Because in Param2 it is the days to be increased.


SQL for shopsystem.php
PHP:
NSERT INTO `z_ots_comunication` (`id`, `name`, `type`, `action`, `param1`, `param2`, `param3`, `param4`, `param5`, `param6`, `param7`, `delete_it`) VALUES
(ID, 'Player Name', 'login', 'pacc', '0', '15  (Days)', '0', '0', 'premium', '15x Days of Premium Account', '0', 1);

Is there a possibility that this same script "shop.lua" will change the character's sex?
 
Last edited:
In this case would the player: addPremiumDays (30) command add 30 days of Premium Account?
Because in Param2 it is the days to be increased.


SQL for shopsystem.php
PHP:
NSERT INTO `z_ots_comunication` (`id`, `name`, `type`, `action`, `param1`, `param2`, `param3`, `param4`, `param5`, `param6`, `param7`, `delete_it`) VALUES
(ID, 'Player Name', 'login', 'pacc', '0', '15  (Days)', '0', '0', 'premium', '15x Days of Premium Account', '0', 1);

Is there a possibility that this same script "shop.lua" will change the character's sex?

You could use any of the parameters for the amount of days, check what you did in your database and shopsystem.php to see which one to use.
In the case of this query you can't use 15 (Days) it has to be an integer (a number value), use param1 or param3 and set that to 15.
Or remove (Days) and print that out in shopsystem.php insted.

By itself no :p
But you can add the code to do make it posible to do a sex change.
Lua:
player:setSex(player:getSex() == PLAYERSEX_MALE and PLAYERSEX_FEMALE or PLAYERSEX_MALE)
 
@WibbenZ

Is correct?

Lua:
-- <globalevent name="shop" interval="30000" script="others/shop.lua"/>

function onThink(interval, lastExecution)
    local queryShop = db.storeQuery('SELECT * FROM `z_ots_comunication`')
    if queryShop ~= false then
        repeat
            local id, player = result.getNumber(queryShop, 'id'), Player(result.getString(queryShop, 'name'))
            if player then
                local item_id, item_count = result.getNumber(queryShop, 'param1'), result.getNumber(queryShop, 'param2')
                local container_id, container_count = result.getNumber(queryShop, 'param3'), result.getNumber(queryShop, 'param4')
                local offer_type = result.getString(queryShop, 'param5')
                local item_name = result.getString(queryShop, 'param6')
                -- ITEMS
                if isInArray({'item', 'novos', 'umbral', 'custom', offer_type}) then
                    player:getInbox():addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do Shop em seu depot.')
                -- CONTAINER
                elseif offer_type == 'container' then
                    local container_id, container_count = result.getNumber(queryShop, 'param3'), result.getNumber(queryShop, 'param4')
                    local i, new_container = 0, player:getInbox():addItem(container_id, 1, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    while i ~= container_count do
                        new_container:addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
                        i = i + 1
                    end
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do Shop em seu depot.')
                -- ADDON
                elseif offer_type == 'addon' then
                    player:addOutfitAddon(item_id, 3)
                    player:addOutfitAddon(item_count, 3)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do Shop.')
                -- MOUNT
                elseif offer_type == 'mount' then
                    player:addMount(item_id)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do Shop.')
               
                -- Premium Account
                elseif offer_type == 'premium' then
                    player:addPremiumDays(queryShop, 'param2')
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do Shop.')
                end
               
                -- Change Sex
                elseif offer_type == 'sex' then
                    player:setSex(player:getSex() == PLAYERSEX_MALE and PLAYERSEX_FEMALE or PLAYERSEX_MALE)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do Shop.')
                end
                db.asyncQuery('DELETE FROM `z_ots_comunication` WHERE `id` = ' .. id)
                db.asyncQuery('UPDATE `z_shop_history_item` SET `trans_state` = \'realized\', `trans_real` = ' .. os.time() .. ' WHERE id = ' .. id)
            end
        until not result.next(queryShop)
        result.free(queryShop)
    end
    return true
end
 
@WibbenZ

Is correct?

Lua:
-- <globalevent name="shop" interval="30000" script="others/shop.lua"/>

function onThink(interval, lastExecution)
    local queryShop = db.storeQuery('SELECT * FROM `z_ots_comunication`')
    if queryShop ~= false then
        repeat
            local id, player = result.getNumber(queryShop, 'id'), Player(result.getString(queryShop, 'name'))
            if player then
                local item_id, item_count = result.getNumber(queryShop, 'param1'), result.getNumber(queryShop, 'param2')
                local container_id, container_count = result.getNumber(queryShop, 'param3'), result.getNumber(queryShop, 'param4')
                local offer_type = result.getString(queryShop, 'param5')
                local item_name = result.getString(queryShop, 'param6')
                -- ITEMS
                if isInArray({'item', 'novos', 'umbral', 'custom', offer_type}) then
                    player:getInbox():addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do Shop em seu depot.')
                -- CONTAINER
                elseif offer_type == 'container' then
                    local container_id, container_count = result.getNumber(queryShop, 'param3'), result.getNumber(queryShop, 'param4')
                    local i, new_container = 0, player:getInbox():addItem(container_id, 1, INDEX_WHEREEVER, FLAG_NOLIMIT)
                    while i ~= container_count do
                        new_container:addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
                        i = i + 1
                    end
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do Shop em seu depot.')
                -- ADDON
                elseif offer_type == 'addon' then
                    player:addOutfitAddon(item_id, 3)
                    player:addOutfitAddon(item_count, 3)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do Shop.')
                -- MOUNT
                elseif offer_type == 'mount' then
                    player:addMount(item_id)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do Shop.')
             
                -- Premium Account
                elseif offer_type == 'premium' then
                    player:addPremiumDays(queryShop, 'param2')
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do Shop.')
                end
             
                -- Change Sex
                elseif offer_type == 'sex' then
                    player:setSex(player:getSex() == PLAYERSEX_MALE and PLAYERSEX_FEMALE or PLAYERSEX_MALE)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do Shop.')
                end
                db.asyncQuery('DELETE FROM `z_ots_comunication` WHERE `id` = ' .. id)
                db.asyncQuery('UPDATE `z_shop_history_item` SET `trans_state` = \'realized\', `trans_real` = ' .. os.time() .. ' WHERE id = ' .. id)
            end
        until not result.next(queryShop)
        result.free(queryShop)
    end
    return true
end

No use item_count insted of 'param2', look at line 9
 
Solution
Back
Top