Support:Queries: Difference between revisions

From Arianne
Jump to navigation Jump to search
Content deleted Content added
imported>Hendrik Brummermann
No edit summary
imported>Hendrik Brummermann
Line 19: Line 19:
== Items ==
== Items ==


=== Item history of all items touched by suspicious character ===
=== Item history of all items touched by suspicious characters ===


<source lang="SQL">
<source lang="SQL">
SELECT *
SELECT * FROM itemlog, (SELECT DISTINCT itemid FROM itemlog WHERE source IN ('[charname1]', '[charname2]')) As x
FROM itemlog,
(SELECT DISTINCT itemid
FROM itemlog
WHERE source IN ('[charname1]', '[charname2]')
) As x
WHERE x.itemid=itemlog.itemid
WHERE x.itemid=itemlog.itemid
ORDER BY itemlog.itemid, itemlog.id
ORDER BY itemlog.itemid, itemlog.id
</source>
</source>

=== Item history of all items touched by suspicious characters and someone else ===

<source lang="SQL">
SELECT *
FROM itemlog,
(SELECT DISTINCT i1.itemid
FROM itemlog i1, itemlog i2
WHERE i1.source IN ('[charname1]', '[charname2]')
AND i1.itemid=i2.itemid
AND i2.itemid NOT IN ('null', '[charname2]', '[charname2]')
) As x
WHERE x.itemid=itemlog.itemid
ORDER BY itemlog.itemid, itemlog.id
</source>

The string 'null' is required in the NOT IN clause because of register events


== Bots ==
== Bots ==

Revision as of 20:03, 27 October 2010

Characters and accounts

Account belonging to a character

SELECT account.* 
FROM account, characters
WHERE characters.player_id=account.id AND charname='[character]';

Characters belonging to an account

SELECT characters.*
FROM account, characters
WHERE characters.player_id=account.id AND username='[account]'

Items

Item history of all items touched by suspicious characters

SELECT * 
FROM itemlog, 
  (SELECT DISTINCT itemid 
   FROM itemlog
   WHERE source IN ('[charname1]', '[charname2]')
  ) As x
WHERE x.itemid=itemlog.itemid
ORDER BY itemlog.itemid, itemlog.id

Item history of all items touched by suspicious characters and someone else

SELECT * 
FROM itemlog, 
  (SELECT DISTINCT i1.itemid 
   FROM itemlog i1, itemlog i2
   WHERE i1.source IN ('[charname1]', '[charname2]')
   AND i1.itemid=i2.itemid
   AND i2.itemid NOT IN ('null', '[charname2]', '[charname2]')
  ) As x
WHERE x.itemid=itemlog.itemid
ORDER BY itemlog.itemid, itemlog.id

The string 'null' is required in the NOT IN clause because of register events

Bots

Finding Bots

TODO: {{{1}}}

Checking if someone is a bot

The following queries lists the number of "use"-actions per player and hour. If there are high number of uses for several hours in a row, it is likely a bot.

SELECT source, left(timedate, 13) As day, count(*) As cnt
FROM gameEvents
WHERE (source='[character1]' OR source='[character2]') AND event='use' GROUP BY source, event, day ORDER BY day;