1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-20 20:25:30 +02:00
parent d83dc01004
commit 29c786ff04
3 changed files with 31 additions and 206 deletions

View file

@ -33,7 +33,7 @@ noTools = "Du hast nicht das benötigte Werkzeug!",
cooldown = "Du musst warten, bevor du den nächsten Überfall starten kannst!", cooldown = "Du musst warten, bevor du den nächsten Überfall starten kannst!",
globalCooldown = "Diese Art von Überfall ist derzeit gesperrt!", globalCooldown = "Diese Art von Überfall ist derzeit gesperrt!",
notEnoughPolice = "Es sind nicht genug Polizisten in der Stadt!", notEnoughPolice = "Es sind nicht genug Polizisten in der Stadt!",
policeMessage = "Container Einbruch in der Nähe von %s", -- Diese Zeile fehlt policeMessage = "Einbruch in der Nähe von %s", -- Diese Zeile fehlt
alreadyRobbed = "Dieser Container wurde bereits kürzlich ausgeraubt!", alreadyRobbed = "Dieser Container wurde bereits kürzlich ausgeraubt!",
} }

View file

@ -1,125 +1,37 @@
Open = false -- Replace the existing onResourceStart event handler with this:
cam = nil AddEventHandler('onResourceStart', function(resourceName)
Peds = {} if (GetCurrentResourceName() == resourceName) then
local Actions = {} -- Use next() instead of # to check if the table has any entries
if next(Config.peds) ~= nil then
print("Resource started, spawning peds")
SpawnPeds()
else
print("Resource started, but Config.peds is empty")
end
end
end)
-- Also update the framework loading event handler:
if Config.FrameworkLoadinEvent ~= '' then if Config.FrameworkLoadinEvent ~= '' then
RegisterNetEvent(Config.FrameworkLoadinEvent, function() RegisterNetEvent(Config.FrameworkLoadinEvent, function()
SpawnPeds() print("Framework loading event triggered")
if next(Config.peds) ~= nil then
print("Spawning peds after framework loaded")
SpawnPeds()
else
print("Framework loaded, but Config.peds is empty")
end
end) end)
end end
AddEventHandler('onResourceStart', function(resourceName) -- Add a debug command to help troubleshoot
if (GetCurrentResourceName() == resourceName) then RegisterCommand('debugpeds', function()
if #Config.peds ~= 0 then SpawnPeds() end print("Debug peds command triggered")
local count = 0
for k, v in pairs(Config.peds) do
count = count + 1
print("Found ped: " .. k)
end end
end) print("Total peds in config: " .. count)
SpawnPeds()
---@param ped number # The id of the ped end, false)
---@param data table # The data for the interaction
---@param zoom number # Camera zoom level (optional, default: 40.0)
---@param x number # Camera X position (optional, default: 0)
---@param y number # Camera Y position (optional, default: 1.5)
---@param z number # Camera Z position (optional, default: 0.3)
---@param rotX number # Camera X rotation (optional, default: 0.0)
---@param rotY number # Camera Y rotation (optional, default: 0.0)
---@param rotZ number # Camera Z rotation (optional, default: GetEntityHeading(ped) + 180)
OpenDialog = function(ped, data, zoom, x, y, z, rotX, rotY, rotZ)
-- Setting defaults
local newX, newY, newZ = x or 0, y or 1.5, z or 0.3
local newRotX, newRotY, newRotZ = rotX or 0.0, rotY or 0.0, rotZ or GetEntityHeading(ped) + 180
local fov = zoom or 40.0
local coords = GetOffsetFromEntityInWorldCoords(ped, newX, newY, newZ)
-- camera setup
cam = CreateCam('DEFAULT_SCRIPTED_CAMERA', true)
SetEntityLocallyInvisible(PlayerPedId())
SetCamActive(cam, true)
RenderScriptCams(true, true, 500, true, true)
SetCamCoord(cam, coords.x, coords.y, coords.z + 0.2)
SetCamRot(cam, newRotX, newRotY, newRotZ, 5)
SetCamFov(cam, fov)
local Dialog = data
local function extractEvents(tbl)
for k, v in pairs(tbl) do
if type(v) == "table" then
extractEvents(v)
elseif k == "event" and type(v) == "string" then
Actions[v] = v
end
end
end
extractEvents(Dialog)
SetNuiFocus(true, true)
SendNUIMessage({
type = 'New',
data = data
})
Open = true
SetInvisible()
end
SetDialog = function(data)
SendNUIMessage({
type = 'Set',
data = data
})
end
CloseDialog = function()
Open = false
SendNUIMessage({
type = 'Close',
})
end
SpawnPedByID = function(id, data)
Peds[id] = data
SpawnPed(id, data)
end
DeletePedByID = function(id)
if Peds[id].ped then
exports['qb-target']:RemoveTargetEntity(Peds[id].ped)
DeleteEntity(Peds[id].ped)
Peds[id] = nil
end
end
RegisterNuiCallback("click", function(data, cb)
if data.data then
SendNUIMessage({
type = 'Continue',
data = data.data
})
cb(false)
return
end
if data.close then
SetNuiFocus(false, false)
if cam and DoesCamExist(cam) then
RenderScriptCams(false, true, 500, true, true)
DestroyCam(cam, true)
end
CloseDialog()
end
if Actions[data.event] then
if data.server then
TriggerServerEvent(Actions[data.event], data)
else
TriggerEvent(Actions[data.event], data)
end
end
end)
exports('OpenDialog', OpenDialog)
exports('SetDialog', SetDialog)
exports('CloseDialog', CloseDialog)
exports('SpawnPed', SpawnPedByID)

View file

@ -1,87 +0,0 @@
RegisterCommand('deleteped', function()
DeletePedByID('test')
end, false)
RegisterCommand('spawnped', function()
SpawnPedByID('test', {
label = 'Talk to stranger',
icon = 'fa-solid fa-comment',
model = "csb_avon",
coords = vector3(165.48, 6612.81, 31.9),
heading = 170,
data = {
firstname = 'John',
lastname = 'Doe',
text = 'Hey bud, how ya doin.',
buttons = {
{
text = 'Im ok, how are you?',
data = {
text = 'Im cool rn, see you around!',
buttons = {
{
text = 'Se ya',
close = true
},
}
}
},
{
text = 'No sorry, im gonna leave',
close = true
},
}
}
})
end, false)
RegisterNetEvent('con:mechanic', function(ped)
rep = 1
data = {
firstname = 'John',
lastname = 'Doe',
text = 'Hey bud, what can i do for you',
type = 'Mechanic',
rep = rep,
buttons = {
{ text = "I wanna clock in", data = {
text = 'Alright',
buttons = {
{ text = 'Clock in/out', event = 'con:clockin', close = true },
{ text = 'Whatever, changed my mind', event = 'con:back' },
}
}},
{ text = "I'm gonna leave", close = true },
}
}
OpenDialog(ped, data)
end)
RegisterNetEvent('con:back', function()
data = {
firstname = 'John',
lastname = 'Doe',
text = 'Hey bud, what can i do for you',
type = 'Mechanic',
rep = '2',
buttons = {
{ text = "I wanna clock in", data = {
text = 'Alright',
buttons = {
{ text = 'Clock in/out', event = 'con:clockin', close = true },
{ text = 'Whatever changed my mind', event = 'con:back' },
}
}
},
{ text = "I'm gonna leave", close = true },
}
}
SetDialog(data)
end)
RegisterNetEvent('con:clockin', function()
print('123')
TriggerEvent('QBCore:Notify', "clocked in", 'success')
end)