100 are existing products with the same serial number, after use
local delete = db.executeQuery("DELETE FROM " .. tablesToCheck[i] .. " WHERE SUBSTRING(CONVERT(attributes USING latin1) FROM "..Caracters..") = " .. db.escapeString(query:getDataString("track")) .. ";")
Continue to exist a single product with a number of serious, the other duplicates will be deleted.
A product with unique serial number is only permitted, existing more than 1 will be deleted.
EX:
100 Products
100 = 100-99 = 1 - Products
Must remain only one item with the same serial
LINK DATBASE:
local function Antidupe()-- USAR FROM 62 OU 70 ELE VAI PEGAR APARTIR DO 62 ou 70 CARACTERSlocal tablesToCheck = {"player_items", "player_depotitems", "tile_items"}local itemsToCheck = {2523}local text, final = "", ""local filex = "data/logs/Duplicated.txt"local f = io.open(filex, "a+")local count = 0local Caracters = 70for i = 1, table.maxn(tablesToCheck) dofor _, item in ipairs(itemsToCheck) do if(type(tablesToCheck[i]) == "string") thenlocal query = db.getResult("SELECT *, SUBSTRING(CONVERT(attributes USING latin1) FROM "..Caracters..") AS 'track' FROM " .. tablesToCheck[i] .. " WHERE itemtype = "..item.." AND SUBSTRING(CONVERT(attributes USING latin1) FROM "..Caracters..") IN (SELECT SUBSTRING(CONVERT(attributes USING latin1) FROM "..Caracters..") FROM " .. tablesToCheck[i] .. " WHERE CONVERT(attributes USING latin1) LIKE '%serial%' GROUP BY SUBSTRING(CONVERT(attributes USING latin1) FROM "..Caracters..") HAVING COUNT(*) > 0)")if(query:getID() < 1) thenprint("[!] [Anti-Dupe] -> No duplicated item was found in the database!")endif(query:getID() ~= -1) thenwhile(true) dolocal delete = db.executeQuery("DELETE FROM " .. tablesToCheck[i] .. " WHERE SUBSTRING(CONVERT(attributes USING latin1) FROM "..Caracters..") = " .. db.escapeString(query:getDataString("track")) .. ";") text = "[!] [Anti-Dupe] -> Deleting item with duplicated serial from '" .. tablesToCheck[i] .. "' [Player: " .. getPlayerNameByGUID(query:getDataInt("player_id")) .. ", Item: " .. query:getDataInt("itemtype") .. ", Count: " .. query:getDataInt("count") .. ", Serial: " .. query:getDataString("track") .."]... " .. (delete and "Success!" or "Failed!")count = (delete and count + 1 or count)final = final .. (final ~= "" and "n" or "") .. textprint(text)if not query:next() then break endend endendendendif(f ~= nil) thenf:write("[" .. os.date("%d %B %Y Hora: %X") .. "] >> [Anti-Dupe] " .. count .. " duplicated items have been deleted from the database.n" .. (final == "" and "[!] [Anti-Dupe] -> No duplicated item was found in the database" or final) .. "nn")f:close()elseprint("[!] [Anti-Dupe] -> Cannot save info to file!")endreturn trueendfunction onSay(cid, words, param)Antidupe()return trueend