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

vocation for sale

lopez65

Member
Joined
May 10, 2012
Messages
289
Solutions
1
Reaction score
14
Location
Barcelona
Hello friends, I have a little doubt, try several days trying and I can not find the solution. I need to sell vocations on the web, the offers I can only make from phpadmin here I leave a sample. in the original way that it gives error in console


C++:
-- Extraindo dados da tabela `z_shop_offer`
--

INSERT INTO `z_shop_offer` (`id`, `points`, `itemid1`, `count1`, `itemid2`, `count2`, `offer_type`, `offer_description`, `offer_name`) VALUES
(1, 20, 12633, 1, 0, 0, 'item', 'Armor: 60 | Speed +25 | Ki Blasting +5 | Ki +3000/s.', 'Cell Helmet'),
(2, 10, 12661, 1, 0, 0, 'item', 'Armor: 150 | Ki Blasting +20 | Ki +3000/s.', 'Cell Armor'),
(3, 15, 12632, 1, 0, 0, 'item', 'Armor: 60 | Speed +20 | Sword +5 | Health & Ki +2000/s.', 'Janemba Helmet'),
(4, 10, 12654, 1, 0, 0, 'item', 'Armor: 125 | Sword +10 | Health & Ki +3000/s.', 'Janemba Armor'),
(5, 10, 12679, 1, 0, 0, 'item', 'Armor: 75 | Sword +5 | Health & Ki +3000/s.', 'Janemba Legs'),
(6, 10, 12689, 1, 0, 0, 'item', 'Armor: 30 | Health & Ki +2000/s.', 'Janemba Boots'),
(7, 10, 12660, 1, 0, 0, 'item', 'Armor: 150 | Speed +15 | Health & Ki +3500/s.', 'Fusion Armor'),
(8, 10, 12680, 1, 0, 0, 'item', 'Armor: 85 | Speed +15 | Health & Ki +3500/s.', 'Fusion Legs'),
(9, 10, 12694, 1, 0, 0, 'item', 'Armor: 75 | Speed +15 | Health & Ki +3000/s.', 'Fusion Boots'),
(11, 5, 12655, 1, 0, 0, 'item', 'Armor: 85 | Health +5000/3s.', 'Goku Armor'),
(12, 5, 12675, 0, 0, 0, 'item', 'Armor: 50 | Ki +5000/3s.', 'Goku Legs'),
(13, 7, 12693, 0, 0, 0, 'item', 'Armor: 50 | Health & Ki +5000/3s.', 'Goku Boots'),
(14, 6, 12678, 1, 0, 0, 'item', 'Armor: 75 | Health & Ki +2500/s.', 'Goku SSJ5 Legs'),
(15, 15, 12662, 1, 0, 0, 'item', 'Armor: 200 | All Skills +5 | Health & Ki +5000/s.', 'Legendary Armor'),
(16, 15, 12681, 1, 0, 0, 'item', 'Armor: 100 | Health & Ki +5000/s.', 'Legendary Legs'),
(17, 15, 12695, 1, 0, 0, 'item', 'Armor: 85 | Health & Ki +4000/s.', 'Legendary Boots'),
(18, 20, 12663, 1, 0, 0, 'item', 'Armor: 250 | All Skills +5 | Health & Ki +6500/s.', 'Supreme North Armor'),
(19, 20, 12682, 1, 0, 0, 'item', 'Armor: 150 | All Skills +5 | Health & Ki +6500/s.', 'Supreme North Legs'),
(20, 20, 12696, 1, 0, 0, 'item', 'Armor: 100 | Health & Ki +5000/s.', 'Supreme North Boots'),
(21, 25, 13497, 1, 0, 0, 'item', 'Armor: 150 | Speed +25 | Ki Level +5 | Health & Ki +7500/s.', 'Bills Armor'),
(22, 25, 13498, 1, 0, 0, 'item', 'Armor: 100 | Speed +50 | Ki Level +5 | Health & Ki +7500/s.', 'Bills Legs'),
(23, 25, 13499, 1, 0, 0, 'item', 'Armor: 65 | Speed +100| Ki Level +3 | Health & Ki +5000/s.', 'Bills Boots'),
(24, 15, 12714, 1, 0, 0, 'item', 'Atk: 20 | Def: 20 | Strenght +10 | Effect | Fast Attack.', 'Glove Of Lies'),
(25, 15, 12733, 1, 0, 0, 'item', 'Atk: 20 | Def: 20 | Sword +10 | Effect | Fast Attack.', 'Hell Janemba Sword'),
(26, 15, 13447, 1, 0, 0, 'item', 'Atk: 20 | Def: 20 | Weapon +10 | Effect | Fast Attack.', 'Elypson'),
(27, 20, 13467, 1, 0, 0, 'item', 'Atk: 25 Def: 25 | Attack Speed +10 Strenght & Defense +10 | Effect | Fast Attack.', 'Golden Crystal Glove'),
(28, 20, 13466, 1, 0, 0, 'item', 'Atk: 25 Def: 25 | Attack Speed +10 Sword & Defense +10 | Effect | Fast Attack.', 'Mystic Sword'),
(29, 20, 12734, 1, 0, 0, 'item', 'Atk: 25 Def: 25 | Attack Speed +10  Weapon & Defense +10 | Effect | Fast Attack.', 'Goku Staff'),
(30, 15, 12735, 1, 0, 0, 'item', 'Def: 100 | Protect All 5% | Speed +100', 'Shield Of Glory'),
(31, 15, 13398, 1, 0, 0, 'item', 'Def: 250 | Protect All 5% | Speed -100', 'Tortoiseshell'),
(32, 20, 12759, 1, 0, 0, 'item', 'Protect All 10%.', 'Earring Of Magic'),
(33, 20, 10220, 1, 0, 0, 'item', 'Protect All 10%.', 'Leviathans Amulet'),
(36, 30, 13484, 1, 0, 0, 'mounts', 'Transforme-se em um Shenron.', 'Vocação Shenron'),
(37, 30, 13485, 1, 0, 0, 'mounts', 'Transforme-se em um Vegetto.', 'Vocação Vegetto'),
(38, 30, 13486, 1, 0, 0, 'mounts', 'Transforme-se em um Tapion.', 'Vocação Tapion'),
(39, 30, 13487, 1, 0, 0, 'mounts', 'Transforme-se em um Kame.', 'Vocação Kame'),
(40, 30, 13488, 1, 0, 0, 'mounts', 'Transforme-se em um King Vegeta.', 'Vocação King Vegeta'),
(41, 30, 13489, 1, 0, 0, 'mounts', 'Transforme-se em uma Kagome.', 'Vocação Kagome'),
(42, 30, 13490, 1, 0, 0, 'mounts', 'Transforme-se em um Zaiko.', 'Vocação Zaiko'),
(43, 30, 13491, 1, 0, 0, 'mounts', 'Transforme-se em um Chilled.', 'Vocação Chilled'),
(44, 30, 13492, 1, 0, 0, 'mounts', 'Transforme-se em um C8.', 'Vocação C8'),
(45, 27, 9004, 1, 0, 0, 'addons', 'Premium Scroll de 90 dias.', 'Premium Scroll'),
(48, 10, 5958, 1, 0, 0, 'addons', 'Premium Scroll de 30 dias.', 'Premium Scroll'),
(49, 7, 5957, 1, 0, 0, 'addons', 'Premium Scroll de 10 dias.', 'Premium Scroll'),
(50, 5, 12289, 1, 0, 0, 'addons', 'Recupera toda a Stamina.', 'Stamina Potion'),
(51, 5, 7440, 1, 0, 0, 'addons', 'Remove todos frags unjustified do seu personagem.', 'Remover Unjust');

line 37 to 45
 
Hello friends, I have a little doubt, try several days trying and I can not find the solution. I need to sell vocations on the web, the offers I can only make from phpadmin here I leave a sample. in the original way that it gives error in console


C++:
-- Extraindo dados da tabela `z_shop_offer`
--

INSERT INTO `z_shop_offer` (`id`, `points`, `itemid1`, `count1`, `itemid2`, `count2`, `offer_type`, `offer_description`, `offer_name`) VALUES
(1, 20, 12633, 1, 0, 0, 'item', 'Armor: 60 | Speed +25 | Ki Blasting +5 | Ki +3000/s.', 'Cell Helmet'),
(2, 10, 12661, 1, 0, 0, 'item', 'Armor: 150 | Ki Blasting +20 | Ki +3000/s.', 'Cell Armor'),
(3, 15, 12632, 1, 0, 0, 'item', 'Armor: 60 | Speed +20 | Sword +5 | Health & Ki +2000/s.', 'Janemba Helmet'),
(4, 10, 12654, 1, 0, 0, 'item', 'Armor: 125 | Sword +10 | Health & Ki +3000/s.', 'Janemba Armor'),
(5, 10, 12679, 1, 0, 0, 'item', 'Armor: 75 | Sword +5 | Health & Ki +3000/s.', 'Janemba Legs'),
(6, 10, 12689, 1, 0, 0, 'item', 'Armor: 30 | Health & Ki +2000/s.', 'Janemba Boots'),
(7, 10, 12660, 1, 0, 0, 'item', 'Armor: 150 | Speed +15 | Health & Ki +3500/s.', 'Fusion Armor'),
(8, 10, 12680, 1, 0, 0, 'item', 'Armor: 85 | Speed +15 | Health & Ki +3500/s.', 'Fusion Legs'),
(9, 10, 12694, 1, 0, 0, 'item', 'Armor: 75 | Speed +15 | Health & Ki +3000/s.', 'Fusion Boots'),
(11, 5, 12655, 1, 0, 0, 'item', 'Armor: 85 | Health +5000/3s.', 'Goku Armor'),
(12, 5, 12675, 0, 0, 0, 'item', 'Armor: 50 | Ki +5000/3s.', 'Goku Legs'),
(13, 7, 12693, 0, 0, 0, 'item', 'Armor: 50 | Health & Ki +5000/3s.', 'Goku Boots'),
(14, 6, 12678, 1, 0, 0, 'item', 'Armor: 75 | Health & Ki +2500/s.', 'Goku SSJ5 Legs'),
(15, 15, 12662, 1, 0, 0, 'item', 'Armor: 200 | All Skills +5 | Health & Ki +5000/s.', 'Legendary Armor'),
(16, 15, 12681, 1, 0, 0, 'item', 'Armor: 100 | Health & Ki +5000/s.', 'Legendary Legs'),
(17, 15, 12695, 1, 0, 0, 'item', 'Armor: 85 | Health & Ki +4000/s.', 'Legendary Boots'),
(18, 20, 12663, 1, 0, 0, 'item', 'Armor: 250 | All Skills +5 | Health & Ki +6500/s.', 'Supreme North Armor'),
(19, 20, 12682, 1, 0, 0, 'item', 'Armor: 150 | All Skills +5 | Health & Ki +6500/s.', 'Supreme North Legs'),
(20, 20, 12696, 1, 0, 0, 'item', 'Armor: 100 | Health & Ki +5000/s.', 'Supreme North Boots'),
(21, 25, 13497, 1, 0, 0, 'item', 'Armor: 150 | Speed +25 | Ki Level +5 | Health & Ki +7500/s.', 'Bills Armor'),
(22, 25, 13498, 1, 0, 0, 'item', 'Armor: 100 | Speed +50 | Ki Level +5 | Health & Ki +7500/s.', 'Bills Legs'),
(23, 25, 13499, 1, 0, 0, 'item', 'Armor: 65 | Speed +100| Ki Level +3 | Health & Ki +5000/s.', 'Bills Boots'),
(24, 15, 12714, 1, 0, 0, 'item', 'Atk: 20 | Def: 20 | Strenght +10 | Effect | Fast Attack.', 'Glove Of Lies'),
(25, 15, 12733, 1, 0, 0, 'item', 'Atk: 20 | Def: 20 | Sword +10 | Effect | Fast Attack.', 'Hell Janemba Sword'),
(26, 15, 13447, 1, 0, 0, 'item', 'Atk: 20 | Def: 20 | Weapon +10 | Effect | Fast Attack.', 'Elypson'),
(27, 20, 13467, 1, 0, 0, 'item', 'Atk: 25 Def: 25 | Attack Speed +10 Strenght & Defense +10 | Effect | Fast Attack.', 'Golden Crystal Glove'),
(28, 20, 13466, 1, 0, 0, 'item', 'Atk: 25 Def: 25 | Attack Speed +10 Sword & Defense +10 | Effect | Fast Attack.', 'Mystic Sword'),
(29, 20, 12734, 1, 0, 0, 'item', 'Atk: 25 Def: 25 | Attack Speed +10  Weapon & Defense +10 | Effect | Fast Attack.', 'Goku Staff'),
(30, 15, 12735, 1, 0, 0, 'item', 'Def: 100 | Protect All 5% | Speed +100', 'Shield Of Glory'),
(31, 15, 13398, 1, 0, 0, 'item', 'Def: 250 | Protect All 5% | Speed -100', 'Tortoiseshell'),
(32, 20, 12759, 1, 0, 0, 'item', 'Protect All 10%.', 'Earring Of Magic'),
(33, 20, 10220, 1, 0, 0, 'item', 'Protect All 10%.', 'Leviathans Amulet'),
(36, 30, 13484, 1, 0, 0, 'mounts', 'Transforme-se em um Shenron.', 'Vocação Shenron'),
(37, 30, 13485, 1, 0, 0, 'mounts', 'Transforme-se em um Vegetto.', 'Vocação Vegetto'),
(38, 30, 13486, 1, 0, 0, 'mounts', 'Transforme-se em um Tapion.', 'Vocação Tapion'),
(39, 30, 13487, 1, 0, 0, 'mounts', 'Transforme-se em um Kame.', 'Vocação Kame'),
(40, 30, 13488, 1, 0, 0, 'mounts', 'Transforme-se em um King Vegeta.', 'Vocação King Vegeta'),
(41, 30, 13489, 1, 0, 0, 'mounts', 'Transforme-se em uma Kagome.', 'Vocação Kagome'),
(42, 30, 13490, 1, 0, 0, 'mounts', 'Transforme-se em um Zaiko.', 'Vocação Zaiko'),
(43, 30, 13491, 1, 0, 0, 'mounts', 'Transforme-se em um Chilled.', 'Vocação Chilled'),
(44, 30, 13492, 1, 0, 0, 'mounts', 'Transforme-se em um C8.', 'Vocação C8'),
(45, 27, 9004, 1, 0, 0, 'addons', 'Premium Scroll de 90 dias.', 'Premium Scroll'),
(48, 10, 5958, 1, 0, 0, 'addons', 'Premium Scroll de 30 dias.', 'Premium Scroll'),
(49, 7, 5957, 1, 0, 0, 'addons', 'Premium Scroll de 10 dias.', 'Premium Scroll'),
(50, 5, 12289, 1, 0, 0, 'addons', 'Recupera toda a Stamina.', 'Stamina Potion'),
(51, 5, 7440, 1, 0, 0, 'addons', 'Remove todos frags unjustified do seu personagem.', 'Remover Unjust');

line 37 to 45

Most likely the characters are the problem "Vocação"
Try to write Vocation insted and see if that fixes it.
 
You need to specify a correct charset for those letters. I am not sure but Vocação seems to have non valid UTF-8 letters, you need to use a different charset in this case...
 
have friends and put in sheron data base where are all the other vocations saved but I still give error not understood very well what they want to tell me if they can explain it a little more for noob I would appreciate it very much


https://i.gyazo.com/7964a1590d6a71d3ddf3971e2198a9b0.png

changes that I made added shenron in the database before there was no

(36, 30, 13484, 1, 0, 0, 'mounts', 'Transforme-se em um Shenron.', 'Vocation Shenron'),
 
have friends and put in sheron data base where are all the other vocations saved but I still give error not understood very well what they want to tell me if they can explain it a little more for noob I would appreciate it very much


https://i.gyazo.com/7964a1590d6a71d3ddf3971e2198a9b0.png

changes that I made added shenron in the database before there was no

(36, 30, 13484, 1, 0, 0, 'mounts', 'Transforme-se em um Shenron.', 'Vocation Shenron'),

Post the script
 
here globalevents

Lua:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
function onThink(interval, lastExecution)
    local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")
    if(result_plr:getID() ~= -1) then
        while(true) do
            id = tonumber(result_plr:getDataInt("id"))
            action = tostring(result_plr:getDataString("action"))
            delete = tonumber(result_plr:getDataInt("delete_it"))
            cid = getCreatureByName(tostring(result_plr:getDataString("name")))
            if isPlayer(cid) == TRUE then
                local itemtogive_id = tonumber(result_plr:getDataInt("param1"))
                local itemtogive_count = tonumber(result_plr:getDataInt("param2"))
                local container_id = tonumber(result_plr:getDataInt("param3"))
                local container_count = tonumber(result_plr:getDataInt("param4"))
                local add_item_type = tostring(result_plr:getDataString("param5"))
                local add_item_name = tostring(result_plr:getDataString("param6"))
                local received_item = 0
                local full_weight = 0
                if add_item_type == 'container' then
                    container_weight = getItemWeightById(container_id, 1)
                    if isItemRune(itemtogive_id) == TRUE then
                        items_weight = container_count * getItemWeightById(itemtogive_id, 1)
                    else
                        items_weight = container_count * getItemWeightById(itemtogive_id, itemtogive_count)
                    end
                    full_weight = items_weight + container_weight
                else
                    full_weight = getItemWeightById(itemtogive_id, itemtogive_count)
                    if isItemRune(itemtogive_id) == TRUE then
                        full_weight = getItemWeightById(itemtogive_id, 1)
                    else
                        full_weight = getItemWeightById(itemtogive_id, itemtogive_count)
                    end
                end
                local free_cap = getPlayerFreeCap(cid)
                if full_weight <= free_cap then
                    if add_item_type == 'container' then
                        local new_container = doCreateItemEx(container_id, 1)
                        local iter = 0
                        while iter ~= container_count do
                            doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
                            iter = iter + 1
                        end
                        received_item = doPlayerAddItemEx(cid, new_container)
                    else
                        local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
                        received_item = doPlayerAddItemEx(cid, new_item)
                    end
                    if received_item == RETURNVALUE_NOERROR then
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from OTS shop.')
                        db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                        db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                    else
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')
                    end
                else
                    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. It weight is '.. full_weight ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.')
                end
            end
            if not(result_plr:next()) then
                break
            end
        end
        result_plr:free()
    end
    return TRUE
end
 
here globalevents

Lua:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
function onThink(interval, lastExecution)
    local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")
    if(result_plr:getID() ~= -1) then
        while(true) do
            id = tonumber(result_plr:getDataInt("id"))
            action = tostring(result_plr:getDataString("action"))
            delete = tonumber(result_plr:getDataInt("delete_it"))
            cid = getCreatureByName(tostring(result_plr:getDataString("name")))
            if isPlayer(cid) == TRUE then
                local itemtogive_id = tonumber(result_plr:getDataInt("param1"))
                local itemtogive_count = tonumber(result_plr:getDataInt("param2"))
                local container_id = tonumber(result_plr:getDataInt("param3"))
                local container_count = tonumber(result_plr:getDataInt("param4"))
                local add_item_type = tostring(result_plr:getDataString("param5"))
                local add_item_name = tostring(result_plr:getDataString("param6"))
                local received_item = 0
                local full_weight = 0
                if add_item_type == 'container' then
                    container_weight = getItemWeightById(container_id, 1)
                    if isItemRune(itemtogive_id) == TRUE then
                        items_weight = container_count * getItemWeightById(itemtogive_id, 1)
                    else
                        items_weight = container_count * getItemWeightById(itemtogive_id, itemtogive_count)
                    end
                    full_weight = items_weight + container_weight
                else
                    full_weight = getItemWeightById(itemtogive_id, itemtogive_count)
                    if isItemRune(itemtogive_id) == TRUE then
                        full_weight = getItemWeightById(itemtogive_id, 1)
                    else
                        full_weight = getItemWeightById(itemtogive_id, itemtogive_count)
                    end
                end
                local free_cap = getPlayerFreeCap(cid)
                if full_weight <= free_cap then
                    if add_item_type == 'container' then
                        local new_container = doCreateItemEx(container_id, 1)
                        local iter = 0
                        while iter ~= container_count do
                            doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
                            iter = iter + 1
                        end
                        received_item = doPlayerAddItemEx(cid, new_container)
                    else
                        local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
                        received_item = doPlayerAddItemEx(cid, new_item)
                    end
                    if received_item == RETURNVALUE_NOERROR then
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from OTS shop.')
                        db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                        db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                    else
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')
                    end
                else
                    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. It weight is '.. full_weight ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.')
                end
            end
            if not(result_plr:next()) then
                break
            end
        end
        result_plr:free()
    end
    return TRUE
end

Start to print out the values in that if statment, full_weight and free_cap.
ex
Lua:
print(free_cap)

I guess full_weight would be the one throwing the wrong value, so if thats the case you need to track down where the boolean value is set insted of a number value - once again by using the print function.
 
new error console

https://i.gyazo.com/23356a0d3e3bf34db0294bc6096b3c80.png


What did you tell me to do something without?

Lua:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
function onThink(interval, lastExecution)
    local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")
    if(result_plr:getID() ~= -1) then
        while(true) do
            id = tonumber(result_plr:getDataInt("id"))
            action = tostring(result_plr:getDataString("action"))
            delete = tonumber(result_plr:getDataInt("delete_it"))
            cid = getCreatureByName(tostring(result_plr:getDataString("name")))
            if isPlayer(cid) == TRUE then
                local itemtogive_id = tonumber(result_plr:getDataInt("param1"))
                local itemtogive_count = tonumber(result_plr:getDataInt("param2"))
                local container_id = tonumber(result_plr:getDataInt("param3"))
                local container_count = tonumber(result_plr:getDataInt("param4"))
                local add_item_type = tostring(result_plr:getDataString("param5"))
                local add_item_name = tostring(result_plr:getDataString("param6"))
                local received_item = 0
                local free_cap = 0
                if add_item_type == 'container' then
                    container_weight = getItemWeightById(container_id, 1)
                    if isItemRune(itemtogive_id) == TRUE then
                        items_weight = container_count * getItemWeightById(itemtogive_id, 1)
                    else
                        items_weight = container_count * getItemWeightById(itemtogive_id, itemtogive_count)
                    end
                    free_cap = items_weight + container_weight
                else
                    free_cap = getItemWeightById(itemtogive_id, itemtogive_count)
                    if isItemRune(itemtogive_id) == TRUE then
                        free_cap = getItemWeightById(itemtogive_id, 1)
                    else
                        free_cap = getItemWeightById(itemtogive_id, itemtogive_count)
                    end
                end
                local free_cap = getPlayerFreeCap(cid)
                if free_cap <= free_cap then
                    if add_item_type == 'container' then
                        local new_container = doCreateItemEx(container_id, 1)
                        local iter = 0
                        while iter ~= container_count do
                            doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
                            iter = iter + 1
                        end
                        received_item = doPlayerAddItemEx(cid, new_container)
                    else
                        local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
                        received_item = doPlayerAddItemEx(cid, new_item)
                    end
                    if received_item == RETURNVALUE_NOERROR then
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from OTS shop.')
                        db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                        db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                    else
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')
                    end
                else
                    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. It weight is '.. free_cap ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.')
                end
            end
            if not(result_plr:next()) then
                break
            end
        end
        result_plr:free()
    end
    return TRUE
end

before making that change the items if I gave it the store to pray gives me infinite :S

https://i.gyazo.com/4e76249b98a68fca984bf1b3b202cf4c.png

they do not stop leaving cell helmets of the backpack xDDDDDDDD

I have been thinking, and if you know some npc that sells vocation with a specific currency, I can solve the problem from another method.
 
Last edited by a moderator:
new error console

https://i.gyazo.com/23356a0d3e3bf34db0294bc6096b3c80.png


What did you tell me to do something without?

Lua:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
function onThink(interval, lastExecution)
    local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")
    if(result_plr:getID() ~= -1) then
        while(true) do
            id = tonumber(result_plr:getDataInt("id"))
            action = tostring(result_plr:getDataString("action"))
            delete = tonumber(result_plr:getDataInt("delete_it"))
            cid = getCreatureByName(tostring(result_plr:getDataString("name")))
            if isPlayer(cid) == TRUE then
                local itemtogive_id = tonumber(result_plr:getDataInt("param1"))
                local itemtogive_count = tonumber(result_plr:getDataInt("param2"))
                local container_id = tonumber(result_plr:getDataInt("param3"))
                local container_count = tonumber(result_plr:getDataInt("param4"))
                local add_item_type = tostring(result_plr:getDataString("param5"))
                local add_item_name = tostring(result_plr:getDataString("param6"))
                local received_item = 0
                local free_cap = 0
                if add_item_type == 'container' then
                    container_weight = getItemWeightById(container_id, 1)
                    if isItemRune(itemtogive_id) == TRUE then
                        items_weight = container_count * getItemWeightById(itemtogive_id, 1)
                    else
                        items_weight = container_count * getItemWeightById(itemtogive_id, itemtogive_count)
                    end
                    free_cap = items_weight + container_weight
                else
                    free_cap = getItemWeightById(itemtogive_id, itemtogive_count)
                    if isItemRune(itemtogive_id) == TRUE then
                        free_cap = getItemWeightById(itemtogive_id, 1)
                    else
                        free_cap = getItemWeightById(itemtogive_id, itemtogive_count)
                    end
                end
                local free_cap = getPlayerFreeCap(cid)
                if free_cap <= free_cap then
                    if add_item_type == 'container' then
                        local new_container = doCreateItemEx(container_id, 1)
                        local iter = 0
                        while iter ~= container_count do
                            doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
                            iter = iter + 1
                        end
                        received_item = doPlayerAddItemEx(cid, new_container)
                    else
                        local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
                        received_item = doPlayerAddItemEx(cid, new_item)
                    end
                    if received_item == RETURNVALUE_NOERROR then
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from OTS shop.')
                        db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                        db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                    else
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')
                    end
                else
                    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. It weight is '.. free_cap ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.')
                end
            end
            if not(result_plr:next()) then
                break
            end
        end
        result_plr:free()
    end
    return TRUE
end

before making that change the items if I gave it the store to pray gives me infinite :S

https://i.gyazo.com/4e76249b98a68fca984bf1b3b202cf4c.png

they do not stop leaving cell helmets of the backpack xDDDDDDDD

I have been thinking, and if you know some npc that sells vocation with a specific currency, I can solve the problem from another method.

You need to print out values, using the print function;
Lua:
print(value)

In this case we wanna keep an eye on free_cap, since that seemd to be the problem.
Lua:
print(free_cap)

That should print out a number in your console (the cap the player has), if it prints out ex string, nil, boolean etc then you have a problem with that function.

I don't think there is any NPCs that sells vocations, you could change the NPC in Rookgaard or Dawnport to give players other vocations.
 
Back
Top