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

TalkAction Basic Anti-dupe System

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
A new version for this script is here http://otland.net/f82/anti-dupe-delete-all-duplicated-items-your-database-136899/#post1317307




Hello, here i finished a Basic Anti-dupe System, it can help to detect duped items.

First of all, i'm using the attribute 'serial' that gives to items an "unique serial code".

You need to paste this at your lib/functions.lua:
Lua:
function generateSerial()
	local strings = "ABCDEFGHIJKLMOPQRSTUVWXYZ"
	local newSerialStr, newSerialInt = "", 0
	local newSerial = ""
	local query
	repeat
		for k = 1, math.random(1, 10) do
			local l = math.random(1, string.len(strings))
			newSerialStr = newSerialStr .. string.sub(strings, l, l)
		end
		newSerialInt = math.random(999999)
		newSerial = newSerialStr .. "-" .. newSerialInt
		query = db.getResult("select * from player_items where substring(convert(attributes using latin1) from 18) = " .. db.escapeString(newSerial))
	until query:getID() == -1
	return "!" .. newSerial
end

Now, everytime that do you want to set a serial to an item, just use
Lua:
doItemSetAttribute(uid, "serial", generateSerial())

With this command, you'll get info about all items with serial and you can get info about items with duplicated serials (Cloned items)

Create a file called trackitems.lua and paste this:
Lua:
function onSay(cid, words, param, channel)

	if(param ~= "duplicated") then
		local query = db.getResult("select *, substring(convert(attributes using latin1) from 18) as 'track' from player_items where convert(attributes using latin1) like '%serial%'")
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Here is a list of all items with serial.\nOwner Name - ItemID - Count - Serial")
		if query:getID() ~= -1 then
			while(true) do
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerNameByGUID(query:getDataInt("player_id")) .. " - " .. query:getDataInt("itemtype") .. " - " .. query:getDataInt("count") .. " - " .. query:getDataString("track"))
				if not query:next() then break end
			end
		end
	else
		local query = db.getResult("SELECT *, SUBSTRING(CONVERT(attributes USING latin1) FROM 18) AS 'track' FROM player_items WHERE SUBSTRING(CONVERT(attributes USING latin1) FROM 18) IN (SELECT SUBSTRING(CONVERT(attributes USING latin1) FROM 18) FROM player_items WHERE CONVERT(attributes USING latin1) LIKE '%serial%' GROUP BY SUBSTRING(CONVERT(attributes USING latin1) FROM 18) HAVING COUNT(*) > 1)")
		if query:getID() ~= -1 then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Here is a list of all items with duplicated serial.\nOwner Name - ItemID - Count - Serial")
			while(true) do
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerNameByGUID(query:getDataInt("player_id")) .. " - " .. query:getDataInt("itemtype") .. " - " .. query:getDataInt("count") .. " - " .. query:getDataString("track"))
				if not query:next() then break end
			end
		else
			return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "No items with duplicated serial.")
		end
	end
	return true
end

XML:
	<talkaction words="/track" access="5" event="script" value="trackitems.lua"/>

This will delete items with duplicated serial when serer starts:
Create a file of globalevents/scripts called trackitems.lua and paste:
Lua:
tablesToCheck = {"player_items", "player_depotitems"}

function onStartup()
	local text, final = "", ""
	local filex = "data/logs/duplicated.txt"
	local f = io.open(filex, "a+")
	for i = 1, table.maxn(tablesToCheck) do
		local query = db.getResult("SELECT *, SUBSTRING(CONVERT(attributes USING latin1) FROM 18) AS 'track' FROM " .. tablesToCheck[i] .. " WHERE SUBSTRING(CONVERT(attributes USING latin1) FROM 18) IN (SELECT SUBSTRING(CONVERT(attributes USING latin1) FROM 18) FROM " .. tablesToCheck[i] .. " WHERE CONVERT(attributes USING latin1) LIKE '%serial%' GROUP BY SUBSTRING(CONVERT(attributes USING latin1) FROM 18) HAVING COUNT(*) > 1)")
		local duplicated = {}
		if query:getID() ~= -1 then
			while(true) do
				text = "[!] -> Deleting item with duplicated serial: [Player: " .. getPlayerNameByGUID(query:getDataInt("player_id")) .. ", Item: " .. query:getDataInt("itemtype") .. ", Count: " .. query:getDataInt("count") .. ", Serial: " .. query:getDataString("track") .."]... "
				local delete = db.executeQuery("delete from " .. tablesToCheck[i] .. " where SUBSTRING(CONVERT(attributes USING latin1) FROM 18) = " .. db.escapeString(query:getDataString("track")) .. ";")
				if delete then
					text = text .. "Success!"
				else
					text = text .. "Failed!"
				end
				final = final .. (final ~= "" and "\n" or "") .. text
				print(text)
				if not query:next() then break end
			end
			if f ~= nil then
				f:write(os.date() .. "\n" .. final .. "\n\n")
				f:close()
			else
				print("[!] -> Cannot save info to file!")
			end
		else
			print("[!] -> Cannot get info, table is empty, there are not items with duplicated serial or you have a problem on the query syntax: " .. tablesToCheck[i] .. ".")
		end
	end
	return true
end

XML:
	<globalevent name="trackitems" type="start" event="script" value="trackitems.lua"/>
Also you can see items with serial from phpMyAdmin with this command:
SQL:
SELECT * , SUBSTRING( CONVERT( attributes
USING latin1 ) 
FROM 18 ) AS  'serial'
FROM player_items
WHERE CONVERT( attributes
USING latin1 ) LIKE  '%serial%'
ippb3n.png


And you can see items with duplicated serials with the following commands:
SQL:
--Use this command to see duplicated items on players inventory
SELECT * , SUBSTRING( CONVERT( attributes
USING latin1 ) 
FROM 18 ) AS  'duplicated serials'
FROM player_items
WHERE SUBSTRING( CONVERT( attributes
USING latin1 ) 
FROM 18 ) 
IN (

SELECT SUBSTRING( CONVERT( attributes
USING latin1 ) 
FROM 18 ) 
FROM player_items
WHERE CONVERT( attributes
USING latin1 ) LIKE  '%serial%'
GROUP BY SUBSTRING( CONVERT( attributes
USING latin1 ) 
FROM 18 ) 
HAVING COUNT( * ) >1
)

--Use this command to see duplicated items on players inventory or depot items
SELECT * , SUBSTRING( CONVERT( attributes
USING latin1 ) 
FROM 18 ) AS 'duplicated serials'
FROM player_items
WHERE SUBSTRING( CONVERT( attributes
USING latin1 ) 
FROM 18 ) 
IN (
 
SELECT SUBSTRING( CONVERT( attributes
USING latin1 ) 
FROM 18 ) 
FROM player_depotitems
WHERE CONVERT( attributes
USING latin1 ) LIKE '%serial%'
GROUP BY SUBSTRING( CONVERT( attributes
USING latin1 ) 
FROM 18 ) 
HAVING COUNT( * ) >1
)

--Use this command to see duplicated items on players depots
SELECT * , SUBSTRING( CONVERT( attributes
USING latin1 ) 
FROM 18 ) AS 'duplicated serials'
FROM player_depotitems
WHERE SUBSTRING( CONVERT( attributes
USING latin1 ) 
FROM 18 ) 
IN (
 
SELECT SUBSTRING( CONVERT( attributes
USING latin1 ) 
FROM 18 ) 
FROM player_depotitems
WHERE CONVERT( attributes
USING latin1 ) LIKE '%serial%'
GROUP BY SUBSTRING( CONVERT( attributes
USING latin1 ) 
FROM 18 ) 
HAVING COUNT( * ) >1
)
709ovs.png

Note that you can change the table 'player_items' to 'player_depotitems' to get info about items on depot

Please, comment with constructive criticism :)!
Rep++ is appreciated!
 
Last edited:
tremendo aporte wn, se ve que le echaste ganas, gracias por compartirlo.

nice, thanks for sharing :D
 
How are people able to dupe items?
I haven't seen any duping since MrSheenOT in 7.6.
 
How are people able to dupe items?
I haven't seen any duping since MrSheenOT in 7.6.

There are methods to clone items, most used now is abusing a bug to close the server instantly or maybe with DDoS Attacks.
 
VERY similar to Jano >.<, Very good =)
will prove it.

Thanks
 
possible, just use your imagination
you can onStartup perform check and delete all copies(you cannot know which one is original BUT if duper managed to sell that item before restart honest player may be hurt. but it shouldnt happen cause duping need serv crash afaik so on startup will be fixed ;d)
 
I can make it checks duplicated items on startup, deleting it and banning player(s), but i don't know how exactly works the banishments on queries x)
 
I can make it checks duplicated items on startup, deleting it and banning player(s), but i don't know how exactly works the banishments on queries x)


Something like this?
Code:
db.executeQuery("UPDATE `players` SET `deleted` = 1 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
 
Please, could you do auto-punishiment ? Removing BOTH items and baning BOTH players !
Thank you, and REP+
 
Something like this?
Code:
db.executeQuery("UPDATE `players` SET `deleted` = 1 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")

That's for deleted, you said BANISHMENT... anyways, it works

@tigerx2!

Yes i can but that is not a recommended solution because, What if an innocent player buys a duped item? He will be punished and to him will be no reason.

I'm scripting a new feature-fix now, i'll update main post later.
 
Does this apply serial numbers to items bought from npcs, or dropped by a monster?

Is it possible to make it so players can see the items serial in game? or set it as an option (visible serial, yes or no)


Also, first thing I thought of after seeing this, is to make a global event that runs the command to delete duplicate serial number items.
 
about auto punsh: anyway, how you want to determine which one is original and which player is bad guy?
If item can be cloned on online serv(guild management plx?) its problematic, onCrash should be safe to take care of it automatic I guess
 
It will be amazing if only dupped be deleted and the original keep in game.
Another way:
Globalevent run and create a log/save in DB so admin can check dupped itens in a page in gesior/modern. (Admin Pannel)
 
Back
Top