Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 729449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:47:53+00:00 2026-05-14T06:47:53+00:00

For a game server, I want to record details when a player makes a

  • 0

For a game server, I want to record details when a player makes a kill, store this, and then at intervals update to a sql database.

The part i’m interested in right now is the best method of storing the kill information.
What i’d like to pass to the sql server on update would be {PlayerName, Kills, Deaths}, where the kills and deaths are a sum for the period between updates.

So i’m assuming i’d build a list along the lines of
{bob, 1, 0}
{frank, 0, 1}
{tom, 1, 0}
{frank, 0, 1}
then on update, consolidate the list to {frank, 14, 3}etc

Can someone offer some advice please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:47:53+00:00Added an answer on May 14, 2026 at 6:47 am

    My version

    class Player
    {
        private readonly string _Name;
        private int _KillsCount = 0;
        private int _DeathsCount = 0;
        private bool _IsChanged = false;
    
        public string Name
        {
            get { return _Name; }
        }
    
        public int DeathsCount
        {
            get { return _DeathsCount; }
            private set
            {
                if (_DeathsCount != value)
                {
                    _DeathsCount = value;
                    _IsChanged = true;  
                }   
            }
        }
    
        public int KillsCount
        {
            get { return _KillsCount; }
            private set
            {
                if (_KillsCount != value)
                {
                    _KillsCount = value;
                    _IsChanged = true;  
                }
            }
        }
    
        public bool IsChanged
        {
            get { return _IsChanged; }
            set { _IsChanged = value; }
        }
    
        public Player(string name)
        {
            _Name = name;
        }
    
        public void Kill(Player killer)
        {
            DeathsCount++;
            killer.KillsCount++;
        }
    }
    
    class Example
    {
        private readonly Collection<Player> _Players = new Collection<Player>();
        private bool _IsUpdateEnabled;
        private int _UpdateTimeout = 1000;
    
        public void Start()
        {
            var frank = new Player("Frank");
            var tom = new Player("Tom");
            _Players.Add(frank);
            _Players.Add(tom);
    
            _Players.Add(new Player("Bob"));
    
            _IsUpdateEnabled = true;
            new Thread(UpdateThreadMethod).Start();
    
            // Frank kills Tom ):
            tom.Kill(frank);
    
            // Where is Bob?
            var bob = _Players.First(p => p.Name == "Bob");
    
            // Bob kills Frank
            frank.Kill(bob);
    
            // Tom kills Bob
            bob.Kill(tom);
        }
    
        private void UpdateThreadMethod()
        {
            while (_IsUpdateEnabled)
            {
                foreach (var player in _Players)
                {
                    if (player.IsChanged)
                    {
                        // update database
                        // e.g. "update stats set kills = @kills, deaths = @deaths where name = @name"
                        // where
                        // @kills is players.KillsCount
                        // @deaths is player.DeathsCount
                        // @name is player.Name
                        player.IsChanged = false;
                    }
                }
    
                Thread.Sleep(_UpdateTimeout);
            }   
        }
    
        public void ShowResults()
        {
            foreach (var player in _Players)
            {
                Console.WriteLine("Player name: {0}, kills: {1}, deaths: {2}", player.Name, player.KillsCount, player.DeathsCount);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm designing a game server and I have never done anything like this before.
i want to have both an Apache and a Game Server to be reachable
I have a game server (WoW). I want my players to download my custom
I made a launcher for my game server. (World of Warcraft) I want to
I have a game server which is made in Java. I want to make
I am working on a client/server game (C#.NET) where I do not want to
I want my game to be entirely server side. Meaning, the client only sends
I want to make a server written in C++ to power my game. I
For my Java game server I send the Action ID of the packet which
I'm building a game server in Python and I just wanted to get some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.