1
0
Fork 0
forked from Simnation/Main
Main/resources/[standalone]/start_train/client.lua

79 lines
2.8 KiB
Lua
Raw Normal View History

2025-08-13 16:59:56 +02:00
local QBCore = exports['qb-core']:GetCoreObject()
2025-08-13 17:06:31 +02:00
print("^2[TRAIN-TRIGGER]^7 Client Script wird geladen...")
2025-08-13 16:59:56 +02:00
2025-08-13 17:06:31 +02:00
-- 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
2025-08-13 16:59:56 +02:00
end)
2025-08-13 17:06:31 +02:00
-- 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"},
}
2025-08-13 16:59:56 +02:00
2025-08-13 17:06:31 +02:00
local showMarkers = false
2025-08-13 16:59:56 +02:00
2025-08-13 17:06:31 +02:00
-- Test Command
RegisterCommand('togglemarkers', function()
2025-08-13 16:59:56 +02:00
showMarkers = not showMarkers
2025-08-13 17:06:31 +02:00
print("^3[TRAIN-TRIGGER]^7 Markers: " .. tostring(showMarkers))
2025-08-13 16:59:56 +02:00
2025-08-13 17:06:31 +02:00
if QBCore and QBCore.Functions and QBCore.Functions.Notify then
QBCore.Functions.Notify('Markers: ' .. tostring(showMarkers), 'primary')
2025-08-13 16:59:56 +02:00
else
2025-08-13 17:06:31 +02:00
TriggerEvent('chatMessage', "SYSTEM", "normal", "Markers: " .. tostring(showMarkers))
2025-08-13 16:59:56 +02:00
end
end, false)
2025-08-13 17:06:31 +02:00
-- Marker Loop
2025-08-13 16:59:56 +02:00
CreateThread(function()
while true do
local sleep = 1000
2025-08-13 17:06:31 +02:00
if showMarkers then
2025-08-13 16:59:56 +02:00
local playerCoords = GetEntityCoords(PlayerPedId())
for i, location in ipairs(trainLocations) do
local distance = #(playerCoords - vector3(location.x, location.y, location.z))
2025-08-13 17:06:31 +02:00
if distance < 200.0 then
2025-08-13 16:59:56 +02:00
sleep = 0
2025-08-13 17:06:31 +02:00
-- 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)
2025-08-13 16:59:56 +02:00
2025-08-13 17:06:31 +02:00
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
2025-08-13 16:59:56 +02:00
2025-08-13 17:06:31 +02:00
if IsControlJustPressed(0, 38) then -- E
print("^3[TRAIN-TRIGGER]^7 E gedrückt bei " .. location.name)
2025-08-13 16:59:56 +02:00
TriggerServerEvent('train:requestStart')
end
end
end
end
end
Wait(sleep)
end
end)
2025-08-13 17:06:31 +02:00
print("^2[TRAIN-TRIGGER]^7 Client Script geladen! Commands: /togglemarkers")