Skip to content

Commit 6056046

Browse files
committed
Don't import whole core
1 parent 6f205f5 commit 6056046

6 files changed

Lines changed: 161 additions & 134 deletions

File tree

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto eol=lf
2+
3+
# Lua and web files - always treat as text
4+
*.lua text eol=lf
5+
*.js text eol=lf
6+
*.html text eol=lf
7+
*.css text eol=lf
8+
*.json text eol=lf
9+
*.xml text eol=lf
10+
*.yml text eol=lf
11+
*.md text eol=lf

client/main.lua renamed to client.lua

Lines changed: 82 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
local QBCore = exports['qb-core']:GetCoreObject()
1+
local QBCore = exports['qb-core']:GetCoreObject({ 'Functions' })
2+
local sharedVehicles = exports['qb-core']:GetShared('Vehicles')
23
local PlayerJob = {}
34
local patt = '[?!@#]'
45
local frontCam = false
6+
local phoneProp = 0
7+
local phoneModel = `prop_npc_phone_02`
58
PhoneData = {
69
MetaData = {},
710
isOpen = false,
@@ -28,6 +31,63 @@ PhoneData = {
2831

2932
-- Functions
3033

34+
local function LoadAnimation(dict)
35+
RequestAnimDict(dict)
36+
while not HasAnimDictLoaded(dict) do
37+
Wait(1)
38+
end
39+
end
40+
41+
local function CheckAnimLoop()
42+
CreateThread(function()
43+
while PhoneData.AnimationData.lib ~= nil and PhoneData.AnimationData.anim ~= nil do
44+
local ped = PlayerPedId()
45+
if not IsEntityPlayingAnim(ped, PhoneData.AnimationData.lib, PhoneData.AnimationData.anim, 3) then
46+
LoadAnimation(PhoneData.AnimationData.lib)
47+
TaskPlayAnim(ped, PhoneData.AnimationData.lib, PhoneData.AnimationData.anim, 3.0, 3.0, -1, 50, 0, false, false, false)
48+
end
49+
Wait(500)
50+
end
51+
end)
52+
end
53+
54+
function newPhoneProp()
55+
deletePhone()
56+
RequestModel(phoneModel)
57+
while not HasModelLoaded(phoneModel) do
58+
Wait(1)
59+
end
60+
phoneProp = CreateObject(phoneModel, 1.0, 1.0, 1.0, 1, 1, 0)
61+
62+
local bone = GetPedBoneIndex(PlayerPedId(), 28422)
63+
if phoneModel == `prop_cs_phone_01` then
64+
AttachEntityToEntity(phoneProp, PlayerPedId(), bone, 0.0, 0.0, 0.0, 50.0, 320.0, 50.0, 1, 1, 0, 0, 2, 1)
65+
else
66+
AttachEntityToEntity(phoneProp, PlayerPedId(), bone, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 0, 0, 2, 1)
67+
end
68+
end
69+
70+
function deletePhone()
71+
if phoneProp ~= 0 then
72+
DeleteObject(phoneProp)
73+
phoneProp = 0
74+
end
75+
end
76+
77+
function DoPhoneAnimation(anim)
78+
local ped = PlayerPedId()
79+
local AnimationLib = 'cellphone@'
80+
local AnimationStatus = anim
81+
if IsPedInAnyVehicle(ped, false) then
82+
AnimationLib = 'anim@cellphone@in_car@ps'
83+
end
84+
LoadAnimation(AnimationLib)
85+
TaskPlayAnim(ped, AnimationLib, AnimationStatus, 3.0, 3.0, -1, 50, 0, false, false, false)
86+
PhoneData.AnimationData.lib = AnimationLib
87+
PhoneData.AnimationData.anim = AnimationStatus
88+
CheckAnimLoop()
89+
end
90+
3191
function string:split(delimiter)
3292
local result = {}
3393
local from = 1
@@ -978,8 +1038,8 @@ RegisterNUICallback('FetchVehicleScan', function(_, cb)
9781038
QBCore.Functions.TriggerCallback('qb-phone:server:ScanPlate', function(result)
9791039
QBCore.Functions.TriggerCallback('police:IsPlateFlagged', function(flagged)
9801040
result.isFlagged = flagged
981-
if QBCore.Shared.Vehicles[vehname] ~= nil then
982-
result.label = QBCore.Shared.Vehicles[vehname]['name']
1041+
if sharedVehicles[vehname] ~= nil then
1042+
result.label = sharedVehicles[vehname]['name']
9831043
else
9841044
result.label = 'Unknown brand..'
9851045
end
@@ -1480,14 +1540,26 @@ RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
14801540
}
14811541
end)
14821542

1483-
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo)
1484-
SendNUIMessage({
1485-
action = 'UpdateApplications',
1486-
JobData = JobInfo,
1487-
applications = Config.PhoneApplications
1488-
})
1543+
RegisterNetEvent('QBCore:Client:OnPlayerUpdated', function(key, val)
1544+
if key == 'job' then
1545+
local JobInfo = val
1546+
SendNUIMessage({
1547+
action = 'UpdateApplications',
1548+
JobData = JobInfo,
1549+
applications = Config.PhoneApplications
1550+
})
14891551

1490-
PlayerJob = JobInfo
1552+
PlayerJob = JobInfo
1553+
elseif key == 'all' then
1554+
local JobInfo = val.job
1555+
SendNUIMessage({
1556+
action = 'UpdateApplications',
1557+
JobData = JobInfo,
1558+
applications = Config.PhoneApplications
1559+
})
1560+
1561+
PlayerJob = JobInfo
1562+
end
14911563
end)
14921564

14931565
-- Events

client/animation.lua

Lines changed: 0 additions & 59 deletions
This file was deleted.

config.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Config.RepeatTimeout = 2000
77
Config.CallRepeats = 10
88
Config.OpenPhone = 'M'
99

10-
-- Set this to true if you wish to use Fivemerr (https://fivemerr.com/) for media uploads.
11-
-- Ensure to add your API key to server/main.lua
10+
-- Set this to true if you wish to use Fivemerr (https://fivemerr.com/) for media uploads.
11+
-- Ensure to add your API key to server/main.lua
1212
Config.Fivemerr = false
1313

1414
Config.PhoneApplications = {

fxmanifest.lua

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,22 @@ game 'gta5'
33
lua54 'yes'
44
author 'Kakarot'
55
description 'Allows players to access a phone to interact with various apps and features'
6-
version '1.3.0'
7-
8-
ui_page 'html/index.html'
6+
version '1.5.0'
97

108
shared_scripts {
119
'config.lua',
1210
'@qb-apartments/config.lua'
1311
}
1412

15-
client_scripts {
16-
'client/main.lua',
17-
'client/animation.lua'
18-
}
13+
client_script 'client.lua'
1914

2015
server_scripts {
2116
'@oxmysql/lib/MySQL.lua',
22-
'server/main.lua'
17+
'server.lua'
2318
}
2419

20+
ui_page 'html/index.html'
21+
2522
files {
2623
'html/*.html',
2724
'html/js/*.js',

0 commit comments

Comments
 (0)