-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean Team Score After Player Disconnecting in FFA #589
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code seems a little too complicated for what this can do.
If we already have a table of the score of each player, wouldnt it also make sense to then save that score so if they re-join they get to keep their score.
Also a better way to do this, is to just save the score of a player in a table < string, int >
. We dont need the struct anyway as the team is unique to each player.
I would suggest to just add a callback for player disconnect like this:
void function OnPlayerDisconnected(entity player)
{
ffaPlayerScoreTable[player.GetUID()] <- GameRules_GetTeamScore( player.GetTeam() )
// this prevents a new player to get someone who's left's score
AddTeamScore( player.GetTeam(), -GameRules_GetTeamScore( player.GetTeam() ))
}
That way we can also eliminate the change to the OnPlayerKilled
callback.
further we could adjust the client connect to:
void function OnClientConnected( entity player )
{
string uid = player.GetUID()
FFAScoreStruct emptyStruct
if ( uid in file.ffaPlayerScoreTable )
{
AddTeamScore( player.GetTeam(), SaveScore[player.GetPlayerName()] )
player.AddToPlayerGameStat( PGS_ASSAULT_SCORE, ffaPlayerScoreTable[player.GetUID()] )
}
}
Then we have a system where the score is saved for a re joining player AND no one else can get the score
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, I have never experienced any issue with the Client disconnect callback but it really doesnt matter now. imo this is good to merge
Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ffa.nut
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, I didn't test the changes though
sounds suspiciously like "LGTM!" |
It isn't, the code has been improved from "why would you do that" to "this is a valid and efficient way of doing this" |
Tested in private server with @uniboi. After I rejoined the game all my kills and point were gone 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #400
Player's team score will be cleaned after they disconnecting, so later joiners won't have trouble start from 0 score