From 8c0ef3516f23a296c71cc4d61ec2b09746db9ca2 Mon Sep 17 00:00:00 2001 From: Interesting#4036 <52731127+Interesting-exe@users.noreply.github.com> Date: Wed, 22 Jun 2022 15:01:52 +0300 Subject: Gun Game: Fix potentially transferring score from leaving player to new joining player (#290) * fixed a bug fixed a bug in which a player that just joined the server might have someone who's left the server's score (this fix should be applied to all ffa gamemodes) * made it more efficient * Use neutral pronoun in comment Co-authored-by: lnteresting-png <52731127+lnteresting-png@users.noreply.github.com> Co-authored-by: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> merging this for now as it's been open for ages while working, will add ffa support myself soon --- Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut index b27892f7..8f34541b 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut @@ -13,6 +13,7 @@ void function GamemodeGG_Init() AddCallback_OnPlayerRespawned( OnPlayerRespawned ) AddCallback_OnPlayerKilled( OnPlayerKilled ) + AddCallback_OnClientDisconnected( OnPlayerDisconnected ) AddCallback_GameStateEnter( eGameState.WinnerDetermined, OnWinnerDetermined ) @@ -27,6 +28,12 @@ void function GamemodeGG_Init() catch ( ex ) {} } +void function OnPlayerDisconnected(entity player) +{ + // resetting a player's score when they leave prevents a new player to join the leaver's team and having the previous player's points + AddTeamScore( player.GetTeam(), -GameRules_GetTeamScore( player.GetTeam() ) ) +} + void function OnPlayerRespawned( entity player ) { UpdateLoadout( player ) -- cgit v1.2.3