This guide explains how to integrate murphy_clothing's temperature protection system into metabolism/survival scripts like bcc-corehud.
How It Works
Murphy Clothing tracks which clothing categories are equipped and classifies them as warm, cold, or neutral (configurable in shared/config.lua via Config.ClothingTemperature).
Based on the number of warm/cold items equipped, it calculates a protection level from 0 (no protection) to 3 (heavy protection), configurable via Config.TemperatureProtection.
Every time the player equips or removes clothing, murphy_clothing fires:
-- Event with full protection data
TriggerEvent('murphy_clothes:TemperatureUpdate', protection)
Where protection is a table:
{
warmItems = 3, -- Number of warm clothing items equipped
coldItems = 0, -- Number of cold clothing items equipped
coldProtection = 2, -- Protection level against cold (0-3)
heatProtection = 0, -- Protection level against heat (0-3)
categories = { "coats", "boots", "gloves", ... } -- List of all equipped categories
}
Debug Command
Use /temptest in the F8 console to check the current ambient temperature, equipped clothing, and protection levels.
Integration with bcc-corehud
Step 1 - Add variables at the top of your bcc-corehud client script
local currentProtection = { cold = 0, heat = 0 }
-- Maps protection level (0-3) to the minimum temperature the player can withstand
local ColdResistance = {
[0] = 5.0, -- Level 0: starts freezing at 5 C
[1] = -5.0, -- Level 1: protected down to -5 C
[2] = -15.0, -- Level 2: protected down to -15 C
[3] = -20.0, -- Level 3: protected down to -20 C
}
Step 2 - Listen for clothing changes
Add this event handler to receive real-time updates from murphy_clothing:
AddEventHandler('murphy_clothes:TemperatureUpdate', function(protection)
if type(protection) == 'table' then
currentProtection.cold = tonumber(protection.coldProtection) or 0
currentProtection.heat = tonumber(protection.heatProtection) or 0
end
end)
Step 3 - Modify your temperature damage function
In your temperature damage function (e.g. applySimpleTemperatureDamage), use the protection level to determine whether the player actually takes damage:
local function applySimpleTemperatureDamage(ped, temperature)
local damage = C.tempDamagePerTick or 0.0
if damage <= 0.0 or ped == 0 or IsEntityDead(ped) then
stopTemperatureFx()
return false, false
end
local below = C.minTempDamage and temperature < C.minTempDamage
local above = C.maxTempDamage and temperature > C.maxTempDamage
-- Apply cold protection from clothing
if below then
local threshold = ColdResistance[currentProtection.cold] or 5.0
if temperature > threshold then
below = false -- Clothing protects the player
end
end
-- Apply heat protection from clothing (optional, same logic)
-- if above then
-- ...
-- end
if not below and not above then
stopTemperatureFx()
return false, false
end
-- ... rest of your damage logic
end
Step 4 - (Optional) Fetch protection on player spawn
To initialize the protection level when the player first loads in:
Citizen.CreateThread(function()
Wait(5000) -- Wait for murphy_clothing to load
local protection = exports['murphy_clothing']:GetTemperatureProtection()
if protection then
currentProtection.cold = protection.coldProtection or 0
currentProtection.heat = protection.heatProtection or 0
end
end)
Available Exports
You can call these from any client script:
-- Get full temperature protection data
local protection = exports['murphy_clothing']:GetTemperatureProtection()
-- Get all equipped clothing (category -> {model, texture, category})
local equipped = exports['murphy_clothing']:GetEquippedClothing()
-- Check if a specific category is equipped
local hasCoat = exports['murphy_clothing']:IsClothingCategoryEquipped("coats")
-- Get detailed info for a category
local info = exports['murphy_clothing']:GetClothingInfo("coats")
-- Returns: { category, model, texture, temperature }
Available Events
-- Fired every time clothing changes (with 500ms delay for cache sync)
AddEventHandler('murphy_clothes:TemperatureUpdate', function(protection)
-- protection = { warmItems, coldItems, coldProtection, heatProtection, categories }
end)
-- Fired immediately when a clothing category is toggled
AddEventHandler('murphy_clothes:OnClothingChanged', function(category, equipped)
-- category = "coats", "boots", etc.
-- equipped = true/false
end)
Configuration
In shared/config.lua, you can customize which categories provide warmth or cooling, and how many items are needed for each protection level:
Config.ClothingTemperature = {
["coats"] = "warm",
["coats_closed"] = "warm",
["ponchos"] = "warm",
["cloaks"] = "warm",
["vests"] = "warm",
["gloves"] = "warm",
["boots"] = "warm",
["chaps"] = "warm",
["shirts_full"] = "neutral",
["skirts"] = "cold",
["pants"] = "neutral",
["hats"] = "neutral",
}
Config.TemperatureProtection = {
cold = {
[0] = 0, -- 0 warm items = no protection
[1] = 1, -- 1 warm item = light
[2] = 1, -- 2 warm items = light
[3] = 2, -- 3 warm items = medium
[4] = 2, -- 4 warm items = medium
[5] = 3, -- 5+ warm items = heavy
},
heat = {
[0] = 0,
[1] = 1,
[2] = 2,
[3] = 3,
}
}