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

Save Ped Through Roleplays #3

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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@

## Need support?
[![Need Support?](https://user-images.githubusercontent.com/86536434/147299047-73691b78-2690-4786-b58b-27d24e48a0d2.png)](https://discord.gg/Z9Mxu72zZ6)

## Command:
(Use /saverpped to save your current ped for the next roleplay! even when changing characters you can be sure that your ped will be there.)
Comment on lines +19 to +21
Copy link
Member

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.

35 changes: 33 additions & 2 deletions source/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The 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:"})
Expand All @@ -24,6 +33,8 @@ local function saveWardrobe(name)
name = name,
appearance = appearance
}
Outfit = appearance
SetResourceKvp("ND_AppearanceShops:savedclothing", json.encode(Outfit))
return true
end

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ND Core should do this.

Copy link
Author

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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)
Expand Down