local items = { -- [ item id ] = {points = points will be returned to players}
[2466] = {points = 5},
[2446] = {points = 6}
}
local table_place = {x=92,y=132,z=7}
function addPoint(cid,p,t)
return doPlayerSendTextMessage(cid,25,"You have returned your donated item '"..getItemNameById(t).."' and added ".. p .." points to your current one.") and db.executeQuery("UPDATE `accounts` set `premium_points` = `premium_points` + '"..p.."' WHERE `name` = '"..getPlayerAccount(cid).."';")
end
local check = nil
function onUse(cid, item, fromPosition, itemEx, toPosition)
for k,v in pairs(items) do
if getTileItemById(table_place,k).uid > 0 then
check = {k,v.points}
end
end
if check ~= nil then
addPoint(cid,check[2],check[1])
doRemoveItem(getTileItemById(table_place,check[1]).uid,1)
doSendMagicEffect(table_place,2)
doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
check = nil
else
doPlayerSendCancel(cid,"No donated item can be found.")
doSendMagicEffect(toPosition,2)
end
return true
end