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
Thanks.
Yours VANKK;
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:
