Files
2026-03-29 21:41:17 +03:00

100 lines
3.3 KiB
Lua

-- ============================================
-- 17mov-plugin-char-creator
-- Red Valley RP — Spawn Outfit Enforcer
--
-- Tracks citizenid to detect new characters.
-- Each new char = new citizenid = auto-detected.
-- Zero overhead in-game (local check only).
-- ============================================
local isCreating = false
local handledCid = nil -- citizenid already handled (in-game or saved)
local outfitMale = {
{1, 0, 0}, {3, 96, 0}, {4, 200, 2}, {5, 0, 0},
{6, 77, 8}, {7, 0, 0}, {8, 15, 0}, {9, 0, 0}, {11, 539, 2},
}
local outfitFemale = {
{1, 0, 0}, {3, 18, 0}, {4, 214, 1}, {5, 0, 0},
{6, 81, 10}, {7, 0, 0}, {8, 15, 0}, {9, 0, 0}, {11, 583, 1},
}
local function StartOutfitLoop()
if isCreating then return end
isCreating = true
print("[17mov-plugin] ^2LOOP STARTED^0")
CreateThread(function()
while isCreating do
local ped = PlayerPedId()
if ped and DoesEntityExist(ped) then
local model = GetEntityModel(ped)
local outfit = (model == GetHashKey("mp_f_freemode_01")) and outfitFemale or outfitMale
for _, v in ipairs(outfit) do
SetPedComponentVariation(ped, v[1], v[2], v[3], 0)
end
ClearPedProp(ped, 0)
ClearPedProp(ped, 1)
end
Wait(0)
end
print("[17mov-plugin] ^1LOOP ENDED^0")
end)
end
-- ============================================
-- SMART POLLING
-- Only hits server when citizenid changes (new char)
-- ============================================
CreateThread(function()
while true do
Wait(5000)
if isCreating then goto skip end
local ok, QBCore = pcall(function() return exports['qb-core']:GetCoreObject() end)
if not ok or not QBCore then goto skip end
local pd = QBCore.Functions.GetPlayerData()
if not pd or not pd.citizenid or pd.citizenid == "" then goto skip end
-- Already handled this citizenid → skip (free local check)
if pd.citizenid == handledCid then goto skip end
-- New citizenid detected! Check if it's a new char
print("[17mov-plugin] ^5New CID: " .. pd.citizenid .. "^0")
QBCore.Functions.TriggerCallback("qb-clothing:server:getPlayerSkin", function(data)
if data and data.isGenerated and not isCreating then
print("[17mov-plugin] ^2NEW CHAR — starting loop^0")
StartOutfitLoop()
else
handledCid = pd.citizenid
print("[17mov-plugin] ^3Existing char " .. pd.citizenid .. " — idle^0")
end
end)
::skip::
end
end)
-- Stop on save → mark this citizenid as handled
RegisterNetEvent('17mov_CharacterSystem:SaveCurrentSkin', function()
if isCreating then
isCreating = false
local ok, QBCore = pcall(function() return exports['qb-core']:GetCoreObject() end)
if ok and QBCore then
local pd = QBCore.Functions.GetPlayerData()
if pd and pd.citizenid then
handledCid = pd.citizenid
end
end
print("[17mov-plugin] ^1SAVED — idle^0")
end
end)
AddEventHandler('onResourceStop', function(res)
if res == GetCurrentResourceName() then isCreating = false end
end)
print("[17mov-plugin] ^2Resource loaded^0")