-
Notifications
You must be signed in to change notification settings - Fork 4
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
Save Ped Through Roleplays #3
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,15 @@ local wardrobeSelectedId = ("%s_selected"):format(wardrobeId) | |
local wardrobe = json.decode(GetResourceKvpString(wardrobeId)) or {} | ||
local currentOpenWardrobe | ||
local fivemAppearance = exports["fivem-appearance"] | ||
Peds = {} | ||
|
||
RegisterNetEvent("ND:characterLoaded") | ||
AddEventHandler("ND:characterLoaded", function() | ||
local ped = PlayerPedId() | ||
print(json.decode(GetResourceKvpString("ND_AppearanceShops:savedclothing"))) | ||
fivemAppearance:setPedAppearance(ped, json.decode(GetResourceKvpString("ND_AppearanceShops:savedclothing"))) | ||
end) | ||
|
||
Comment on lines
+8
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ND Characters should do this already... |
||
|
||
local function inputOutfitName() | ||
local input = lib.inputDialog("Save current outfit", {"Outfit name:"}) | ||
|
@@ -24,6 +33,8 @@ local function saveWardrobe(name) | |
name = name, | ||
appearance = appearance | ||
} | ||
Outfit = appearance | ||
SetResourceKvp("ND_AppearanceShops:savedclothing", json.encode(Outfit)) | ||
return true | ||
end | ||
|
||
|
@@ -79,7 +90,7 @@ local function startChange(coords, options, i) | |
tattoos = fivemAppearance:getPedTattoos(ped), | ||
appearance = fivemAppearance:getPedAppearance(ped) | ||
} | ||
|
||
SetResourceKvp("ND_AppearanceShops:savedclothing", json.encode(appearance)) | ||
if not lib.callback.await("ND_AppearanceShops:clothingPurchase", false, i, clothing) then | ||
fivemAppearance:setPlayerModel(oldAppearance.model) | ||
ped = PlayerPedId() | ||
|
@@ -127,7 +138,7 @@ local function createClothingStore(info) | |
end | ||
} | ||
end | ||
NDCore.createAiPed({ | ||
Peds[#Peds+1] = NDCore.createAiPed({ | ||
resource = GetInvokingResource(), | ||
model = location.model, | ||
coords = location.worker, | ||
|
@@ -197,9 +208,29 @@ for i=1, #Config do | |
createClothingStore(Config[i]) | ||
end | ||
|
||
|
||
|
||
|
||
|
||
|
||
AddEventHandler("onResourceStop", function(resource) | ||
if resource ~= cache.resource then return end | ||
SetResourceKvp(wardrobeId, json.encode(wardrobe)) | ||
SetResourceKvp("ND_AppearanceShops:savedclothing", json.encode(Outfit)) | ||
for _, ped in pairs(Peds) do | ||
NDCore.removeAiPed(ped) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ND Core should do this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It makes it so that the last appearance you saved in an Appearance shop loads in instead of the character you can only set once. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be fair, i dont know what version we are on, i don't own the server i work for. But this makes appearance shops more useful in my opinion. |
||
end | ||
end) | ||
|
||
|
||
RegisterCommand("saverpped", function () | ||
local appearance = fivemAppearance:getPedAppearance(PlayerPedId()) | ||
appearance.hair = nil | ||
appearance.headOverlays = nil | ||
appearance.tattoos = nil | ||
appearance.faceFeatures = nil | ||
appearance.headBlend = nil | ||
SetResourceKvp("ND_AppearanceShops:savedclothing", json.encode(appearance)) | ||
end) | ||
|
||
exports("openWardrobe", openWardrobe) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose with this command, the current player outfit should be saved anyways.