forked from Simnation/Main
ed
This commit is contained in:
parent
761af3afdf
commit
bc2a683f6f
2 changed files with 121 additions and 167 deletions
|
@ -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