forked from Simnation/Main
ed
This commit is contained in:
parent
3fa969a62c
commit
b31336d080
19 changed files with 3844 additions and 85 deletions
|
@ -1,78 +0,0 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
print("^2[TRAIN-TRIGGER]^7 Client Script wird geladen...")
|
||||
|
||||
-- Test ob QBCore funktioniert
|
||||
CreateThread(function()
|
||||
Wait(2000)
|
||||
if QBCore then
|
||||
print("^2[TRAIN-TRIGGER]^7 QBCore erfolgreich geladen auf Client")
|
||||
else
|
||||
print("^1[TRAIN-TRIGGER]^7 FEHLER: QBCore nicht gefunden auf Client!")
|
||||
end
|
||||
end)
|
||||
|
||||
-- Einfache Locations (gleiche wie Server)
|
||||
local trainLocations = {
|
||||
{x = 215.3, y = -810.1, z = 30.7, name = "Legion Square"},
|
||||
{x = -265.0, y = -957.3, z = 31.2, name = "Pillbox Hospital"},
|
||||
}
|
||||
|
||||
local showMarkers = false
|
||||
|
||||
-- Test Command
|
||||
RegisterCommand('togglemarkers', function()
|
||||
showMarkers = not showMarkers
|
||||
print("^3[TRAIN-TRIGGER]^7 Markers: " .. tostring(showMarkers))
|
||||
|
||||
if QBCore and QBCore.Functions and QBCore.Functions.Notify then
|
||||
QBCore.Functions.Notify('Markers: ' .. tostring(showMarkers), 'primary')
|
||||
else
|
||||
TriggerEvent('chatMessage', "SYSTEM", "normal", "Markers: " .. tostring(showMarkers))
|
||||
end
|
||||
end, false)
|
||||
|
||||
-- Marker Loop
|
||||
CreateThread(function()
|
||||
while true do
|
||||
local sleep = 1000
|
||||
|
||||
if showMarkers then
|
||||
local playerCoords = GetEntityCoords(PlayerPedId())
|
||||
|
||||
for i, location in ipairs(trainLocations) do
|
||||
local distance = #(playerCoords - vector3(location.x, location.y, location.z))
|
||||
|
||||
if distance < 200.0 then
|
||||
sleep = 0
|
||||
-- Grüner Marker
|
||||
DrawMarker(1, location.x, location.y, location.z - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 2.0, 0, 255, 0, 150, false, true, 2, nil, nil, false)
|
||||
|
||||
if distance < 20.0 then
|
||||
-- 3D Text
|
||||
local onScreen, _x, _y = World3dToScreen2d(location.x, location.y, location.z + 2.0)
|
||||
if onScreen then
|
||||
SetTextScale(0.4, 0.4)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, 215)
|
||||
SetTextEntry("STRING")
|
||||
SetTextCentre(1)
|
||||
AddTextComponentString("[E] " .. location.name .. "\nDistanz: " .. math.floor(distance) .. "m")
|
||||
DrawText(_x, _y)
|
||||
end
|
||||
|
||||
if IsControlJustPressed(0, 38) then -- E
|
||||
print("^3[TRAIN-TRIGGER]^7 E gedrückt bei " .. location.name)
|
||||
TriggerServerEvent('train:requestStart')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Wait(sleep)
|
||||
end
|
||||
end)
|
||||
|
||||
print("^2[TRAIN-TRIGGER]^7 Client Script geladen! Commands: /togglemarkers")
|
142
resources/[standalone]/start_train/client/client.lua
Normal file
142
resources/[standalone]/start_train/client/client.lua
Normal file
|
@ -0,0 +1,142 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
local PlayerData = {}
|
||||
local isInTrainingZone = false
|
||||
local currentZone = nil
|
||||
local isInScenario = false
|
||||
|
||||
-- Events
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
||||
PlayerData = QBCore.Functions.GetPlayerData()
|
||||
CreateTrainingZones()
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
|
||||
PlayerData = {}
|
||||
end)
|
||||
|
||||
-- Erstelle Training Zones
|
||||
function CreateTrainingZones()
|
||||
for k, v in pairs(Config.TrainingZones) do
|
||||
local blip = AddBlipForCoord(v.coords.x, v.coords.y, v.coords.z)
|
||||
SetBlipSprite(blip, v.blip.sprite)
|
||||
SetBlipDisplay(blip, 4)
|
||||
SetBlipScale(blip, v.blip.scale)
|
||||
SetBlipColour(blip, v.blip.color)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
AddTextComponentSubstringPlayerName(v.blip.label)
|
||||
EndTextCommandSetBlipName(blip)
|
||||
end
|
||||
end
|
||||
|
||||
-- Main Thread für Zone Detection
|
||||
CreateThread(function()
|
||||
while true do
|
||||
local sleep = 1000
|
||||
local ped = PlayerPedId()
|
||||
local coords = GetEntityCoords(ped)
|
||||
|
||||
for k, v in pairs(Config.TrainingZones) do
|
||||
local distance = #(coords - vector3(v.coords.x, v.coords.y, v.coords.z))
|
||||
|
||||
if distance < v.radius then
|
||||
sleep = 0
|
||||
if not isInTrainingZone then
|
||||
isInTrainingZone = true
|
||||
currentZone = k
|
||||
ShowHelpText()
|
||||
end
|
||||
|
||||
if IsControlJustReleased(0, 38) then -- E Key
|
||||
StartTrainingScenario(v.scenario)
|
||||
end
|
||||
elseif isInTrainingZone and currentZone == k then
|
||||
isInTrainingZone = false
|
||||
currentZone = nil
|
||||
end
|
||||
end
|
||||
|
||||
Wait(sleep)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Zeige Help Text
|
||||
function ShowHelpText()
|
||||
CreateThread(function()
|
||||
while isInTrainingZone do
|
||||
local zoneData = Config.TrainingZones[currentZone]
|
||||
QBCore.Functions.DrawText3D(zoneData.coords.x, zoneData.coords.y, zoneData.coords.z + 1.0,
|
||||
'[E] - ' .. zoneData.label)
|
||||
Wait(0)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Starte Training Scenario
|
||||
function StartTrainingScenario(scenario)
|
||||
if isInScenario then
|
||||
QBCore.Functions.Notify('Du bist bereits in einem Szenario!', 'error')
|
||||
return
|
||||
end
|
||||
|
||||
local ped = PlayerPedId()
|
||||
|
||||
-- Prüfe ob Szenario existiert
|
||||
if not DoesScenarioExist(scenario) then
|
||||
QBCore.Functions.Notify('Szenario existiert nicht!', 'error')
|
||||
return
|
||||
end
|
||||
|
||||
isInScenario = true
|
||||
TaskStartScenarioInPlace(ped, scenario, 0, true)
|
||||
|
||||
QBCore.Functions.Notify('Szenario gestartet! Drücke [X] zum Beenden', 'success')
|
||||
|
||||
-- Thread zum Beenden des Szenarios
|
||||
CreateThread(function()
|
||||
while isInScenario do
|
||||
if IsControlJustReleased(0, 73) then -- X Key
|
||||
StopTrainingScenario()
|
||||
break
|
||||
end
|
||||
Wait(0)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Stoppe Training Scenario
|
||||
function StopTrainingScenario()
|
||||
if not isInScenario then return end
|
||||
|
||||
local ped = PlayerPedId()
|
||||
ClearPedTasks(ped)
|
||||
isInScenario = false
|
||||
|
||||
QBCore.Functions.Notify('Szenario beendet!', 'primary')
|
||||
end
|
||||
|
||||
-- Event Handler für externe Triggers
|
||||
RegisterNetEvent('train:startscenario', function(scenario)
|
||||
if not scenario then
|
||||
QBCore.Functions.Notify('Kein Szenario angegeben!', 'error')
|
||||
return
|
||||
end
|
||||
|
||||
StartTrainingScenario(scenario)
|
||||
end)
|
||||
|
||||
-- Utility Functions
|
||||
QBCore.Functions.DrawText3D = function(x, y, z, text)
|
||||
SetTextScale(0.35, 0.35)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, 215)
|
||||
SetTextEntry("STRING")
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(x, y, z, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
local factor = (string.len(text)) / 370
|
||||
DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75)
|
||||
ClearDrawOrigin()
|
||||
end
|
|
@ -1,20 +1,17 @@
|
|||
fx_version 'cerulean'
|
||||
game 'gta5'
|
||||
|
||||
author 'Dein Name'
|
||||
description 'QBCore Train Scenario Trigger Script'
|
||||
description 'QB-TrainingScenarios'
|
||||
version '1.0.0'
|
||||
|
||||
server_scripts {
|
||||
'server.lua'
|
||||
shared_scripts {
|
||||
'shared/config.lua'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'client.lua'
|
||||
'client/main.lua'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
'qb-core'
|
||||
}
|
||||
|
||||
lua54 'yes'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue