1
0
Fork 0
forked from Simnation/Main

Update client.lua

This commit is contained in:
Nordi98 2025-07-26 21:25:55 +02:00
parent 9d4f625a84
commit 0686dcdea2

View file

@ -147,6 +147,7 @@ RegisterNetEvent('tdm:playerHit', function()
isHit = true
local ped = PlayerPedId()
-- Animation für kurze Zeit
RequestAnimDict("random@mugging3")
while not HasAnimDictLoaded("random@mugging3") do
Wait(1)
@ -156,20 +157,54 @@ RegisterNetEvent('tdm:playerHit', function()
lib.notify({
title = 'TeamDeathmatch',
description = 'Du wurdest getroffen! Gehe zurück zu deiner Team Zone!',
description = 'Du wurdest getroffen! Respawn in 3 Sekunden...',
type = 'error'
})
highlightTeamZone(currentTeam)
-- Nach 3 Sekunden automatisch respawnen
CreateThread(function()
Wait(3000)
if inTDM and isHit and currentTeam and currentField then
-- Respawn zum Team Spawn
local fieldConfig = Config.gameFields[currentField]
local spawnPoints = fieldConfig.teamSpawns[currentTeam]
local randomSpawn = spawnPoints[math.random(#spawnPoints)]
-- Animation stoppen
ClearPedTasks(ped)
-- Teleport zum Spawn
SetEntityCoords(ped, randomSpawn.x, randomSpawn.y, randomSpawn.z)
-- Spieler ist wieder aktiv
isHit = false
-- Zone Blip Flash stoppen
if teamZoneBlips[currentTeam] and DoesBlipExist(teamZoneBlips[currentTeam]) then
SetBlipFlashes(teamZoneBlips[currentTeam], false)
end
lib.notify({
title = 'TeamDeathmatch',
description = 'Du bist wieder im Spiel!',
type = 'success'
})
end
end)
end)
RegisterNetEvent('tdm:updateScore', function(team1Score, team2Score, gameStats)
-- Verwende gameStats falls verfügbar, sonst lokale Stats
local myHits = gameStats and gameStats.hits or playerStats.hits
local myDeaths = gameStats and gameStats.deaths or playerStats.deaths
local displayText = string.format(
'[Team 1: %d] VS [Team 2: %d] | Deine Treffer: %d | Tode: %d',
team1Score,
team2Score,
playerStats.hits,
playerStats.deaths
myHits,
myDeaths
)
lib.showTextUI(displayText, {
@ -189,10 +224,16 @@ RegisterNetEvent('tdm:hitRegistered', function()
})
showHitMarker()
-- Score sofort aktualisieren
TriggerServerEvent('tdm:requestScoreUpdate', currentGameId)
end)
RegisterNetEvent('tdm:deathRegistered', function()
playerStats.deaths = playerStats.deaths + 1
-- Score sofort aktualisieren
TriggerServerEvent('tdm:requestScoreUpdate', currentGameId)
end)
RegisterNetEvent('tdm:gameEnded', function(winnerTeam, team1Score, team2Score)
@ -480,36 +521,6 @@ function openJoinGameMenu(fieldId)
lib.showContext('tdm_join_menu_' .. fieldId)
end
-- Zone Checker Thread
CreateThread(function()
while true do
Wait(500)
if inTDM and isHit and currentTeam and currentField then
local ped = PlayerPedId()
local playerPos = GetEntityCoords(ped)
local zone = Config.gameFields[currentField].teamZones[currentTeam]
local distance = #(playerPos - zone.center)
if distance <= zone.radius then
isHit = false
ClearPedTasks(ped)
if teamZoneBlips[currentTeam] and DoesBlipExist(teamZoneBlips[currentTeam]) then
SetBlipFlashes(teamZoneBlips[currentTeam], false)
end
lib.notify({
title = 'TeamDeathmatch',
description = 'Du bist wieder im Spiel!',
type = 'success'
})
end
end
end
end)
-- Zone Marker Renderer
CreateThread(function()
while true do
@ -546,7 +557,7 @@ CreateThread(function()
end
end)
-- Damage Handler
-- Damage Handler (erweitert)
CreateThread(function()
while true do
Wait(100)
@ -566,6 +577,10 @@ CreateThread(function()
end
ClearEntityLastDamageEntity(ped)
-- Lokale Stats sofort updaten
playerStats.deaths = playerStats.deaths + 1
TriggerEvent('tdm:playerHit')
TriggerServerEvent('tdm:playerWasHit', currentGameId, currentTeam, damagerPlayer)
end
@ -663,6 +678,7 @@ RegisterNetEvent('tdm:openFieldMenu', function(data)
end
end)
-- Chat Command zum Spiel verlassen
RegisterCommand('leavetdm', function()
if inTDM then