forked from Simnation/Main
Update client.lua
This commit is contained in:
parent
9d4f625a84
commit
0686dcdea2
1 changed files with 51 additions and 35 deletions
|
@ -147,6 +147,7 @@ RegisterNetEvent('tdm:playerHit', function()
|
||||||
isHit = true
|
isHit = true
|
||||||
local ped = PlayerPedId()
|
local ped = PlayerPedId()
|
||||||
|
|
||||||
|
-- Animation für kurze Zeit
|
||||||
RequestAnimDict("random@mugging3")
|
RequestAnimDict("random@mugging3")
|
||||||
while not HasAnimDictLoaded("random@mugging3") do
|
while not HasAnimDictLoaded("random@mugging3") do
|
||||||
Wait(1)
|
Wait(1)
|
||||||
|
@ -156,20 +157,54 @@ RegisterNetEvent('tdm:playerHit', function()
|
||||||
|
|
||||||
lib.notify({
|
lib.notify({
|
||||||
title = 'TeamDeathmatch',
|
title = 'TeamDeathmatch',
|
||||||
description = 'Du wurdest getroffen! Gehe zurück zu deiner Team Zone!',
|
description = 'Du wurdest getroffen! Respawn in 3 Sekunden...',
|
||||||
type = 'error'
|
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)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('tdm:updateScore', function(team1Score, team2Score, gameStats)
|
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(
|
local displayText = string.format(
|
||||||
'[Team 1: %d] VS [Team 2: %d] | Deine Treffer: %d | Tode: %d',
|
'[Team 1: %d] VS [Team 2: %d] | Deine Treffer: %d | Tode: %d',
|
||||||
team1Score,
|
team1Score,
|
||||||
team2Score,
|
team2Score,
|
||||||
playerStats.hits,
|
myHits,
|
||||||
playerStats.deaths
|
myDeaths
|
||||||
)
|
)
|
||||||
|
|
||||||
lib.showTextUI(displayText, {
|
lib.showTextUI(displayText, {
|
||||||
|
@ -189,10 +224,16 @@ RegisterNetEvent('tdm:hitRegistered', function()
|
||||||
})
|
})
|
||||||
|
|
||||||
showHitMarker()
|
showHitMarker()
|
||||||
|
|
||||||
|
-- Score sofort aktualisieren
|
||||||
|
TriggerServerEvent('tdm:requestScoreUpdate', currentGameId)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('tdm:deathRegistered', function()
|
RegisterNetEvent('tdm:deathRegistered', function()
|
||||||
playerStats.deaths = playerStats.deaths + 1
|
playerStats.deaths = playerStats.deaths + 1
|
||||||
|
|
||||||
|
-- Score sofort aktualisieren
|
||||||
|
TriggerServerEvent('tdm:requestScoreUpdate', currentGameId)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('tdm:gameEnded', function(winnerTeam, team1Score, team2Score)
|
RegisterNetEvent('tdm:gameEnded', function(winnerTeam, team1Score, team2Score)
|
||||||
|
@ -480,36 +521,6 @@ function openJoinGameMenu(fieldId)
|
||||||
lib.showContext('tdm_join_menu_' .. fieldId)
|
lib.showContext('tdm_join_menu_' .. fieldId)
|
||||||
end
|
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
|
-- Zone Marker Renderer
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
while true do
|
while true do
|
||||||
|
@ -546,7 +557,7 @@ CreateThread(function()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Damage Handler
|
-- Damage Handler (erweitert)
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
while true do
|
while true do
|
||||||
Wait(100)
|
Wait(100)
|
||||||
|
@ -566,6 +577,10 @@ CreateThread(function()
|
||||||
end
|
end
|
||||||
|
|
||||||
ClearEntityLastDamageEntity(ped)
|
ClearEntityLastDamageEntity(ped)
|
||||||
|
|
||||||
|
-- Lokale Stats sofort updaten
|
||||||
|
playerStats.deaths = playerStats.deaths + 1
|
||||||
|
|
||||||
TriggerEvent('tdm:playerHit')
|
TriggerEvent('tdm:playerHit')
|
||||||
TriggerServerEvent('tdm:playerWasHit', currentGameId, currentTeam, damagerPlayer)
|
TriggerServerEvent('tdm:playerWasHit', currentGameId, currentTeam, damagerPlayer)
|
||||||
end
|
end
|
||||||
|
@ -663,6 +678,7 @@ RegisterNetEvent('tdm:openFieldMenu', function(data)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
-- Chat Command zum Spiel verlassen
|
-- Chat Command zum Spiel verlassen
|
||||||
RegisterCommand('leavetdm', function()
|
RegisterCommand('leavetdm', function()
|
||||||
if inTDM then
|
if inTDM then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue