Skip to content

GetPlayerHardware

The parts of the player’s PC by name - for a database with a column per part.

The parts of GetPlayerHwid in a table: system, board, disk and machine, each 16 hex digits. A part the PC has no value for is left out (nil). With a column per part a ban list is searched by the database itself (WHERE system = @s OR disk = @d ...) instead of a loop over every ban.

GetPlayerHardware(pid)
Parameter Type
pid number the player

table | nil - { system = ..., board = ..., disk = ..., machine = ... } (the parts the PC has); nil when their game sent none

-- a ban table with a column per part (a part the PC had none of stored as NULL): two shared parts = the same PC
local hw = GetPlayerHardware(pid)
if hw then
db:Query([[SELECT reason FROM banned_pcs WHERE
(CASE WHEN system = @s THEN 1 ELSE 0 END) + (CASE WHEN board = @b THEN 1 ELSE 0 END)
+ (CASE WHEN disk = @d THEN 1 ELSE 0 END) + (CASE WHEN machine = @m THEN 1 ELSE 0 END) >= 2]],
{ s = hw.system or "-", b = hw.board or "-", d = hw.disk or "-", m = hw.machine or "-" },
function(rows)
if rows and rows[1] then Kick(pid, "Banned: " .. rows[1].reason) end
end)
end

GetPlayerHwid · CompareHwid · the Players group of the index