Skip to content

Commit

Permalink
feat(framework): ✨ add required events for qb-core (andristum#20)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
AvaN0x authored Jul 8, 2022
1 parent c7af06d commit 7eaf5a3
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 10 deletions.
26 changes: 21 additions & 5 deletions client/AnimationList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3982,14 +3982,14 @@ DP.PropEmotes = {
PropPlacement = { 0.0480, 0.0780, 0.0040, -81.6893, 2.5616, -15.7909 },
EmoteLoop = true,
EmoteMoving = true,
}},
["cop4"] = { "amb@world_human_car_park_attendant@male@base", "base", "Cop 4", AnimationOptions = {
}},
["cop4"] = { "amb@world_human_car_park_attendant@male@base", "base", "Cop 4", AnimationOptions = {
Prop = "prop_parking_wand_01",
PropBone = 57005,
PropPlacement = { 0.12, 0.05, 0.0, 80.0, -20.0, 180.0 },
EmoteLoop = true,
EmoteMoving = true,
} },
}},
["leanphone"] = { "amb@world_human_leaning@male@wall@back@mobile@base", "base", "Leaning With Phone", AnimationOptions = {
EmoteMoving = false,
EmoteLoop = true,
Expand All @@ -4005,12 +4005,28 @@ DP.PropEmotes = {
PtfxPlacement = { -0.05, 0.3, 0.0, 0.0, 90.0, 90.0, 1.0 },
PtfxInfo = Config.Languages[Config.MenuLanguage]['pee'],
PtfxWait = 3000,
} },
}},
["hump"] = { "timetable@trevor@skull_loving_bear", "skull_loving_bear", "Hump (Bear)", AnimationOptions = {
Prop = 'prop_mr_raspberry_01',
PropBone = 28422,
PropPlacement = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
EmoteMoving = false,
EmoteLoop = true,
} },
}},
["eat"] = {"mp_player_inteat@burger", "mp_player_int_eat_burger_fp", "Eat", AnimationOptions =
{
Prop = "prop_cs_burger_01",
PropBone = 18905,
PropPlacement = {0.12, 0.028, 0.001, 10.0, 175.0},
EmoteMoving = true,
EmoteLoop = true,
}},
["drink"] = {"mp_player_intdrink", "loop_bottle", "Drink", AnimationOptions =
{
Prop = "prop_ld_flow_bottle",
PropBone = 18905,
PropPlacement = {0.12, 0.008, 0.03, 240.0, -60.0},
EmoteMoving = true,
EmoteLoop = true,
}},
}
4 changes: 2 additions & 2 deletions client/EmoteMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ if Config.FavKeybindEnabled then
while true do
if IsControlPressed(0, Config.FavKeybind) then
if not IsPedSittingInAnyVehicle(PlayerPedId()) then
if FavoriteEmote ~= "" then
if FavoriteEmote ~= "" and (not CanUseFavKeyBind or CanUseFavKeyBind()) then
EmoteCommandStart(nil, { FavoriteEmote, 0 })
Wait(3000)
end
end
end
Citizen.Wait(1)
Citizen.Wait(0)
end
end)
end
Expand Down
102 changes: 102 additions & 0 deletions client/frameworks/qb-core.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
if Config.Framework ~= 'qb-core' then return end

local framework = 'qb-core'
local state = GetResourceState(framework)

if state == 'missing' or state == "unknown" then
-- Framework can't be used if it's missing or unknown
return
end

QBCore, PlayerData, isLoggedIn = nil, nil, false

-- QB core parts
QBCore = exports[framework]:GetCoreObject()
PlayerData = QBCore.Functions.GetPlayerData()
isLoggedIn = false

RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
PlayerData = QBCore.Functions.GetPlayerData()
isLoggedIn = true
end)

RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
PlayerData = {}
isLoggedIn = false
end)

RegisterNetEvent('QBCore:Player:SetPlayerData', function(val)
PlayerData = val
end)

-- This is here to get the player data when the resource is restarted instead of having to log out and back in each time
-- This won't set the player data too early as this only triggers when the server side is started and not the client side
AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
Wait(200)
PlayerData = QBCore.Functions.GetPlayerData()
isLoggedIn = true
end
end)

function CanUseFavKeyBind()
return not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead']
end

-- Added events
RegisterNetEvent('animations:client:PlayEmote', function(args)
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
EmoteCommandStart(source, args)
end
end)

if Config.SqlKeybinding then
RegisterNetEvent('animations:client:BindEmote', function(args)
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
EmoteBindStart(source, args)
end
end)

RegisterNetEvent('animations:client:EmoteBinds', function()
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
EmoteBindsStart()
end
end)
end

RegisterNetEvent('animations:client:EmoteMenu', function()
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
OpenEmoteMenu()
end
end)

RegisterNetEvent('animations:client:ListEmotes', function()
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
EmotesOnCommand()
end
end)

RegisterNetEvent('animations:client:Walk', function(args)
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
WalkCommandStart(source, args)
end
end)

RegisterNetEvent('animations:client:ListWalks', function()
if not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['isdead'] then
WalksOnCommand()
end
end)

-- Added by https://github.dev/qbcore-framework/dpemotes/

CanDoEmote = true
RegisterNetEvent('animations:ToggleCanDoAnims', function(bool)
CanDoEmote = bool
end)

RegisterNetEvent('animations:client:EmoteCommandStart', function(args)
if CanDoEmote then
EmoteCommandStart(source, args)
end
end)
2 changes: 2 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Config = {
CheckForUpdates = true,
-- If you have the SQL imported enable this to turn on keybinding.
SqlKeybinding = false,
-- Used for few framework dependent things. Accepted values: qb-core, false
Framework = false,
}

Config.KeybindKeys = {
Expand Down
5 changes: 3 additions & 2 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fx_version 'adamant'

game 'gta5'

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

client_scripts {
'NativeUI.lua',
'client/*.lua'
'client/*.lua',
'client/frameworks/*.lua'
}


Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
207
208

0 comments on commit 7eaf5a3

Please sign in to comment.