Skip to content

Commit 7eaf5a3

Browse files
authored
feat(framework): ✨ add required events for qb-core (andristum#20)
* feat(framework): ✨ add required events for qb-core This should hopefully work as intended. Adding things that were added to https://github.com/qbcore-framework/dpemotes for qb servers using this version of dpemotes
1 parent c7af06d commit 7eaf5a3

File tree

6 files changed

+131
-10
lines changed

6 files changed

+131
-10
lines changed

client/AnimationList.lua

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3982,14 +3982,14 @@ DP.PropEmotes = {
39823982
PropPlacement = { 0.0480, 0.0780, 0.0040, -81.6893, 2.5616, -15.7909 },
39833983
EmoteLoop = true,
39843984
EmoteMoving = true,
3985-
}},
3986-
["cop4"] = { "amb@world_human_car_park_attendant@male@base", "base", "Cop 4", AnimationOptions = {
3985+
}},
3986+
["cop4"] = { "amb@world_human_car_park_attendant@male@base", "base", "Cop 4", AnimationOptions = {
39873987
Prop = "prop_parking_wand_01",
39883988
PropBone = 57005,
39893989
PropPlacement = { 0.12, 0.05, 0.0, 80.0, -20.0, 180.0 },
39903990
EmoteLoop = true,
39913991
EmoteMoving = true,
3992-
} },
3992+
}},
39933993
["leanphone"] = { "amb@world_human_leaning@male@wall@back@mobile@base", "base", "Leaning With Phone", AnimationOptions = {
39943994
EmoteMoving = false,
39953995
EmoteLoop = true,
@@ -4005,12 +4005,28 @@ DP.PropEmotes = {
40054005
PtfxPlacement = { -0.05, 0.3, 0.0, 0.0, 90.0, 90.0, 1.0 },
40064006
PtfxInfo = Config.Languages[Config.MenuLanguage]['pee'],
40074007
PtfxWait = 3000,
4008-
} },
4008+
}},
40094009
["hump"] = { "timetable@trevor@skull_loving_bear", "skull_loving_bear", "Hump (Bear)", AnimationOptions = {
40104010
Prop = 'prop_mr_raspberry_01',
40114011
PropBone = 28422,
40124012
PropPlacement = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
40134013
EmoteMoving = false,
40144014
EmoteLoop = true,
4015-
} },
4015+
}},
4016+
["eat"] = {"mp_player_inteat@burger", "mp_player_int_eat_burger_fp", "Eat", AnimationOptions =
4017+
{
4018+
Prop = "prop_cs_burger_01",
4019+
PropBone = 18905,
4020+
PropPlacement = {0.12, 0.028, 0.001, 10.0, 175.0},
4021+
EmoteMoving = true,
4022+
EmoteLoop = true,
4023+
}},
4024+
["drink"] = {"mp_player_intdrink", "loop_bottle", "Drink", AnimationOptions =
4025+
{
4026+
Prop = "prop_ld_flow_bottle",
4027+
PropBone = 18905,
4028+
PropPlacement = {0.12, 0.008, 0.03, 240.0, -60.0},
4029+
EmoteMoving = true,
4030+
EmoteLoop = true,
4031+
}},
40164032
}

client/EmoteMenu.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ if Config.FavKeybindEnabled then
4949
while true do
5050
if IsControlPressed(0, Config.FavKeybind) then
5151
if not IsPedSittingInAnyVehicle(PlayerPedId()) then
52-
if FavoriteEmote ~= "" then
52+
if FavoriteEmote ~= "" and (not CanUseFavKeyBind or CanUseFavKeyBind()) then
5353
EmoteCommandStart(nil, { FavoriteEmote, 0 })
5454
Wait(3000)
5555
end
5656
end
5757
end
58-
Citizen.Wait(1)
58+
Citizen.Wait(0)
5959
end
6060
end)
6161
end

client/frameworks/qb-core.lua

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
if Config.Framework ~= 'qb-core' then return end
2+
3+
local framework = 'qb-core'
4+
local state = GetResourceState(framework)
5+
6+
if state == 'missing' or state == "unknown" then
7+
-- Framework can't be used if it's missing or unknown
8+
return
9+
end
10+
11+
QBCore, PlayerData, isLoggedIn = nil, nil, false
12+
13+
-- QB core parts
14+
QBCore = exports[framework]:GetCoreObject()
15+
PlayerData = QBCore.Functions.GetPlayerData()
16+
isLoggedIn = false
17+
18+
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
19+
PlayerData = QBCore.Functions.GetPlayerData()
20+
isLoggedIn = true
21+
end)
22+
23+
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
24+
PlayerData = {}
25+
isLoggedIn = false
26+
end)
27+
28+
RegisterNetEvent('QBCore:Player:SetPlayerData', function(val)
29+
PlayerData = val
30+
end)
31+
32+
-- This is here to get the player data when the resource is restarted instead of having to log out and back in each time
33+
-- This won't set the player data too early as this only triggers when the server side is started and not the client side
34+
AddEventHandler('onResourceStart', function(resource)
35+
if resource == GetCurrentResourceName() then
36+
Wait(200)
37+
PlayerData = QBCore.Functions.GetPlayerData()
38+
isLoggedIn = true
39+
end
40+
end)
41+
42+
function CanUseFavKeyBind()
43+
return not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead']
44+
end
45+
46+
-- Added events
47+
RegisterNetEvent('animations:client:PlayEmote', function(args)
48+
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
49+
EmoteCommandStart(source, args)
50+
end
51+
end)
52+
53+
if Config.SqlKeybinding then
54+
RegisterNetEvent('animations:client:BindEmote', function(args)
55+
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
56+
EmoteBindStart(source, args)
57+
end
58+
end)
59+
60+
RegisterNetEvent('animations:client:EmoteBinds', function()
61+
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
62+
EmoteBindsStart()
63+
end
64+
end)
65+
end
66+
67+
RegisterNetEvent('animations:client:EmoteMenu', function()
68+
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
69+
OpenEmoteMenu()
70+
end
71+
end)
72+
73+
RegisterNetEvent('animations:client:ListEmotes', function()
74+
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
75+
EmotesOnCommand()
76+
end
77+
end)
78+
79+
RegisterNetEvent('animations:client:Walk', function(args)
80+
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
81+
WalkCommandStart(source, args)
82+
end
83+
end)
84+
85+
RegisterNetEvent('animations:client:ListWalks', function()
86+
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
87+
WalksOnCommand()
88+
end
89+
end)
90+
91+
-- Added by https://github.dev/qbcore-framework/dpemotes/
92+
93+
CanDoEmote = true
94+
RegisterNetEvent('animations:ToggleCanDoAnims', function(bool)
95+
CanDoEmote = bool
96+
end)
97+
98+
RegisterNetEvent('animations:client:EmoteCommandStart', function(args)
99+
if CanDoEmote then
100+
EmoteCommandStart(source, args)
101+
end
102+
end)

config.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Config = {
4040
CheckForUpdates = true,
4141
-- If you have the SQL imported enable this to turn on keybinding.
4242
SqlKeybinding = false,
43+
-- Used for few framework dependent things. Accepted values: qb-core, false
44+
Framework = false,
4345
}
4446

4547
Config.KeybindKeys = {

fxmanifest.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fx_version 'adamant'
66

77
game 'gta5'
88

9-
-- Comment the following linnes if you don't want to use the SQL keybinds
9+
-- Comment the following lines if you don't want to use the SQL keybinds
1010
--#region oxmysql
1111
-- dependency 'oxmysql'
1212
-- server_script "@oxmysql/lib/MySQL.lua"
@@ -23,7 +23,8 @@ server_scripts {
2323

2424
client_scripts {
2525
'NativeUI.lua',
26-
'client/*.lua'
26+
'client/*.lua',
27+
'client/frameworks/*.lua'
2728
}
2829

2930

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
207
1+
208

0 commit comments

Comments
 (0)