mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-19 06:46:03 +01:00
Added fivem appearance
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
config = {
|
config = {
|
||||||
changeCharacterCommand = "changecharacter", -- this is the command to open the ui again and change your character.
|
changeCharacterCommand = "changecharacter", -- this is the command to open the ui again and change your character.
|
||||||
|
enableAppearance = true, -- you need to install fivem-appearance
|
||||||
characterSelectionAopDisplay = false,
|
characterSelectionAopDisplay = false,
|
||||||
aop = function ()
|
aop = function ()
|
||||||
return "AOP: " .. exports["SimpleHUD"]:getAOP() -- exports["ModernHUD"]:getAOP()
|
return "AOP: " .. exports["SimpleHUD"]:getAOP() -- exports["ModernHUD"]:getAOP()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
NDCore = exports["ND_Core"]:GetCoreObject()
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
local changeAppearence = false
|
local changeAppearence = false
|
||||||
|
local started = false
|
||||||
|
|
||||||
function startChangeAppearence()
|
function startChangeAppearence()
|
||||||
local config = {
|
local config = {
|
||||||
@@ -15,17 +16,19 @@ function startChangeAppearence()
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports["fivem-appearance"]:startPlayerCustomization(function(appearance)
|
exports["fivem-appearance"]:startPlayerCustomization(function(appearance)
|
||||||
if (appearance) then
|
if appearance then
|
||||||
local ped = PlayerPedId()
|
local ped = PlayerPedId()
|
||||||
local clothing = {
|
local clothing = {
|
||||||
|
model = GetEntityModel(ped),
|
||||||
tattoos = exports["fivem-appearance"]:getPedTattoos(ped),
|
tattoos = exports["fivem-appearance"]:getPedTattoos(ped),
|
||||||
appearance = exports["fivem-appearance"]:getPedAppearance(ped)
|
appearance = exports["fivem-appearance"]:getPedAppearance(ped)
|
||||||
}
|
}
|
||||||
Wait(4000)
|
Wait(4000)
|
||||||
TriggerServerEvent("ND:updateClothes", clothing)
|
TriggerServerEvent("ND:updateClothes", clothing)
|
||||||
else
|
else
|
||||||
print("Canceled")
|
start(true)
|
||||||
end
|
end
|
||||||
|
changeAppearence = false
|
||||||
end, config)
|
end, config)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -62,8 +65,6 @@ function SetDisplay(bool, typeName, bg, characters)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
started = false
|
|
||||||
|
|
||||||
function start(switch)
|
function start(switch)
|
||||||
TriggerServerEvent("ND:GetCharacters")
|
TriggerServerEvent("ND:GetCharacters")
|
||||||
if not started then
|
if not started then
|
||||||
@@ -119,19 +120,21 @@ AddEventHandler("ND:returnCharacters", function(characters)
|
|||||||
SetDisplay(true, "ui", background, characters)
|
SetDisplay(true, "ui", background, characters)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- [TODO] to be implemented properly later
|
|
||||||
-- Set the player to creating the ped if they haven't already.
|
-- Set the player to creating the ped if they haven't already.
|
||||||
-- RegisterNetEvent("ND:setCharacter")
|
RegisterNetEvent("ND:setCharacter")
|
||||||
-- AddEventHandler("ND:setCharacter", function(character)
|
AddEventHandler("ND:setCharacter", function(character)
|
||||||
-- if next(character.clothing) == nil then
|
if config.enableAppearance then
|
||||||
-- changeAppearence = true
|
if next(character.clothing) == nil then
|
||||||
-- else
|
changeAppearence = true
|
||||||
-- changeAppearence = false
|
else
|
||||||
-- local ped = PlayerPedId()
|
changeAppearence = false
|
||||||
-- exports["fivem-appearance"]:setPedTattoos(ped, character.clothing.tattoos)
|
exports["fivem-appearance"]:setPlayerModel(character.clothing.model)
|
||||||
-- exports["fivem-appearance"]:setPedAppearance(ped, character.clothing.appearance)
|
local ped = PlayerPedId()
|
||||||
-- end
|
exports["fivem-appearance"]:setPedTattoos(ped, character.clothing.tattoos)
|
||||||
-- end)
|
exports["fivem-appearance"]:setPedAppearance(ped, character.clothing.appearance)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
-- Selecting a player from the iu.
|
-- Selecting a player from the iu.
|
||||||
RegisterNUICallback("setMainCharacter", function(data)
|
RegisterNUICallback("setMainCharacter", function(data)
|
||||||
@@ -142,7 +145,8 @@ RegisterNUICallback("setMainCharacter", function(data)
|
|||||||
x = spawn.x,
|
x = spawn.x,
|
||||||
y = spawn.y,
|
y = spawn.y,
|
||||||
z = spawn.z,
|
z = spawn.z,
|
||||||
name = spawn.name
|
name = spawn.name,
|
||||||
|
id = characters[data.id].id
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
Wait(1000)
|
Wait(1000)
|
||||||
@@ -200,21 +204,27 @@ RegisterNUICallback("tpToLocation", function(data)
|
|||||||
Citizen.Wait(500)
|
Citizen.Wait(500)
|
||||||
FreezeEntityPosition(ped, false)
|
FreezeEntityPosition(ped, false)
|
||||||
SetEntityVisible(ped, true, 0)
|
SetEntityVisible(ped, true, 0)
|
||||||
if changeAppearence then
|
if config.enableAppearance and changeAppearence then
|
||||||
startChangeAppearence()
|
startChangeAppearence()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Choosing the do not tp button.
|
-- Choosing the do not tp button.
|
||||||
RegisterNUICallback("tpDoNot", function()
|
RegisterNUICallback("tpDoNot", function(data)
|
||||||
local ped = PlayerPedId()
|
local ped = PlayerPedId()
|
||||||
|
local character = NDCore.Functions.GetCharacters()[data.id]
|
||||||
|
FreezeEntityPosition(ped, false)
|
||||||
|
if next(character.lastLocation) ~= nil then
|
||||||
|
SetEntityCoords(ped, character.lastLocation.x, character.lastLocation.y, character.lastLocation.z, false, false, false, false)
|
||||||
|
end
|
||||||
|
FreezeEntityPosition(ped, true)
|
||||||
SwitchInPlayer(ped)
|
SwitchInPlayer(ped)
|
||||||
Citizen.Wait(500)
|
Citizen.Wait(500)
|
||||||
SetDisplay(false, "ui")
|
SetDisplay(false, "ui")
|
||||||
Citizen.Wait(500)
|
Citizen.Wait(500)
|
||||||
SetEntityVisible(ped, true, 0)
|
|
||||||
FreezeEntityPosition(ped, false)
|
FreezeEntityPosition(ped, false)
|
||||||
if changeAppearence then
|
SetEntityVisible(ped, true, 0)
|
||||||
|
if config.enableAppearance and changeAppearence then
|
||||||
startChangeAppearence()
|
startChangeAppearence()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ $(function() {
|
|||||||
if (item.type === "setSpawns") {
|
if (item.type === "setSpawns") {
|
||||||
$("#spawnMenuContainer").empty();
|
$("#spawnMenuContainer").empty();
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
|
$("#tpDoNot").data("id", item.id);
|
||||||
$("#spawnMenuContainer").append(`<button class="spawnButtons" data-x="${item.x}" data-y="${item.y}" data-z="${item.z}">${item.name}</button>`);
|
$("#spawnMenuContainer").append(`<button class="spawnButtons" data-x="${item.x}" data-y="${item.y}" data-z="${item.z}">${item.name}</button>`);
|
||||||
$(".spawnButtons").click(function() {
|
$(".spawnButtons").click(function() {
|
||||||
$.post(`https://${GetParentResourceName()}/tpToLocation`, JSON.stringify({
|
$.post(`https://${GetParentResourceName()}/tpToLocation`, JSON.stringify({
|
||||||
@@ -77,6 +78,16 @@ $(function() {
|
|||||||
}, 550);
|
}, 550);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
$("#tpDoNot").click(function() {
|
||||||
|
$.post(`https://${GetParentResourceName()}/tpDoNot`, JSON.stringify({
|
||||||
|
id: $("#tpDoNot").data("id")
|
||||||
|
}));
|
||||||
|
spawnMenu(false)
|
||||||
|
setTimeout(function(){
|
||||||
|
$("#spawnMenuContainer").empty();
|
||||||
|
}, 550);
|
||||||
|
return;
|
||||||
|
});
|
||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,8 +212,228 @@ $(function() {
|
|||||||
}, 550);
|
}, 550);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
$("#tpDoNot").click(function() {
|
|
||||||
$.post(`https://${GetParentResourceName()}/tpDoNot`);
|
$("#quitGameButton").click(function() {
|
||||||
|
exitGameMenu(true)
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
$("#exitGameCancel").click(function() {
|
||||||
|
exitGameMenu(false)
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
$("#exitGameConfirm").click(function() {
|
||||||
|
$.post(`https://${GetParentResourceName()}/exitGame`);
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$(function() {
|
||||||
|
function display(bool) {
|
||||||
|
if (bool) {
|
||||||
|
$("body").show();
|
||||||
|
} else {
|
||||||
|
$("body").hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function characterCreatorMenu(bool) {
|
||||||
|
if (bool) {
|
||||||
|
$("#characterCreator").fadeIn("slow");
|
||||||
|
$("#characterEditor, #exitGameMenu, #deleteCharacterMenu, #spawnLocation").hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$("#characterCreator").fadeOut("slow");
|
||||||
|
}
|
||||||
|
function characterEditorMenu(bool) {
|
||||||
|
if (bool) {
|
||||||
|
$("#characterEditor").fadeIn("slow");
|
||||||
|
$("#characterCreator, #exitGameMenu, #deleteCharacterMenu, #spawnLocation").hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$("#characterEditor").fadeOut("slow");
|
||||||
|
}
|
||||||
|
function exitGameMenu(bool) {
|
||||||
|
if (bool) {
|
||||||
|
$("#exitGameMenu").fadeIn("slow");
|
||||||
|
$("#characterCreator, #characterEditor, #deleteCharacterMenu, #spawnLocation").hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$("#exitGameMenu").fadeOut("slow");
|
||||||
|
}
|
||||||
|
function confirmDeleteMenu(bool) {
|
||||||
|
if (bool) {
|
||||||
|
$("#deleteCharacterMenu").fadeIn("slow");
|
||||||
|
$("#characterCreator, #characterEditor, #exitGameMenu, #spawnLocation").hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$("#deleteCharacterMenu").fadeOut("slow");
|
||||||
|
}
|
||||||
|
function spawnMenu(bool) {
|
||||||
|
if (bool) {
|
||||||
|
$("#spawnLocation").fadeIn("slow");
|
||||||
|
$("#characterCreator, #characterEditor, #exitGameMenu, #deleteCharacterMenu").hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$("#spawnLocation").fadeOut("slow");
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener("message", function(event) {
|
||||||
|
const item = event.data;
|
||||||
|
if (item.type === "ui") {
|
||||||
|
if (item.status) {
|
||||||
|
$("#serverName").text(item.serverName);
|
||||||
|
$("body").css("background-image", "url(" + item.background + ")");
|
||||||
|
display(true);
|
||||||
|
} else {
|
||||||
|
display(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#playerAmount").text(item.characterAmount);
|
||||||
|
|
||||||
|
if (item.type === "setSpawns") {
|
||||||
|
$("#spawnMenuContainer").empty();
|
||||||
|
setTimeout(function(){
|
||||||
|
$("#tpDoNot").data("id", item.id);
|
||||||
|
$("#spawnMenuContainer").append(`<button class="spawnButtons" data-x="${item.x}" data-y="${item.y}" data-z="${item.z}">${item.name}</button>`);
|
||||||
|
$(".spawnButtons").click(function() {
|
||||||
|
$.post(`https://${GetParentResourceName()}/tpToLocation`, JSON.stringify({
|
||||||
|
x: $(this).data("x"),
|
||||||
|
y: $(this).data("y"),
|
||||||
|
z: $(this).data("z")
|
||||||
|
}));
|
||||||
|
spawnMenu(false);
|
||||||
|
setTimeout(function(){
|
||||||
|
$("#spawnMenuContainer").empty();
|
||||||
|
}, 550);
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
$("#tpDoNot").click(function() {
|
||||||
|
$.post(`https://${GetParentResourceName()}/tpDoNot`, JSON.stringify({
|
||||||
|
id: $("#tpDoNot").data("id")
|
||||||
|
}));
|
||||||
|
spawnMenu(false)
|
||||||
|
setTimeout(function(){
|
||||||
|
$("#spawnMenuContainer").empty();
|
||||||
|
}, 550);
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
}, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.type === "givePerms") {
|
||||||
|
JSON.parse(item.deptRoles).forEach((dept) => {
|
||||||
|
$(".departments").append($("<option>", {
|
||||||
|
text: dept
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.type === "aop") {
|
||||||
|
$("#aop").text(item.aop);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.type === "refresh") {
|
||||||
|
$("#charactersSection").empty();
|
||||||
|
characterCreatorMenu(false);
|
||||||
|
let characters = JSON.parse(item.characters)
|
||||||
|
Object.keys(characters).forEach((id) => {
|
||||||
|
createCharacter(characters[id].firstName, characters[id].lastName, characters[id].dob, characters[id].gender, characters[id].twt, characters[id].job, characters[id].cash, characters[id].bank, characters[id].id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function createCharacter(firstName, lastName, dateOfBirth, gender, twtName, department, startingCash, startingBank, id) {
|
||||||
|
$("#charactersSection").append(`<button id="characterButton${id}" class="createdButton">${firstName} ${lastName} (${department})</button><button id="characterButtonEdit${id}" class="createdButtonEdit"><a class="fas fa-edit"></a> Edit</button><button id="characterButtonDelete${id}" class="createdButtonDelete"><a class="fas fa-trash-alt"></a> Delete</button>`);
|
||||||
|
$(`#characterButton${id}`).click(function() {
|
||||||
|
spawnMenu(true)
|
||||||
|
$.post(`https://${GetParentResourceName()}/setMainCharacter`, JSON.stringify({
|
||||||
|
id: id
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
$(`#characterButtonEdit${id}`).click(function() {
|
||||||
|
characterEditorMenu(true)
|
||||||
|
$("#newFirstName").val(firstName);
|
||||||
|
$("#newLastName").val(lastName);
|
||||||
|
$("#newDateOfBirth").val(dateOfBirth);
|
||||||
|
$("#newGender").val(gender);
|
||||||
|
$("#newTwtName").val(twtName);
|
||||||
|
$("#newDepartment").val(department);
|
||||||
|
characterEdited = id
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
$(`#characterButtonDelete${id}`).click(function() {
|
||||||
|
confirmDeleteMenu(true)
|
||||||
|
characterDeleting = id
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#characterCreator").submit(function() {
|
||||||
|
$.post(`https://${GetParentResourceName()}/newCharacter`, JSON.stringify({
|
||||||
|
firstName: $("#firstName").val(),
|
||||||
|
lastName: $("#lastName").val(),
|
||||||
|
dateOfBirth: $("#dateOfBirth").val(),
|
||||||
|
gender: $("#gender").val(),
|
||||||
|
twtName: $("#twtName").val(),
|
||||||
|
department: $("#department").val(),
|
||||||
|
startingCash: $("#startingCash").val(),
|
||||||
|
startingBank: $("#startingBank").val()
|
||||||
|
}));
|
||||||
|
characterCreatorMenu(false)
|
||||||
|
$("#firstName, #lastName, #dateOfBirth, #twtName, #startingCash, #startingBank").val("")
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#characterEditor").submit(function() {
|
||||||
|
characterEditorMenu(false)
|
||||||
|
$.post(`https://${GetParentResourceName()}/editCharacter`, JSON.stringify({
|
||||||
|
firstName: $("#newFirstName").val(),
|
||||||
|
lastName: $("#newLastName").val(),
|
||||||
|
dateOfBirth: $("#newDateOfBirth").val(),
|
||||||
|
gender: $("#newGender").val(),
|
||||||
|
twtName: $("#newTwtName").val(),
|
||||||
|
department: $("#newDepartment").val(),
|
||||||
|
id: characterEdited
|
||||||
|
}));
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#deleteCharacterConfirm").click(function() {
|
||||||
|
confirmDeleteMenu(false)
|
||||||
|
$("#characterButton" + characterDeleting).fadeOut("slow",function(){
|
||||||
|
$("#characterButton" + characterDeleting).remove();
|
||||||
|
})
|
||||||
|
$("#characterButtonEdit" + characterDeleting).fadeOut("slow",function(){
|
||||||
|
$("#characterButtonEdit" + characterDeleting).remove();
|
||||||
|
})
|
||||||
|
$("#characterButtonDelete" + characterDeleting).fadeOut("slow",function(){
|
||||||
|
$("#characterButtonDelete" + characterDeleting).remove();
|
||||||
|
})
|
||||||
|
$.post(`https://${GetParentResourceName()}/delCharacter`, JSON.stringify({
|
||||||
|
character: characterDeleting
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#newCharacterButton").click(function() {
|
||||||
|
characterCreatorMenu(true)
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#deleteCharacterCancel").click(function() {
|
||||||
|
confirmDeleteMenu(false)
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
$("#cancelCharacterCreation").click(function() {
|
||||||
|
characterCreatorMenu(false)
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
$("#cancelCharacterEditing").click(function() {
|
||||||
|
characterEditorMenu(false)
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#tpCancel").click(function() {
|
||||||
spawnMenu(false)
|
spawnMenu(false)
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$("#spawnMenuContainer").empty();
|
$("#spawnMenuContainer").empty();
|
||||||
|
|||||||
@@ -77,7 +77,11 @@ end)
|
|||||||
-- Remove player from NDCore.Players table when they leave.
|
-- Remove player from NDCore.Players table when they leave.
|
||||||
AddEventHandler("playerDropped", function()
|
AddEventHandler("playerDropped", function()
|
||||||
local player = source
|
local player = source
|
||||||
NDCore.Players[player] = nil
|
local character = NDCore.Players[player]
|
||||||
|
if character then
|
||||||
|
NDCore.Functions.UpdateLastLocation(character.id, character.lastLocation)
|
||||||
|
end
|
||||||
|
character = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Update the characters clothes.
|
-- Update the characters clothes.
|
||||||
|
|||||||
@@ -8,3 +8,16 @@ NDCore.Config = config
|
|||||||
function GetCoreObject()
|
function GetCoreObject()
|
||||||
return NDCore
|
return NDCore
|
||||||
end
|
end
|
||||||
|
|
||||||
|
CreateThread(function()
|
||||||
|
while true do
|
||||||
|
Wait(30000)
|
||||||
|
for player, playerInfo in pairs(NDCore.Players) do
|
||||||
|
local ped = GetPlayerPed(player)
|
||||||
|
if DoesEntityExist(ped) then
|
||||||
|
local lastLocation = GetEntityCoords(ped)
|
||||||
|
playerInfo.lastLocation = {x = lastLocation.x, y = lastLocation.y, z = lastLocation.z}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
Reference in New Issue
Block a user