Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add first character creation callback/event #222

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ local function GetPositionByRelativeHeading(ped, head, dist)

return finPosx, finPosy
end
local function openMenu(allowedMenus)
local function openMenu(allowedMenus, isCreatingFirstCharacter)
previousSkinData = json.encode(skinData)
creatingCharacter = true
PlayerData = QBCore.Functions.GetPlayerData()
Expand All @@ -426,6 +426,7 @@ local function openMenu(allowedMenus)
currentClothing = skinData,
hasTracker = trackerMeta,
translations = translations,
isCreatingFirstCharacter = isCreatingFirstCharacter
})
SetNuiFocus(true, true)
SetCursorLocation(0.9, 0.25)
Expand Down Expand Up @@ -1022,7 +1023,7 @@ RegisterNetEvent('qb-clothes:client:CreateFirstCharacter', function()
{menu = "hair", label = Lang:t("menu.hair"), selected = false},
{menu = "clothing", label = Lang:t("menu.character"), selected = false},
{menu = "accessoires", label = Lang:t("menu.accessoires"), selected = false}
})
}, true)

if pData.charinfo.gender == 1 then
skin = "mp_f_freemode_01"
Expand Down Expand Up @@ -1542,12 +1543,13 @@ RegisterNUICallback('resetOutfit', function(_, cb)
previousSkinData = {}
cb('ok')
end)
RegisterNUICallback('close', function(_, cb)
RegisterNUICallback('close', function(data, cb)
local isCreatingFirstCharacter = data.isCreatingFirstCharacter
SetNuiFocus(false, false)
creatingCharacter = false
disableCam()
FreezeEntityPosition(PlayerPedId(), false)
TriggerEvent('qb-clothing:client:onMenuClose')
TriggerEvent('qb-clothing:client:onMenuClose', isCreatingFirstCharacter)
cb('ok')
end)
RegisterNUICallback('getCatergoryItems', function(data, cb)
Expand Down Expand Up @@ -1580,6 +1582,9 @@ RegisterNUICallback('saveClothing', function(_, cb)
SaveSkin()
cb('ok')
end)
RegisterNUICallback('characterCreated', function()
-- Do stuff here as developers need
end)
-- Commands
RegisterCommand("refreshskin", function()
local playerPed = PlayerPedId()
Expand Down
13 changes: 12 additions & 1 deletion html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ var translations = {};

var clothingCategorys = [];

// Introduced to allow for new character creation callback
let isCreatingFirstCharacter = false;

$(document).on('click', '.clothing-menu-header-btn', function(e) {
var category = $(this).data('category');

Expand Down Expand Up @@ -378,6 +381,11 @@ $(document).on('click', "#save-menu", function(e) {
e.preventDefault();
QBClothing.Close();
$.post('https://qb-clothing/saveClothing');

if (isCreatingFirstCharacter) {
$.post('https://qb-clothing/characterCreated');
isCreatingFirstCharacter = false;
}
});

$(document).on('click', "#cancel-menu", function(e) {
Expand Down Expand Up @@ -508,7 +516,10 @@ $(document).on('click', '.clothing-menu-myOutfit-option-button-remove', function
});

QBClothing.Close = function() {
$.post('https://qb-clothing/close');
$.post('https://qb-clothing/close', JSON.stringify({
isCreatingFirstCharacter: isCreatingFirstCharacter
}));

$(".change-camera-buttons").fadeOut(150);
$(".clothing-menu-roomOutfits-container").css("display", "none");
$(".clothing-menu-myOutfits-container").css("display", "none");
Expand Down
Loading