Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Well, here is a rough idea of what I want. I need a better way to prime this. This is looping through a collection of player objects obviously I don�t want to add the first player objects together just ones that match names throughout the file and then remove the other unneeded player objects from the collection. It�s creating the totals for certain items off of one of our servers. I want redundant player names to be totaled and stored in the first instance of that player object. The rest of the redundant players eliminated. Think I wrote to much code today... :confused: Been writing code since about midnight last night. Sleepy now :confused:Hate when you get going on something sometimes and you can't pull yourself away from it....aaarghhh

 

 

  Private Sub TotalPlayers()
       Try
           Dim i As Integer
           Dim x As Integer
           With PlayersList
               For i = 1 To .GetPLAYERCount
                   For x = 1 To .GetPLAYERCount Step 1
                       Dim kills, deaths, teamkills, suicides, objective As Integer
                       If .GetPLAYERObject(i).Name = .GetPLAYERObject(x).Name Then
                           kills = Convert.ToInt32(.GetPLAYERObject(i).Kills) + Convert.ToInt32(.GetPLAYERObject(x).Kills)
                           .GetPLAYERObject(i).Kills = Convert.ToString(kills)
                           deaths = Convert.ToInt32(.GetPLAYERObject(i).Deaths) + Convert.ToInt32(.GetPLAYERObject(x).Deaths)
                           .GetPLAYERObject(i).Deaths = Convert.ToString(deaths)
                           teamkills = Convert.ToInt32(.GetPLAYERObject(i).TeamKills) + Convert.ToInt32(.GetPLAYERObject(x).TeamKills)
                           .GetPLAYERObject(i).TeamKills = Convert.ToString(teamkills)
                           suicides = Convert.ToInt32(.GetPLAYERObject(i).Suicides) + Convert.ToInt32(.GetPLAYERObject(x).Suicides)
                           .GetPLAYERObject(i).Suicides = Convert.ToString(suicides)
                           objective = Convert.ToInt32(.GetPLAYERObject(i).Objective) + Convert.ToInt32(.GetPLAYERObject(x).Objective)
                           .GetPLAYERObject(i).Objective = Convert.ToString(objective)
                           .RemovePlayer(x)

                       End If

                   Next

               Next
           End With
           WritePlayers()
       Catch ex As Exception
           Dim mm As New System.Net.Mail.SmtpClient
           mm.Host = "smtp.charter.net"
           mm.Send("itower@chartermi.net", "itower@chartermi.net", "error", ex.ToString)
       End Try

   End Sub

Yeah I have it now!Disregard this post.I hate when I post and figure it out right away.

I'm silly im removing objects...I think I have it.But any suggestions I'll take right now...lol.

Edited by AFterlife

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...