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

Shop.lua bugged

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
This script is sending to much items to the player, and didn't stop sending. Example, less than a 30 seconds I got this

MKRtd4.png


mu1U9t.png


Code:
function onThink()
    local q = db.getResult("SELECT * FROM z_ots_comunication")
    if q:getID() ~= -1 then
        repeat
            local cid = getPlayerByGUID(q:getDataInt("guid"))
            if cid ~= nil then
                local type = q:getDataString("param5")
                local name = q:getDataString("param6")

                local itemid, count
                local container_id, container_count
                local weight, item = 0

                local pack
                if type == 'package' then
                    itemid = q:getDataString("param1")
                    count = q:getDataString("param2")

                    local id, n = string.explode(itemid, ','), string.explode(count, ',')

                    pack = doCreateItemEx(#id > 8 and 1988 or 1987)
                    for i = 1, #id do
                        doAddContainerItem(pack, id[i], n[i] or 1)
                        doItemSetAttribute(new_container, "description", 'Bought by ' .. getCreatureName(cid) .. ' [ID:' .. id .. '].')
                    end
                    weight = getItemWeight(pack)
                else
                    itemid = q:getDataInt("param1")
                    count = q:getDataInt("param2")

                    if type == 'container' then
                        container_id = q:getDataInt("param3")
                        container_count = q:getDataInt("param4")
                        weight = container_count * getItemWeightById(itemid, count) + getItemWeightById(container_id)
                    else
                        weight = getItemWeightById(itemid, count)
                    end
                end
                if weight <= getPlayerFreeCap(cid) then
                    if type == 'container' then
                        local bp = doCreateItemEx(container_id)
                        for i = 1, container_count do
                            doAddContainerItem(bp, itemid, count)
                        end
                        item = doPlayerAddItemEx(cid, bp)
                    else
                        item = doPlayerAddItemEx(cid, type == 'package' and pack or doCreateItemEx(itemid, count))
                        doItemSetAttribute(new_container, "description", 'Bought by ' .. getCreatureName(cid) .. ' [ID:' .. id .. '].')
                    end

                    if item == RETURNVALUE_NOERROR then
                        local id = q:getDataInt("id")
                        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, 'You have received "'.. name ..'" from HUEHUE 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, MESSAGE_EVENT_ORANGE, ''.. name ..' << from HUEHUE shop is waiting for you, but you don\'t have enough room.')
                    end
                else
                    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, ''.. name ..' << from HUEHUE shop is waiting for you, but you don\'t have '.. weight ..' oz. of free capacity.')
                end
            end
        until not result:next()
        q:free()
    end
    return true
end

Thanks.

Yours VANKK;
 
Last edited:
Doesnt work, still sending every 30 second when broadcasting red message..
in db its this
error.jpg

Don't bump old threads when you have just bumped this...
Read what I wrote again and then read the script.

If you haven't understood it yet:
Code:
db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id)
 
Don't bump old threads when you have just bumped this...
Read what I wrote again and then read the script.

If you haven't understood it yet:
Code:
db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id)

db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id)

MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id)' at line 1
 
db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id)

MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id)' at line 1

I don't even know what to say about this lol, one thing is try to study abit more before trying to start a server haha.....
READ the script READ what I told you.
 
Since you seem to think im not trying to help you ill explain it.
But the thing is that you will never learn if people always tell you what to do.

The variable "item" is used to check if we got any errors while sending the item.
This isen't the best way for 1.x, you should use nil as statment to check for since 1.x mainly returns nil.

So what I told you to do was not to execute a LUA function in the query page in your phpmyadmin.
So to once again say it, you are trying to check if you got anything returned, you did and it's because of that you are not deleting the query.

As I said above READ what I told you and READ the script, you should have understood this if you actually did that rather then trying to find another script on otland.
 
Back
Top