diff --git a/resources/[carscripts]/mh_garage/client/main.lua b/resources/[carscripts]/mh_garage/client/main.lua new file mode 100644 index 000000000..64a0796e2 --- /dev/null +++ b/resources/[carscripts]/mh_garage/client/main.lua @@ -0,0 +1,67 @@ +QBCore = exports['qb-core']:GetCoreObject() + +Player = nil +local npcHandle = nil +local isNPCSpawned = false + +Citizen.CreateThread(function() + while Player == nil do + Player = exports['qb-core']:GetPlayerData() + Wait(0) + end +end) + +-- Funktion zum Spawnen des NPCs +local function SpawnGuardNPC(npc) + -- Ped Model laden + RequestModel(npc.model) + while not HasModelLoaded(npc.model) do + Wait(1) + end + + -- NPC erstellen + npcHandle = CreatePed(4, npc.model, npc.spawn, false, true) + + -- NPC Eigenschaften setzen + SetEntityAsMissionEntity(npcHandle, true, true) + SetBlockingOfNonTemporaryEvents(npcHandle, true) + SetPedDiesWhenInjured(npcHandle, false) + SetPedCanPlayAmbientAnims(npcHandle, true) + SetPedCanRagdollFromPlayerImpact(npcHandle, false) + SetEntityInvincible(npcHandle, true) + FreezeEntityPosition(npcHandle, true) + + -- Optional: Animation für den NPC + TaskStartScenarioInPlace(npcHandle, "WORLD_HUMAN_GUARD_STAND", 0, true) + + isNPCSpawned = true +end + +-- Funktion zum Entfernen des NPCs +local function RemoveGuardNPC() + if DoesEntityExist(npcHandle) then + DeleteEntity(npcHandle) + isNPCSpawned = false + end +end + +-- Hauptthread zum Überprüfen der Spieler-Position +CreateThread(function() + while true do + local playerPed = PlayerPedId() + local playerCoords = GetEntityCoords(playerPed) + + for k, v in pairs(Config.Zonen) do + local dist = #(playerCoords - v.NPC.spawn) + local spawnDistance = v.NPC.distance + + if dist < spawnDistance and not isNPCSpawned then + SpawnGuardNPC() + elseif dist > spawnDistance and isNPCSpawned then + RemoveGuardNPC() + end + end + + Wait(1000) -- Überprüfung jede Sekunde + end +end) \ No newline at end of file diff --git a/resources/[carscripts]/mh_garage/config.lua b/resources/[carscripts]/mh_garage/config.lua new file mode 100644 index 000000000..7ff0cf5a6 --- /dev/null +++ b/resources/[carscripts]/mh_garage/config.lua @@ -0,0 +1,19 @@ +Config = {} + +Config.Zonen = { + { + name = "Meetingpoint", + price = nil, --pro FZ + NPC = { + spawn = vector4(236.1920, -798.5126, 30.4188, 173.7135), + model = "s_m_m_security_01", + distance = 30.0 + }, + vehicle_spawn = { + vector4(247.4089, -799.2991, 29.7057, 159.1259), + vector4(250.7647, -800.5372, 29.6305, 159.2400), + vector4(239.2613, -808.8478, 29.8017, 339.9538), + vector4(242.8265, -809.7695, 29.7245, 338.3645) + } + } +} \ No newline at end of file diff --git a/resources/[carscripts]/mh_garage/fxmanifest.lua b/resources/[carscripts]/mh_garage/fxmanifest.lua new file mode 100644 index 000000000..164de20d8 --- /dev/null +++ b/resources/[carscripts]/mh_garage/fxmanifest.lua @@ -0,0 +1,18 @@ +author 'Mîhó' + +fx_version 'adamant' +game 'gta5' +lua54 'yes' + +client_scripts { + '@NativeUI/NativeUI.lua', + '@ox_lib/init.lua', + 'config.lua', + 'client/*.lua' +} + +server_scripts { + '@oxmysql/lib/MySQL.lua', + 'config.lua', + 'server/*.lua' +} \ No newline at end of file