forked from Simnation/Main
ed
This commit is contained in:
parent
761af3afdf
commit
bc2a683f6f
2 changed files with 121 additions and 167 deletions
|
@ -24,13 +24,11 @@ end
|
|||
|
||||
-- Events
|
||||
RegisterNetEvent('tdm:updateGamesList', function(games)
|
||||
debugPrint("Spiele-Liste aktualisiert - Anzahl: " .. (games and #games or "0"))
|
||||
activeGames = games
|
||||
debugPrint("Spieleliste aktualisiert: " .. (games and table.count(games) or 0) .. " aktive Spiele")
|
||||
end)
|
||||
|
||||
RegisterNetEvent('tdm:joinGame', function(gameId, team, fieldId)
|
||||
debugPrint("Join Game Event empfangen: GameID=" .. gameId .. ", Team=" .. team .. ", FieldID=" .. fieldId)
|
||||
|
||||
currentGameId = gameId
|
||||
currentTeam = team
|
||||
currentField = fieldId
|
||||
|
@ -43,21 +41,11 @@ RegisterNetEvent('tdm:joinGame', function(gameId, team, fieldId)
|
|||
playerStats.gamesPlayed = playerStats.gamesPlayed + 1
|
||||
|
||||
local fieldConfig = Config.gameFields[fieldId]
|
||||
if not fieldConfig then
|
||||
debugPrint("FEHLER: Feldkonfiguration nicht gefunden für ID " .. fieldId)
|
||||
return
|
||||
end
|
||||
|
||||
-- Teleport zu Team Spawn
|
||||
local spawnPoints = fieldConfig.teamSpawns[team]
|
||||
if not spawnPoints or #spawnPoints == 0 then
|
||||
debugPrint("FEHLER: Keine Spawn-Punkte für Team " .. team)
|
||||
return
|
||||
end
|
||||
|
||||
local randomSpawn = spawnPoints[math.random(#spawnPoints)]
|
||||
|
||||
debugPrint("Teleportiere zu: " .. randomSpawn.x .. ", " .. randomSpawn.y .. ", " .. randomSpawn.z)
|
||||
SetEntityCoords(PlayerPedId(), randomSpawn.x, randomSpawn.y, randomSpawn.z)
|
||||
|
||||
-- Team Maske setzen
|
||||
|
@ -76,8 +64,6 @@ RegisterNetEvent('tdm:joinGame', function(gameId, team, fieldId)
|
|||
end)
|
||||
|
||||
RegisterNetEvent('tdm:leaveGame', function()
|
||||
debugPrint("Leave Game Event empfangen")
|
||||
|
||||
inTDM = false
|
||||
local previousField = currentField
|
||||
currentTeam = nil
|
||||
|
@ -91,18 +77,14 @@ RegisterNetEvent('tdm:leaveGame', function()
|
|||
-- Versuche zuerst die vorherige Feld-Lobby
|
||||
if previousField and Config.gameFields[previousField] and Config.gameFields[previousField].lobby then
|
||||
lobbyPos = Config.gameFields[previousField].lobby.pos
|
||||
debugPrint("Verwende vorherige Feld-Lobby für Teleport")
|
||||
-- Dann die aktuelle Lobby-Feld
|
||||
elseif currentLobbyField and Config.gameFields[currentLobbyField] and Config.gameFields[currentLobbyField].lobby then
|
||||
lobbyPos = Config.gameFields[currentLobbyField].lobby.pos
|
||||
debugPrint("Verwende aktuelle Lobby-Feld für Teleport")
|
||||
-- Fallback zur ersten verfügbaren Lobby
|
||||
else
|
||||
debugPrint("Suche nach verfügbarer Lobby für Teleport")
|
||||
for fieldId, fieldData in pairs(Config.gameFields) do
|
||||
if fieldData.lobby and fieldData.lobby.pos then
|
||||
lobbyPos = fieldData.lobby.pos
|
||||
debugPrint("Fallback-Lobby gefunden: " .. fieldId)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
@ -110,17 +92,15 @@ RegisterNetEvent('tdm:leaveGame', function()
|
|||
|
||||
-- Teleport zur Lobby (mit Fallback-Position)
|
||||
if lobbyPos then
|
||||
debugPrint("Teleportiere zur Lobby: " .. lobbyPos.x .. ", " .. lobbyPos.y .. ", " .. lobbyPos.z)
|
||||
SetEntityCoords(PlayerPedId(), lobbyPos.x, lobbyPos.y, lobbyPos.z)
|
||||
else
|
||||
-- Notfall-Fallback Position
|
||||
debugPrint("WARNUNG: Keine Lobby gefunden, verwende Fallback-Position")
|
||||
-- Notfall-Fallback Position (anpassen an deine Map)
|
||||
SetEntityCoords(PlayerPedId(), -1042.4, -2745.8, 21.4)
|
||||
debugPrint("WARNUNG: Keine Lobby gefunden, Fallback-Position verwendet!")
|
||||
end
|
||||
|
||||
-- Maske entfernen
|
||||
SetPedComponentVariation(PlayerPedId(), 1, 0, 0, 0)
|
||||
debugPrint("Maske entfernt")
|
||||
|
||||
-- Zone Blips entfernen
|
||||
removeTeamZoneBlips()
|
||||
|
@ -133,12 +113,10 @@ RegisterNetEvent('tdm:leaveGame', function()
|
|||
type = 'error'
|
||||
})
|
||||
|
||||
debugPrint("Spiel verlassen - Cleanup abgeschlossen")
|
||||
debugPrint("Spiel verlassen")
|
||||
end)
|
||||
|
||||
RegisterNetEvent('tdm:joinRequest', function(gameId, playerName, playerId)
|
||||
debugPrint("Join-Anfrage erhalten von: " .. playerName .. " (ID: " .. playerId .. ") für Spiel " .. gameId)
|
||||
|
||||
local alert = lib.alertDialog({
|
||||
header = 'Join Anfrage',
|
||||
content = playerName .. ' möchte deinem Spiel beitreten.\n\nErlauben?',
|
||||
|
@ -151,24 +129,20 @@ RegisterNetEvent('tdm:joinRequest', function(gameId, playerName, playerId)
|
|||
})
|
||||
|
||||
if alert == 'confirm' then
|
||||
debugPrint("Join-Anfrage von " .. playerName .. " akzeptiert")
|
||||
TriggerServerEvent('tdm:approveJoinRequest', gameId, playerId, true)
|
||||
else
|
||||
debugPrint("Join-Anfrage von " .. playerName .. " abgelehnt")
|
||||
TriggerServerEvent('tdm:approveJoinRequest', gameId, playerId, false)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('tdm:joinRequestResult', function(approved, gameName)
|
||||
if approved then
|
||||
debugPrint("Join-Anfrage für Spiel '" .. gameName .. "' wurde akzeptiert")
|
||||
lib.notify({
|
||||
title = 'TeamDeathmatch',
|
||||
description = 'Deine Anfrage wurde angenommen!',
|
||||
type = 'success'
|
||||
})
|
||||
else
|
||||
debugPrint("Join-Anfrage für Spiel '" .. gameName .. "' wurde abgelehnt")
|
||||
lib.notify({
|
||||
title = 'TeamDeathmatch',
|
||||
description = 'Deine Anfrage für "' .. gameName .. '" wurde abgelehnt!',
|
||||
|
@ -255,6 +229,7 @@ RegisterNetEvent('tdm:playerHit', function()
|
|||
end)
|
||||
|
||||
RegisterNetEvent('tdm:updateScore', function(team1Score, team2Score, gameStats)
|
||||
-- Debug-Ausgabe
|
||||
debugPrint("Score Update empfangen: Team1=" .. team1Score .. ", Team2=" .. team2Score)
|
||||
if gameStats then
|
||||
debugPrint("GameStats: Hits=" .. (gameStats.hits or "nil") .. ", Deaths=" .. (gameStats.deaths or "nil"))
|
||||
|
@ -279,7 +254,6 @@ RegisterNetEvent('tdm:updateScore', function(team1Score, team2Score, gameStats)
|
|||
end)
|
||||
|
||||
RegisterNetEvent('tdm:hitRegistered', function()
|
||||
debugPrint("Treffer registriert! Aktualisiere lokale Stats")
|
||||
playerStats.hits = playerStats.hits + 1
|
||||
|
||||
lib.notify({
|
||||
|
@ -296,7 +270,6 @@ RegisterNetEvent('tdm:hitRegistered', function()
|
|||
|
||||
-- Score sofort aktualisieren
|
||||
if currentGameId then
|
||||
debugPrint("Fordere Score-Update an für Spiel " .. currentGameId)
|
||||
TriggerServerEvent('tdm:requestScoreUpdate', currentGameId)
|
||||
end
|
||||
|
||||
|
@ -304,12 +277,10 @@ RegisterNetEvent('tdm:hitRegistered', function()
|
|||
end)
|
||||
|
||||
RegisterNetEvent('tdm:deathRegistered', function()
|
||||
debugPrint("Tod registriert! Aktualisiere lokale Stats")
|
||||
playerStats.deaths = playerStats.deaths + 1
|
||||
|
||||
-- Score sofort aktualisieren
|
||||
if currentGameId then
|
||||
debugPrint("Fordere Score-Update an für Spiel " .. currentGameId)
|
||||
TriggerServerEvent('tdm:requestScoreUpdate', currentGameId)
|
||||
end
|
||||
|
||||
|
@ -317,7 +288,6 @@ RegisterNetEvent('tdm:deathRegistered', function()
|
|||
end)
|
||||
|
||||
RegisterNetEvent('tdm:gameEnded', function(winnerTeam, team1Score, team2Score)
|
||||
debugPrint("Spiel beendet! Gewinner: " .. (winnerTeam or "Unentschieden"))
|
||||
lib.hideTextUI()
|
||||
|
||||
local wonGame = (currentTeam == 'team1' and winnerTeam == 'team1') or (currentTeam == 'team2' and winnerTeam == 'team2')
|
||||
|
@ -348,8 +318,9 @@ RegisterNetEvent('tdm:gameEnded', function(winnerTeam, team1Score, team2Score)
|
|||
})
|
||||
|
||||
Wait(5000)
|
||||
debugPrint("Verlasse Spiel nach Ende")
|
||||
TriggerServerEvent('tdm:leaveGame')
|
||||
|
||||
debugPrint("Spiel beendet! Gewinner: " .. (winnerTeam or "Unentschieden"))
|
||||
end)
|
||||
|
||||
-- Funktionen
|
||||
|
@ -425,14 +396,12 @@ function showHitMarker()
|
|||
SetTextCentre(true)
|
||||
DrawText(0.5, 0.45)
|
||||
end
|
||||
debugPrint("Hit-Marker ausgeblendet")
|
||||
end)
|
||||
end
|
||||
|
||||
function openMainMenu(fieldId)
|
||||
-- Sicherheitscheck
|
||||
if not fieldId or not Config.gameFields[fieldId] then
|
||||
debugPrint("FEHLER: Ungültiges Spielfeld für Menü: " .. tostring(fieldId))
|
||||
lib.notify({
|
||||
title = 'Fehler',
|
||||
description = 'Ungültiges Spielfeld!',
|
||||
|
@ -441,7 +410,6 @@ function openMainMenu(fieldId)
|
|||
return
|
||||
end
|
||||
|
||||
debugPrint("Öffne Hauptmenü für Feld: " .. fieldId)
|
||||
currentLobbyField = fieldId
|
||||
TriggerServerEvent('tdm:requestGamesList')
|
||||
|
||||
|
@ -455,7 +423,6 @@ function openMainMenu(fieldId)
|
|||
description = 'Erstelle ein neues Spiel für ' .. fieldName,
|
||||
icon = 'plus',
|
||||
onSelect = function()
|
||||
debugPrint("Öffne Menü zum Erstellen eines neuen Spiels")
|
||||
openCreateGameMenu(fieldId)
|
||||
end
|
||||
},
|
||||
|
@ -464,7 +431,6 @@ function openMainMenu(fieldId)
|
|||
description = 'Trete einem laufenden Spiel bei',
|
||||
icon = 'users',
|
||||
onSelect = function()
|
||||
debugPrint("Öffne Menü zum Beitreten eines Spiels")
|
||||
openJoinGameMenu(fieldId)
|
||||
end
|
||||
}
|
||||
|
@ -477,7 +443,6 @@ function openMainMenu(fieldId)
|
|||
icon = 'door-open',
|
||||
iconColor = 'red',
|
||||
onSelect = function()
|
||||
debugPrint("Verlasse aktuelles Spiel über Menü")
|
||||
TriggerServerEvent('tdm:leaveGame')
|
||||
end
|
||||
})
|
||||
|
@ -494,7 +459,6 @@ end
|
|||
|
||||
function openCreateGameMenu(fieldId)
|
||||
if not fieldId or not Config.gameFields[fieldId] then
|
||||
debugPrint("FEHLER: Ungültiges Spielfeld für Erstellungsmenü: " .. tostring(fieldId))
|
||||
lib.notify({
|
||||
title = 'Fehler',
|
||||
description = 'Ungültiges Spielfeld!',
|
||||
|
@ -503,7 +467,6 @@ function openCreateGameMenu(fieldId)
|
|||
return
|
||||
end
|
||||
|
||||
debugPrint("Öffne Spiel-Erstellungsmenü für Feld: " .. fieldId)
|
||||
local fieldData = Config.gameFields[fieldId]
|
||||
|
||||
local input = lib.inputDialog('Neues Spiel erstellen - ' .. fieldData.name, {
|
||||
|
@ -532,24 +495,19 @@ function openCreateGameMenu(fieldId)
|
|||
}
|
||||
})
|
||||
|
||||
if not input then
|
||||
debugPrint("Spiel-Erstellung abgebrochen")
|
||||
return
|
||||
end
|
||||
if not input then return end
|
||||
|
||||
local gameName = input[1]
|
||||
local gameType = input[2]
|
||||
local password = input[3] and input[3] ~= '' and input[3] or nil
|
||||
|
||||
if gameName and gameType then
|
||||
debugPrint("Erstelle Spiel: " .. gameName .. " (Typ: " .. gameType .. ", Passwort: " .. (password and "Ja" or "Nein") .. ")")
|
||||
TriggerServerEvent('tdm:createGame', gameName, fieldId, gameType, password)
|
||||
end
|
||||
end
|
||||
|
||||
function openJoinGameMenu(fieldId)
|
||||
if not fieldId or not Config.gameFields[fieldId] then
|
||||
debugPrint("FEHLER: Ungültiges Spielfeld für Join-Menü: " .. tostring(fieldId))
|
||||
lib.notify({
|
||||
title = 'Fehler',
|
||||
description = 'Ungültiges Spielfeld!',
|
||||
|
@ -558,7 +516,6 @@ function openJoinGameMenu(fieldId)
|
|||
return
|
||||
end
|
||||
|
||||
debugPrint("Öffne Spiel-Beitrittsmenü für Feld: " .. fieldId)
|
||||
TriggerServerEvent('tdm:requestGamesList')
|
||||
|
||||
Wait(200)
|
||||
|
@ -567,10 +524,8 @@ function openJoinGameMenu(fieldId)
|
|||
local fieldName = Config.gameFields[fieldId].name
|
||||
|
||||
-- Nur Spiele für dieses Feld anzeigen
|
||||
local gamesCount = 0
|
||||
for gameId, gameData in pairs(activeGames) do
|
||||
if gameData.fieldId == fieldId then
|
||||
gamesCount = gamesCount + 1
|
||||
local playerCount = #gameData.team1 + #gameData.team2
|
||||
local maxPlayers = Config.gameFields[gameData.fieldId].maxPlayers
|
||||
|
||||
|
@ -589,9 +544,7 @@ function openJoinGameMenu(fieldId)
|
|||
gameType = gameData.gameType
|
||||
},
|
||||
onSelect = function(args)
|
||||
debugPrint("Versuche Spiel beizutreten: " .. gameId)
|
||||
if args.hasPassword then
|
||||
debugPrint("Spiel erfordert Passwort")
|
||||
local input = lib.inputDialog('Passwort eingeben', {
|
||||
{
|
||||
type = 'input',
|
||||
|
@ -603,13 +556,9 @@ function openJoinGameMenu(fieldId)
|
|||
})
|
||||
|
||||
if input and input[1] then
|
||||
debugPrint("Passwort eingegeben, sende Beitrittsanfrage")
|
||||
TriggerServerEvent('tdm:requestJoinGame', args.gameId, input[1])
|
||||
else
|
||||
debugPrint("Passwort-Eingabe abgebrochen")
|
||||
end
|
||||
else
|
||||
debugPrint("Kein Passwort erforderlich, sende Beitrittsanfrage")
|
||||
TriggerServerEvent('tdm:requestJoinGame', args.gameId)
|
||||
end
|
||||
end
|
||||
|
@ -617,8 +566,6 @@ function openJoinGameMenu(fieldId)
|
|||
end
|
||||
end
|
||||
|
||||
debugPrint("Gefundene Spiele für Feld " .. fieldId .. ": " .. gamesCount)
|
||||
|
||||
if #options == 0 then
|
||||
table.insert(options, {
|
||||
title = 'Keine Spiele verfügbar',
|
||||
|
@ -674,12 +621,13 @@ CreateThread(function()
|
|||
end
|
||||
end)
|
||||
|
||||
-- Verbesserte Damage Handler
|
||||
-- Verbesserte Damage Handler für korrekte Treffer-Registrierung
|
||||
CreateThread(function()
|
||||
while true do
|
||||
if inTDM and not isHit then
|
||||
local ped = PlayerPedId()
|
||||
|
||||
-- Prüfe, ob der Spieler Schaden genommen hat
|
||||
if HasEntityBeenDamagedByAnyPed(ped) then
|
||||
debugPrint("Schaden erkannt - Identifiziere Angreifer")
|
||||
|
||||
|
@ -707,6 +655,7 @@ CreateThread(function()
|
|||
|
||||
debugPrint("Getroffen von: " .. (damagerPlayer or "Unbekannt"))
|
||||
|
||||
-- Treffer-Events auslösen
|
||||
TriggerEvent('tdm:playerHit')
|
||||
TriggerServerEvent('tdm:playerWasHit', currentGameId, currentTeam, damagerPlayer)
|
||||
|
||||
|
@ -720,6 +669,42 @@ CreateThread(function()
|
|||
end
|
||||
end)
|
||||
|
||||
-- Zusätzlicher Event-Handler für zuverlässigere Treffer-Erkennung
|
||||
AddEventHandler('gameEventTriggered', function(name, args)
|
||||
if name == "CEventNetworkEntityDamage" then
|
||||
local victimId = args[1]
|
||||
local attackerId = args[2]
|
||||
local isDead = args[4] == 1
|
||||
local weaponHash = args[5]
|
||||
|
||||
if inTDM and not isHit and victimId == PlayerPedId() then
|
||||
local attackerServerId = nil
|
||||
|
||||
-- Versuche den Angreifer zu identifizieren
|
||||
for _, player in ipairs(GetActivePlayers()) do
|
||||
if GetPlayerPed(player) == attackerId then
|
||||
attackerServerId = GetPlayerServerId(player)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
debugPrint("Schaden-Event erkannt: Angreifer=" .. (attackerServerId or "NPC/Unbekannt") .. ", Waffe=" .. weaponHash)
|
||||
|
||||
if attackerServerId then
|
||||
-- Lokale Stats sofort updaten
|
||||
playerStats.deaths = playerStats.deaths + 1
|
||||
|
||||
-- Verhindern, dass der Spieler stirbt
|
||||
SetEntityHealth(PlayerPedId(), GetEntityMaxHealth(PlayerPedId()))
|
||||
|
||||
-- Treffer-Events auslösen
|
||||
TriggerEvent('tdm:playerHit')
|
||||
TriggerServerEvent('tdm:playerWasHit', currentGameId, currentTeam, attackerServerId)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Death Handler
|
||||
CreateThread(function()
|
||||
while true do
|
||||
|
@ -754,8 +739,6 @@ CreateThread(function()
|
|||
local lobbyPos = fieldData.lobby.pos
|
||||
local npcData = fieldData.lobby.npc
|
||||
|
||||
debugPrint("Erstelle Blip und NPC für Feld " .. fieldId)
|
||||
|
||||
-- Blip erstellen
|
||||
local blip = AddBlipForCoord(lobbyPos.x, lobbyPos.y, lobbyPos.z)
|
||||
SetBlipSprite(blip, 432)
|
||||
|
@ -769,17 +752,12 @@ CreateThread(function()
|
|||
|
||||
tdmBlips[fieldId] = blip
|
||||
|
||||
-- NPC erstellen
|
||||
RequestModel(GetHashKey(npcData.model))
|
||||
while not HasModel
|
||||
-- NPC erstellen
|
||||
RequestModel(GetHashKey(npcData.model))
|
||||
while not HasModelLoaded(GetHashKey(npcData.model)) do
|
||||
Wait(1)
|
||||
end
|
||||
|
||||
debugPrint("NPC-Modell geladen für " .. fieldId)
|
||||
|
||||
local npc = CreatePed(4, GetHashKey(npcData.model), npcData.coords.x, npcData.coords.y, npcData.coords.z, npcData.coords.w, false, true)
|
||||
SetEntityInvincible(npc, true)
|
||||
FreezeEntityPosition(npc, true)
|
||||
|
@ -811,10 +789,8 @@ end)
|
|||
-- Event für Feld-spezifisches Menü
|
||||
RegisterNetEvent('tdm:openFieldMenu', function(data)
|
||||
if data and data.fieldId then
|
||||
debugPrint("Öffne Feldmenü für: " .. data.fieldId)
|
||||
openMainMenu(data.fieldId)
|
||||
else
|
||||
debugPrint("FEHLER: Keine Feld-ID übertragen!")
|
||||
lib.notify({
|
||||
title = 'Fehler',
|
||||
description = 'Keine Feld-ID übertragen!',
|
||||
|
@ -826,7 +802,6 @@ end)
|
|||
-- Chat Command zum Spiel verlassen
|
||||
RegisterCommand('leavetdm', function()
|
||||
if inTDM then
|
||||
debugPrint("Verlasse Spiel über Command")
|
||||
TriggerServerEvent('tdm:leaveGame')
|
||||
lib.notify({
|
||||
title = 'TeamDeathmatch',
|
||||
|
@ -834,7 +809,6 @@ RegisterCommand('leavetdm', function()
|
|||
type = 'info'
|
||||
})
|
||||
else
|
||||
debugPrint("Command 'leavetdm' ausgeführt, aber nicht in einem Spiel")
|
||||
lib.notify({
|
||||
title = 'TeamDeathmatch',
|
||||
description = 'Du bist in keinem Spiel!',
|
||||
|
@ -863,18 +837,11 @@ RegisterCommand('debugtdm', function()
|
|||
local hasLobby = fieldData.lobby and fieldData.lobby.pos and "✅" or "❌"
|
||||
debugPrint("- " .. fieldId .. ": " .. fieldData.name .. " " .. hasLobby)
|
||||
end
|
||||
|
||||
lib.notify({
|
||||
title = 'Debug Info',
|
||||
description = 'Debug-Informationen wurden in die Konsole geschrieben',
|
||||
type = 'info'
|
||||
})
|
||||
end, false)
|
||||
|
||||
-- Debug Commands für Masken
|
||||
RegisterCommand('testmask', function(source, args)
|
||||
if not args[1] or not args[2] then
|
||||
debugPrint("Ungültige Parameter für testmask")
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
description = 'Verwendung: /testmask [team1/team2] [male/female]',
|
||||
|
@ -886,22 +853,18 @@ RegisterCommand('testmask', function(source, args)
|
|||
local team = args[1]
|
||||
local gender = args[2]
|
||||
|
||||
debugPrint("Teste Maske: Team=" .. team .. ", Gender=" .. gender)
|
||||
|
||||
if Config.teamMasks[team] and Config.teamMasks[team][gender] then
|
||||
local maskData = Config.teamMasks[team][gender]
|
||||
local ped = PlayerPedId()
|
||||
|
||||
SetPedComponentVariation(ped, maskData.component, maskData.drawable, maskData.texture, 0)
|
||||
|
||||
debugPrint("Maske gesetzt: " .. team .. " (" .. gender .. ")")
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
description = 'Maske gesetzt: ' .. team .. ' (' .. gender .. ')',
|
||||
type = 'success'
|
||||
})
|
||||
else
|
||||
debugPrint("Maske nicht gefunden: " .. team .. " (" .. gender .. ")")
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
description = 'Maske nicht gefunden!',
|
||||
|
@ -913,7 +876,6 @@ end, false)
|
|||
-- Command zum Entfernen der Maske
|
||||
RegisterCommand('removemask', function()
|
||||
SetPedComponentVariation(PlayerPedId(), 1, 0, 0, 0)
|
||||
debugPrint("Maske entfernt")
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
description = 'Maske entfernt!',
|
||||
|
@ -924,7 +886,6 @@ end, false)
|
|||
-- Debug-Funktion für Respawn
|
||||
RegisterCommand('forcetdmrespawn', function()
|
||||
if inTDM and currentTeam and currentField then
|
||||
debugPrint("Manueller Respawn ausgelöst")
|
||||
local ped = PlayerPedId()
|
||||
local fieldConfig = Config.gameFields[currentField]
|
||||
local spawnPoints = fieldConfig.teamSpawns[currentTeam]
|
||||
|
@ -942,14 +903,12 @@ RegisterCommand('forcetdmrespawn', function()
|
|||
Wait(100)
|
||||
DoScreenFadeIn(500)
|
||||
|
||||
debugPrint("Manueller Respawn abgeschlossen")
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
description = 'Manueller Respawn durchgeführt!',
|
||||
type = 'success'
|
||||
})
|
||||
else
|
||||
debugPrint("Manueller Respawn fehlgeschlagen - nicht in einem TDM-Spiel")
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
description = 'Du bist nicht in einem TDM-Spiel!',
|
||||
|
@ -975,7 +934,6 @@ RegisterCommand('showstats', function()
|
|||
type = 'info'
|
||||
})
|
||||
else
|
||||
debugPrint("Stats-Anzeige fehlgeschlagen - nicht in einem TDM-Spiel")
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
description = 'Du bist nicht in einem TDM-Spiel!',
|
||||
|
@ -987,7 +945,6 @@ end, false)
|
|||
-- Debug-Funktion für manuellen Hit
|
||||
RegisterCommand('testhit', function()
|
||||
if inTDM then
|
||||
debugPrint("Test-Hit ausgelöst")
|
||||
TriggerEvent('tdm:playerHit')
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
|
@ -995,7 +952,6 @@ RegisterCommand('testhit', function()
|
|||
type = 'info'
|
||||
})
|
||||
else
|
||||
debugPrint("Test-Hit fehlgeschlagen - nicht in einem TDM-Spiel")
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
description = 'Du bist nicht in einem TDM-Spiel!',
|
||||
|
@ -1007,7 +963,6 @@ end, false)
|
|||
-- Debug-Funktion für manuellen Treffer
|
||||
RegisterCommand('testtreff', function()
|
||||
if inTDM then
|
||||
debugPrint("Test-Treffer ausgelöst")
|
||||
TriggerEvent('tdm:hitRegistered')
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
|
@ -1015,7 +970,6 @@ RegisterCommand('testtreff', function()
|
|||
type = 'info'
|
||||
})
|
||||
else
|
||||
debugPrint("Test-Treffer fehlgeschlagen - nicht in einem TDM-Spiel")
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
description = 'Du bist nicht in einem TDM-Spiel!',
|
||||
|
@ -1024,19 +978,21 @@ RegisterCommand('testtreff', function()
|
|||
end
|
||||
end, false)
|
||||
|
||||
-- Neuer Debug-Command für Damage-Test
|
||||
RegisterCommand('tdmtesthit', function()
|
||||
if inTDM then
|
||||
debugPrint("Sende Test-Hit zum Server")
|
||||
-- Debug-Befehl zum Testen der Treffer-Registrierung
|
||||
RegisterCommand('testtreffer', function()
|
||||
if inTDM and currentGameId and currentTeam then
|
||||
debugPrint("Teste Treffer-Registrierung")
|
||||
|
||||
-- Simuliere einen Treffer gegen sich selbst
|
||||
local targetTeam = currentTeam == 'team1' and 'team2' or 'team1'
|
||||
TriggerServerEvent('tdm:playerWasHit', currentGameId, targetTeam, GetPlayerServerId(PlayerId()))
|
||||
TriggerServerEvent('tdm:playerWasHit', currentGameId, currentTeam, GetPlayerServerId(PlayerId()))
|
||||
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
description = 'Test-Hit zum Server gesendet',
|
||||
description = 'Test-Treffer gesendet!',
|
||||
type = 'info'
|
||||
})
|
||||
else
|
||||
debugPrint("Server-Hit-Test fehlgeschlagen - nicht in einem TDM-Spiel")
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
description = 'Du musst in einem TDM-Spiel sein!',
|
||||
|
@ -1045,35 +1001,32 @@ RegisterCommand('tdmtesthit', function()
|
|||
end
|
||||
end, false)
|
||||
|
||||
-- Neuer Event-Handler für Waffen-Schaden
|
||||
AddEventHandler('gameEventTriggered', function(name, args)
|
||||
if name == "CEventNetworkEntityDamage" then
|
||||
local victimId = args[1]
|
||||
local attackerId = args[2]
|
||||
local isDead = args[4] == 1
|
||||
local weaponHash = args[5]
|
||||
local isMelee = args[10] == 1
|
||||
|
||||
if inTDM and not isHit and victimId == PlayerPedId() then
|
||||
local attackerServerId = nil
|
||||
|
||||
-- Versuche den Angreifer zu identifizieren
|
||||
for _, player in ipairs(GetActivePlayers()) do
|
||||
if GetPlayerPed(player) == attackerId then
|
||||
attackerServerId = GetPlayerServerId(player)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
debugPrint("Schaden-Event erkannt: Angreifer=" .. (attackerServerId or "NPC/Unbekannt") .. ", Waffe=" .. weaponHash)
|
||||
|
||||
if attackerServerId then
|
||||
-- Lokale Stats sofort updaten
|
||||
playerStats.deaths = playerStats.deaths + 1
|
||||
|
||||
-- Debug-Befehl zum Testen des Respawns
|
||||
RegisterCommand('testrespawn', function()
|
||||
if inTDM then
|
||||
debugPrint("Teste Respawn-Funktion")
|
||||
TriggerEvent('tdm:playerHit')
|
||||
TriggerServerEvent('tdm:playerWasHit', currentGameId, currentTeam, attackerServerId)
|
||||
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
description = 'Test-Respawn ausgelöst!',
|
||||
type = 'info'
|
||||
})
|
||||
else
|
||||
lib.notify({
|
||||
title = 'Debug',
|
||||
description = 'Du musst in einem TDM-Spiel sein!',
|
||||
type = 'error'
|
||||
})
|
||||
end
|
||||
end, false)
|
||||
|
||||
-- Hilfsfunktion für table.count
|
||||
table.count = function(tbl)
|
||||
local count = 0
|
||||
for _, _ in pairs(tbl) do
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
end)
|
||||
return count
|
||||
end
|
||||
|
||||
|
|
|
@ -421,16 +421,12 @@ function updateScoreForGame(gameId)
|
|||
|
||||
debugPrint("Score Update für Spiel " .. gameId .. ": Team1=" .. game.score.team1 .. ", Team2=" .. game.score.team2)
|
||||
|
||||
for _, playerId in ipairs(game.team1) do
|
||||
local playerStats = game.playerStats[playerId] or {hits = 0, deaths = 0}
|
||||
TriggerClientEvent('tdm:updateScore', playerId, game.score.team1,
|
||||
for _, playerId in ipairs(game.team1) do
|
||||
local playerStats = game.playerStats[playerId] or {hits = 0, deaths = 0}
|
||||
TriggerClientEvent('tdm:updateScore', playerId, game.score.team1, game.score.team2, {
|
||||
hits = playerStats.hits or 0,
|
||||
deaths = playerStats.deaths or 0
|
||||
})
|
||||
debugPrint("Score-Update an Team 1 Spieler " .. playerId .. " gesendet")
|
||||
end
|
||||
|
||||
for _, playerId in ipairs(game.team2) do
|
||||
|
@ -439,14 +435,11 @@ function updateScoreForGame(gameId)
|
|||
hits = playerStats.hits or 0,
|
||||
deaths = playerStats.deaths or 0
|
||||
})
|
||||
debugPrint("Score-Update an Team 2 Spieler " .. playerId .. " gesendet")
|
||||
end
|
||||
end
|
||||
|
||||
function updateGamesListForAll()
|
||||
local players = QBCore.Functions.GetPlayers()
|
||||
debugPrint("Aktualisiere Spieleliste für alle Spieler - Aktive Spiele: " .. #activeGames)
|
||||
|
||||
for _, playerId in pairs(players) do
|
||||
TriggerClientEvent('tdm:updateGamesList', playerId, activeGames)
|
||||
end
|
||||
|
@ -468,7 +461,7 @@ AddEventHandler('onResourceStart', function(resourceName)
|
|||
if GetCurrentResourceName() == resourceName then
|
||||
activeGames = {}
|
||||
gameIdCounter = 1
|
||||
debugPrint("TeamDeathmatch System gestartet! Version 1.0.1")
|
||||
debugPrint("TeamDeathmatch System gestartet!")
|
||||
end
|
||||
end)
|
||||
|
||||
|
@ -485,7 +478,6 @@ AddEventHandler('onResourceStop', function(resourceName)
|
|||
end
|
||||
|
||||
for _, playerId in ipairs(allPlayers) do
|
||||
debugPrint("Resource wird gestoppt - Entferne Spieler " .. playerId .. " aus Spiel " .. gameId)
|
||||
TriggerClientEvent('tdm:leaveGame', playerId)
|
||||
end
|
||||
end
|
||||
|
@ -495,34 +487,7 @@ AddEventHandler('onResourceStop', function(resourceName)
|
|||
end
|
||||
end)
|
||||
|
||||
-- Neuer Debug-Command für Server
|
||||
RegisterCommand('tdmserverdebug', function(source, args)
|
||||
local src = source
|
||||
if src > 0 then -- Spieler
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if not Player or not Player.PlayerData.job or Player.PlayerData.job.name ~= 'admin' then
|
||||
TriggerClientEvent('QBCore:Notify', src, 'Du hast keine Berechtigung!', 'error')
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
debugPrint("=== TDM SERVER DEBUG ===")
|
||||
debugPrint("Aktive Spiele: " .. #activeGames)
|
||||
|
||||
for gameId, game in pairs(activeGames) do
|
||||
debugPrint("Spiel: " .. gameId .. " - " .. game.name)
|
||||
debugPrint(" Status: " .. game.status)
|
||||
debugPrint(" Feld: " .. game.fieldId)
|
||||
debugPrint(" Team 1: " .. #game.team1 .. " Spieler, Score: " .. game.score.team1)
|
||||
debugPrint(" Team 2: " .. #game.team2 .. " Spieler, Score: " .. game.score.team2)
|
||||
|
||||
if src > 0 then
|
||||
TriggerClientEvent('QBCore:Notify', src, 'Debug-Info in Server-Konsole', 'info')
|
||||
end
|
||||
end
|
||||
end, true)
|
||||
|
||||
-- Neuer Command zum Zurücksetzen aller Spiele (nur für Admins)
|
||||
-- Admin-Befehle
|
||||
RegisterCommand('tdmreset', function(source, args)
|
||||
local src = source
|
||||
if src > 0 then -- Spieler
|
||||
|
@ -557,3 +522,39 @@ RegisterCommand('tdmreset', function(source, args)
|
|||
TriggerClientEvent('QBCore:Notify', src, 'TDM System zurückgesetzt!', 'success')
|
||||
end
|
||||
end, true)
|
||||
|
||||
-- Debug-Befehl für Server-Status
|
||||
RegisterCommand('tdmstatus', function(source, args)
|
||||
local src = source
|
||||
if src > 0 then -- Spieler
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if not Player or not Player.PlayerData.job or Player.PlayerData.job.name ~= 'admin' then
|
||||
TriggerClientEvent('QBCore:Notify', src, 'Du hast keine Berechtigung!', 'error')
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
debugPrint("=== TDM STATUS ===")
|
||||
debugPrint("Aktive Spiele: " .. table.count(activeGames))
|
||||
|
||||
for gameId, game in pairs(activeGames) do
|
||||
debugPrint("Spiel: " .. gameId .. " - " .. game.name)
|
||||
debugPrint(" Status: " .. game.status)
|
||||
debugPrint(" Feld: " .. game.fieldId)
|
||||
debugPrint(" Team 1: " .. #game.team1 .. " Spieler, Score: " .. game.score.team1)
|
||||
debugPrint(" Team 2: " .. #game.team2 .. " Spieler, Score: " .. game.score.team2)
|
||||
end
|
||||
|
||||
if src > 0 then
|
||||
TriggerClientEvent('QBCore:Notify', src, 'TDM Status in Server-Konsole', 'info')
|
||||
end
|
||||
end, true)
|
||||
|
||||
-- Hilfsfunktion für table.count
|
||||
table.count = function(tbl)
|
||||
local count = 0
|
||||
for _, _ in pairs(tbl) do
|
||||
count = count + 1
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue