Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit53edd7f

Browse files
committed
Merge branch 'vehreg' of github.com:Sonoran-Software/SonoranCADFiveM; branch 'feat-functionality' of github.com:Bushcowboy/SonoranCADFiveM into vehreg
2 parents426489c +034ef71 commit53edd7f

File tree

4 files changed

+254
-16
lines changed

4 files changed

+254
-16
lines changed

‎tablet/cl_main.lua‎

Lines changed: 138 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@ isMiniVisible = false
77
-- Debugging Information
88
isDebugging=true
99

10+
FrameworkConfig=nil
11+
Framework=nil
12+
1013
functionDebugMessage(message,module)
1114
ifnotisDebuggingthenreturnend
1215
ifmodule~=nilthenmessage="["..module.."]"..messageend
1316
print(message.."\n")
1417
end
1518

1619
-- Initialization Procedure
17-
Citizen.CreateThread(function()
20+
CreateThread(function()
1821
Wait(1000)
22+
-- Request framework configuration from server
23+
TriggerServerEvent("SonoranCAD::requestFrameworkConfig")
24+
1925
-- Set Default Module Sizes
2026
InitModuleSize("cad")
2127
InitModuleSize("hud")
@@ -37,6 +43,38 @@ Citizen.CreateThread(function()
3743

3844
TriggerServerEvent("SonoranCAD::mini:CallSync_S")
3945

46+
-- Vehicle Exit/Enter Detection for Auto-Hide Mini-CAD
47+
ifConfig.AutoHideOnVehicleExitthen
48+
localwasInVehicle=false
49+
localminiCadWasVisible=false
50+
51+
CreateThread(function()
52+
whiletruedo
53+
localplayerPed=GetPlayerPed(-1)
54+
localisInVehicle=IsPedInAnyVehicle(playerPed,false)
55+
56+
-- Check if player just exited a vehicle
57+
ifwasInVehicleandnotisInVehiclethen
58+
ifisMiniVisiblethen
59+
miniCadWasVisible=true
60+
DisplayModule("hud",false)
61+
DebugMessage("Auto-hiding mini-CAD on vehicle exit")
62+
end
63+
-- Check if player just entered a vehicle
64+
elseifnotwasInVehicleandisInVehiclethen
65+
ifminiCadWasVisiblethen
66+
DisplayModule("hud",true)
67+
miniCadWasVisible=false
68+
DebugMessage("Auto-showing mini-CAD on vehicle enter")
69+
end
70+
end
71+
72+
wasInVehicle=isInVehicle
73+
Wait(50)
74+
end
75+
end)
76+
end
77+
4078
-- Disable Controls Loop
4179
whiletruedo
4280
ifnuiFocusedthen-- Disable controls while NUI is focused.
@@ -45,17 +83,15 @@ Citizen.CreateThread(function()
4583
DisableControlAction(0,142,nuiFocused)-- MeleeAttackAlternate
4684
DisableControlAction(0,106,nuiFocused)-- VehicleMouseControlOverride
4785
end
48-
Citizen.Wait(0)-- Yield until next frame.
86+
Wait(0)-- Yield until next frame.
4987
end
5088
end)
5189

5290
functionInitModuleSize(module)
53-
-- Check if the size of the specified module is already configured.
5491
localmoduleWidth=GetResourceKvpString(module.."width")
5592
localmoduleHeight=GetResourceKvpString(module.."height")
5693
ifmoduleWidth~=nilandmoduleHeight~=nilthen
5794
DebugMessage("retrieving saved presets",module)
58-
-- Send message to NUI to resize the specified module.
5995
SetModuleSize(module,moduleWidth,moduleHeight)
6096
SendNUIMessage({
6197
type="refresh",
@@ -68,7 +104,6 @@ function InitModuleConfig(module)
68104
localmoduleMaxRows=GetResourceKvpString(module.."maxrows")
69105
ifmoduleMaxRows~=nilthen
70106
DebugMessage("retrieving config presets",module)
71-
-- Send messsage to NUI to update config of specified module.
72107
SetModuleConfigValue(module,"maxrows",moduleMaxRows)
73108
SendNUIMessage({
74109
type="refresh",
@@ -163,7 +198,11 @@ RegisterNetEvent("SonoranCAD::mini:OpenMini:Return")
163198
AddEventHandler('SonoranCAD::mini:OpenMini:Return',function(authorized,ident)
164199
myident=ident
165200
ifauthorizedthen
166-
DisplayModule("hud",true)
201+
ifnotisMiniVisiblethen
202+
DisplayModule("hud",true)
203+
else
204+
DisplayModule("hud",false)
205+
end
167206
ifnotGetResourceKvpString("shownTutorial")then
168207
ShowHelpMessage()
169208
SetResourceKvp("shownTutorial","yes")
@@ -186,9 +225,68 @@ function ShowHelpMessage()
186225
PrintChatMessage("Keybinds: Attach/Detach [K], Details [L], Previous/Next [LEFT/RIGHT], changable in settings!")
187226
end
188227

228+
functionIsInWhitelistedVehicle()
229+
localped=PlayerPedId()
230+
ifnotIsPedInAnyVehicle(ped,false)thenreturnfalseend
231+
localveh=GetVehiclePedIsIn(ped,false)
232+
ifvehandveh~=0then
233+
localmodel=GetEntityModel(veh)
234+
for_,allowedinipairs(Config.AccessRestrictions.AllowedVehiclesor {})do
235+
ifmodel==GetHashKey(allowed)then
236+
returntrue
237+
end
238+
end
239+
end
240+
returnfalse
241+
end
242+
243+
functionCheckJobRestriction()
244+
localjobAllowed=true
245+
ifConfig.AccessRestrictions.RestrictByJobthen
246+
jobAllowed=false
247+
localplayerJob=nil
248+
249+
-- Check if framework is initialized
250+
ifFrameworkConfig.usingQBCorethen
251+
localPlayer=Framework.Functions.GetPlayerData()
252+
playerJob=Player.job.name
253+
else
254+
localxPlayer=Framework.GetPlayerData()
255+
playerJob=xPlayer.job.name
256+
end
257+
258+
ifplayerJobthen
259+
for_,allowedJobinpairs(Config.AccessRestrictions.AllowedJobs)do
260+
ifplayerJob==allowedJobthen
261+
jobAllowed=true
262+
break
263+
end
264+
end
265+
end
266+
end
267+
268+
localvehicleAllowed=true
269+
ifConfig.AccessRestrictions.RestrictByVehiclethen
270+
vehicleAllowed=IsInWhitelistedVehicle()
271+
end
272+
273+
returnjobAllowedandvehicleAllowed
274+
end
275+
189276
-- Mini Module Commands
190277
RegisterCommand("minicad",function(source,args,rawCommand)
191-
TriggerServerEvent("SonoranCAD::mini:OpenMini")
278+
ifnotCheckJobRestriction()then
279+
PrintChatMessage("You do not have permission to access the Mini-CAD.")
280+
return
281+
end
282+
283+
localped=PlayerPedId()
284+
localinVehicle=IsPedInAnyVehicle(ped,false)
285+
ifConfig.AllowMiniCadOnFootorinVehiclethen
286+
TriggerServerEvent("SonoranCAD::mini:OpenMini")
287+
else
288+
PrintChatMessage("You must be in a vehicle to access the Mini-CAD.")
289+
end
192290
end,false)
193291
RegisterKeyMapping('minicad','Mini CAD','keyboard','')
194292

@@ -201,7 +299,7 @@ end, false)
201299
RegisterKeyMapping('minicadp','Previous Call','keyboard','LEFT')
202300

203301
RegisterCommand("minicada",function(source,args,rawCommand)
204-
print("ismini"..tostring(isMiniVisible))
302+
print("attach")
205303
ifnotisMiniVisiblethenreturnend
206304
SendNUIMessage({type="command",key="attach"})
207305
end,false)
@@ -243,14 +341,25 @@ TriggerEvent('chat:addSuggestion', '/minicadrows', "Specify max number of call n
243341
{name="rows",help="any number (default 10)"}
244342
})
245343

344+
246345
-- CAD Module Commands
247346
RegisterCommand("showcad",function(source,args,rawCommand)
347+
ifnotCheckJobRestriction()then
348+
PrintChatMessage("You do not have permission to access the CAD Tablet.")
349+
return
350+
end
248351
DisplayModule("cad",true)
249352
toggleTabletDisplay(true)
250353
SetFocused(true)
251354
end,false)
252355
RegisterKeyMapping('showcad','CAD Tablet','keyboard','')
253356

357+
RegisterNetEvent("SonoranCAD::showcad",function()
358+
DisplayModule("cad",true)
359+
toggleTabletDisplay(true)
360+
SetFocused(true)
361+
end)
362+
254363
TriggerEvent('chat:addSuggestion','/cadsize',"Resize CAD to specific width and height in pixels. Default is 1100x510", {
255364
{name="Width",help="Width in pixels"}, {name="Height",help="Height in pixels"}
256365
})
@@ -392,4 +501,24 @@ end)
392501
RegisterNetEvent("sonoran:tablet:failed")
393502
AddEventHandler("sonoran:tablet:failed",function(message)
394503
errorLog("Failed to set API ID:"..tostring(message))
395-
end)
504+
end)
505+
506+
RegisterNetEvent("SonoranCAD::receiveFrameworkConfig")
507+
AddEventHandler("SonoranCAD::receiveFrameworkConfig",function(frameworkConfig)
508+
ifisDebuggingthen
509+
print("Framework Configuration received:")
510+
print("Using QBCore:"..tostring(frameworkConfig.usingQBCore))
511+
forkey,valueinpairs(frameworkConfig)do
512+
print(key..":"..tostring(value))
513+
end
514+
end
515+
ifframeworkConfig.usingQBCorethen
516+
FrameworkConfig=frameworkConfig
517+
Framework=exports['qb-core']:GetCoreObject()
518+
print("Framework initialized: QBCore")
519+
else
520+
FrameworkConfig=frameworkConfig
521+
Framework=exports.es_extended:getSharedObject()
522+
print("Framework initialized: ESX")
523+
end
524+
end)

‎tablet/config.lua‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Config= {}
2+
3+
Config.AutoHideOnVehicleExit=true-- if true, the cad will automatically hide when the player exits a vehicle
4+
Config.AllowMiniCadOnFoot=false-- if true, player can access the cad while on foot
5+
6+
Config.AccessRestrictions= {
7+
RequireTabletItem=true,-- if true, player must have the tablet item to access the cad
8+
TabletItemName="sonoran_tablet",-- name of the tablet item
9+
RestrictByJob=true,-- if true, player must have a job in the allowed jobs list to access the cad
10+
RestrictByVehicle=false,-- if true, player must be in a vehicle in the allowed vehicles list to access the cad
11+
AllowedJobs= {
12+
"lspd",
13+
"sheriff",
14+
"ambulance",
15+
"fire"
16+
},
17+
AllowedVehicles= {
18+
"police",
19+
"police2",
20+
"police3",
21+
"police4",
22+
"fbi",
23+
"fbi2",
24+
"ambulance",
25+
"firetruk"
26+
}
27+
}

‎tablet/fxmanifest.lua‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ games {'gta5'}
44

55
ui_page'html/index.html'
66

7+
shared_scripts {
8+
'config.lua'
9+
}
10+
711
server_scripts {
812
'sv_main.lua'
913
}
@@ -17,5 +21,6 @@ files {
1721
'html/index.html',
1822
'html/style.css',
1923
'html/reset.css',
20-
"html/script.js"
21-
}
24+
"html/script.js",
25+
"html/tablet.png"
26+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp