another update for quickemote to work for all section replace
cl_main.Js
add or replace
// Mock function to simulate loading the clip set
function loadClipSet(clipSet) {
return new Promise(resolve => {
// console.log(`Loading clip set: ${clipSet}`);
setTimeout(resolve, 1000); // Simulate async loading
});
}
// Function to set pedestrian walking style
function setPedWalkingStyle(playerPed, walkingStyle) {
loadClipSet(walkingStyle).then(() => {
SetPedMovementClipset(playerPed, walkingStyle, 0.2);
});
}
function playEmote(emote, category, index) {
// console.log('Playing emote:', emote);
if (category === 'emotes') {
const command = `e ${emote}`;
ExecuteCommand(command);
} else if (category === 'expressions') {
const playerPedId = PlayerPedId();
SetFacialIdleAnimOverride(playerPedId, emote);
} else if (category === 'walks') {
const playerPedId = PlayerPedId();
setPedWalkingStyle(playerPedId, emote);
} else if (category === 'placed') {
_0x137c20(0, [emote]);
} else if (category === 'dances') {
_0x36d7c7(index);
} else if (category === 'synced') {
_0x658340(0, [emote]);
} else {
console.log('Unknown category:', category);
}
}
// Register key mappings for quick emotes (using Numpad 0 to 6)
for (let i = 0; i <= 6; i++) {
RegisterKeyMapping(`quickEmote${i}`, `Trigger Quick Emote ${i}`, 'keyboard', `NUMPAD${i}`);
}
// Command to trigger the quick emote for Numpad numbers
for (let i = 0; i <= 6; i++) {
RegisterCommand(`quickEmote${i}`, () => {
// Check if SHIFT key is pressed
if (IsControlPressed(0, 21)) { // 21 is the control ID for SHIFT
NPX.Procedures.execute('emotes:triggerQuickEmote', i.toString());
}
}, false);
}
// Event handler to play the emote
onNet('emotes
layEmote', (emote, category , index) => {
console.log(`Playing emote: ${emote} from category: ${category}, index: ${index}`);
playEmote(emote , category , index);
});
// Register key mapping for 'Delete' key
RegisterKeyMapping('quickEmoteDelete', 'Trigger Quick Emote Delete', 'keyboard', 'DELETE');
// Command to trigger the quick emote for 'Delete' key
RegisterCommand('quickEmoteDelete', () => {
ExecuteCommand('e c');
}, false);
// Register command to get quick emotes
RegisterCommand('getQuickEmotes', () => {
NPX.Procedures.execute('emotes:getQuickEmotes');
}, false);
// Event handler for receiving quick emotes from the server
onNet('emotes:sendQuickEmotes', (quickEmotes) => {
console.log('Quick Emotes:', quickEmotes);
});
// Register command to set a quick emote with keybinds, category, index, and value
RegisterCommand('setQuickEmote', (source, args) => {
if (args.length < 4) {
console.log('Usage: /setQuickEmote [keybinds] [category] [index] [value]');
return;
}
const keybinds = args[0];
const category = args[1];
const index = parseInt(args[2]);
const value = args[3];
console.log(`Setting quick emote: Keybinds - ${keybinds}, Category - ${category}, Index - ${index}, Value - ${value}`);
NPX.Procedures.execute('emotes:setQuickEmote', { _0x3b923e: keybinds, _0x4ccf1e: { category, index, value } });
}, false);
sv_main.js
NPX.Procedures.register("emotes:setQuickEmote", function (pSrc, { _0x3b923e: keybinds, _0x4ccf1e: { category, index, value } }) {
let user = QBCore.Functions.GetPlayer(pSrc);
let characterId = user.PlayerData.citizenid;
// console.log(`Received quick emote to set: Keybinds - ${keybinds}, Category - ${category}, Index - ${index}, Value - ${value}`);
exports["oxmysql"].execute("SELECT id, pQuickEmote FROM player_quick_emotes WHERE player_id = ? AND keybinds = ?", [characterId, keybinds], function (result) {
if (result && result.length > 0) {
exports["oxmysql"].execute("UPDATE player_quick_emotes SET pQuickEmote = ?, emote_index = ?, category = ? WHERE id = ?", [value, index, category, result[0].id], function () {
// console.log(`Updated quick emote entry: Keybinds - ${keybinds}, Category - ${category}, Index - ${index}, Value - ${value}`);
});
} else {
exports["oxmysql"].execute("INSERT INTO player_quick_emotes (player_id, keybinds, category, emote_index, pQuickEmote) VALUES (?, ?, ?, ?, ?)", [characterId, keybinds, category, index, value], function () {
// console.log(`Inserted new quick emote entry: Keybinds - ${keybinds}, Category - ${category}, Index - ${index}, Value - ${value}`);
});
}
});
return true;
});
NPX.Procedures.register("emotes:getQuickEmotes", function (pSrc) {
let user = QBCore.Functions.GetPlayer(pSrc);
let characterId = user.PlayerData.citizenid;
if (!characterId) return null;
return new Promise((resolve, reject) => {
exports["oxmysql"].execute("SELECT * FROM player_quick_emotes WHERE player_id = ?", [characterId], function (result) {
if (result && result.length > 0) {
let quickEmotesData = result.map(row => ({
keybinds:row.keybinds,
category: row.category,
index: row.emote_index,
value: row.pQuickEmote
}));
TriggerClientEvent('emotes:sendQuickEmotes', pSrc, quickEmotesData);
resolve(quickEmotesData);
} else {
TriggerClientEvent('emotes:sendQuickEmotes', pSrc, []);
resolve([]);
}
});
});
});
NPX.Procedures.register("emotes:triggerQuickEmote", function (pSrc, index) {
let user = QBCore.Functions.GetPlayer(pSrc);
let characterId = user.PlayerData.citizenid;
if (!characterId) return null;
exports["oxmysql"].execute("SELECT pQuickEmote, category, emote_index FROM player_quick_emotes WHERE player_id = ? AND keybinds = ?", [characterId, index], function (result) {
if (result && result.length > 0) {
TriggerClientEvent('emotes
layEmote', pSrc, result[0].pQuickEmote, result[0].category, result[0].emote_index);
}
});
});