Skip to content

OnPlayerOutfitChange

The player’s outfits changed - the moment to save them.

The game keeps three outfits (the inventory’s flags A, B and C): each one the clothing, armour and weapons it wears, and the player switches between them. The player’s game reports them when they change - an outfit put together or changed, a switch to another - and this runs once the server has the new state; read it with GetPlayerOutfits. The game keeps an outfit as the items themselves and a login makes every item anew, so only the outfit the bag’s restore dressed comes back unless the mode saves them and hands them back with SetPlayerOutfits. Not for the mode’s own SetPlayerOutfits.

function OnPlayerOutfitChange(pid)
-- ...
end
Parameter Type
pid number the player

nothing

-- saved as one line per character (db: GetDatabase(); the player's row id in their data)
function OnPlayerOutfitChange(pid)
local id, o = GetPlayerData(pid, "db_id"), GetPlayerOutfits(pid)
if not (db and id and o) then return end
local text = o.current .. ";" .. table.concat(o[1], ",") .. ";" .. table.concat(o[2], ",") .. ";" .. table.concat(o[3], ",")
db:Execute("UPDATE players SET outfits = @o WHERE id = @p", { o = text, p = id })
end

GetPlayerOutfits · SetPlayerOutfits · OnPlayerInventoryChange · the Items and inventory group of the index