Update main.lua
This commit is contained in:
		
							parent
							
								
									5d000c1205
								
							
						
					
					
						commit
						a0a4c022cd
					
				
					 1 changed files with 25 additions and 15 deletions
				
			
		| 
						 | 
				
			
			@ -5,6 +5,9 @@ npcHandle = nil
 | 
			
		|||
isNPCSpawned = false
 | 
			
		||||
CurrentZone = nil
 | 
			
		||||
 | 
			
		||||
CurrentActionData = {}
 | 
			
		||||
hasAlreadyEnteredMarker = false
 | 
			
		||||
 | 
			
		||||
Citizen.CreateThread(function()
 | 
			
		||||
    while Player == nil do
 | 
			
		||||
        Player = exports['qb-core']:GetPlayerData()
 | 
			
		||||
| 
						 | 
				
			
			@ -72,28 +75,35 @@ end
 | 
			
		|||
-- Hauptthread zum Überprüfen der Spieler-Position
 | 
			
		||||
CreateThread(function()
 | 
			
		||||
    while true do
 | 
			
		||||
        local playerPed = PlayerPedId()
 | 
			
		||||
        local playerCoords = GetEntityCoords(playerPed)
 | 
			
		||||
        wait(0)
 | 
			
		||||
        local ped = PlayerPedId()
 | 
			
		||||
        local coords = GetEntityCoords(ped)
 | 
			
		||||
 | 
			
		||||
        local isInMarker = false
 | 
			
		||||
 | 
			
		||||
        for k, v in pairs(Config.Zonen) do
 | 
			
		||||
            local dist = #(playerCoords - vector3(v.NPC.spawn.x, v.NPC.spawn.y, v.NPC.spawn.z))
 | 
			
		||||
            local spawnDistance = v.NPC.distance
 | 
			
		||||
        
 | 
			
		||||
            if dist < spawnDistance and not isNPCSpawned then
 | 
			
		||||
                isNPCSpawned = true
 | 
			
		||||
                print(isNPCSpawned)
 | 
			
		||||
            
 | 
			
		||||
            if dist <= spawnDistance then
 | 
			
		||||
                isInMarker = true
 | 
			
		||||
 | 
			
		||||
                CurrentZone = v
 | 
			
		||||
                SpawnGuardNPC(v.NPC)
 | 
			
		||||
                AddTargetOptions()
 | 
			
		||||
            elseif dist > spawnDistance and isNPCSpawned then
 | 
			
		||||
                isNPCSpawned = false
 | 
			
		||||
                CurrentZone = nil
 | 
			
		||||
                exports['qb-target']:RemoveTargetEntity(npcHandle)
 | 
			
		||||
                RemoveGuardNPC()
 | 
			
		||||
            end
 | 
			
		||||
        end
 | 
			
		||||
        
 | 
			
		||||
        Wait(0) -- Überprüfung jede Sekunde
 | 
			
		||||
 | 
			
		||||
        if isInMarker and not hasAlreadyEnteredMarker then
 | 
			
		||||
            hasAlreadyEnteredMarker = true
 | 
			
		||||
            SpawnGuardNPC(CurrentZone.NPC)
 | 
			
		||||
            AddTargetOptions()
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        if not isInMarker and hasAlreadyEnteredMarker then
 | 
			
		||||
            hasAlreadyEnteredMarker = false
 | 
			
		||||
            CurrentZone = nil
 | 
			
		||||
            exports['qb-target']:RemoveTargetEntity(npcHandle)
 | 
			
		||||
            RemoveGuardNPC()
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue