add hud to joiners...

sync alittle better, so double damage isn't done.
This commit is contained in:
2026-01-11 04:02:21 +01:00
parent 92ac3df666
commit a43a17ed10
5 changed files with 56 additions and 13 deletions

View File

@@ -422,6 +422,16 @@ func _die():
if killer_player and is_instance_valid(killer_player) and killer_player.character_stats:
killer_player.character_stats.kills += 1
print(name, " kill credited to ", killer_player.name, " (total kills: ", killer_player.character_stats.kills, ")")
# Sync kill update to client if this player belongs to a client
# Only sync if we're on the server and the killer is a client's player
if multiplayer.has_multiplayer_peer() and is_multiplayer_authority():
var killer_peer_id = killer_player.get_multiplayer_authority()
# Only sync if killer is a client (not server's own player)
if killer_peer_id != 0 and killer_peer_id != multiplayer.get_unique_id() and killer_player.has_method("_sync_stats_update"):
# Server is updating a client's player stats - sync to the client
var coins = killer_player.character_stats.coin if "coin" in killer_player.character_stats else 0
killer_player._sync_stats_update.rpc_id(killer_peer_id, killer_player.character_stats.kills, coins)
# Spawn loot immediately (before death animation)
_spawn_loot()