Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Server Players List
#1
I know this was around somewhere before. Basically just a listbox with the characters that are currently playing.
Reply
#2
Code:
Function TotalOnlinePlayers() As Long
Dim i As Long

    TotalOnlinePlayers = 0
    
    frmServer.lstOnline.Clear
        
    For i = 1 To MAX_PLAYERS
        If IsPlaying(i) Then
            TotalOnlinePlayers = TotalOnlinePlayers + 1
            frmServer.lstOnline.AddItem Player(i).Char(Player(i).CharNum).Name
        End If
    Next i
End Function

Theres a TotalOnlinePlayers() function in modGameLogic in the server.


That may not be exactly what yours looks like... close enough and the concept is the exact same.
Just make a listbox named lstOnline within frmServer
Reply
#3
I have this somewhere. I can post it if you want?
Reply
#4
I got one working (See the link below) but I just want the list to show characters and nothing else, so i'll try lucidar's and see what that looks like.

http://www.mrpge.chronicalgames.com/ima ... r_main.jpg

Edit:
lucidar's doesn't work
Reply
#5
The code i use for mine is

Code:
Private Sub Form_Load()
frmMapChat.txtMap.Text = 1
frmMapChat.lblPlayers.Caption = GetTotalMapPlayers(1)

        frmMapChat.lstPlayers.Clear
    For i = 1 To GetTotalMapPlayers(txtMap.Text)
        frmMapChat.lstPlayers.AddItem i & ": " & GetPlayerName(i)
    Next i
End Sub

The way it lists the player is diffrent but it does the same thing. Just it gets the player on a certain map as so i can see who i am chatting with.
Reply
#6
That seems like a really really really bad method to me Tongue
Reply
#7
GameBoy Wrote:That seems like a really really really bad method to me Tongue
How is that bad?
Reply
#8
I think I'm just lazy. I'd probably have written it myself if I'd have bothered to sit down and do it. I hate doing the boring bits though!!! :twisted:
Reply
#9
I just took the exact code from my server. (mine also has char,account,map and ip)

I think I may of changed when totalonlineplayers() was called though..
whatever, all you gotta do is throw a for loop with a call of >listbox.additem Player(i).Char(Player(i).CharNum).Name <
I just put it in the function that I happenned to use whenever a character logged in/out.

Just sit down for 5 damn minutes Tongue
or for $2 I'll do it to your exact specs. :lol:


Elmrok: I thought player index's didn't depend on the map#.
Wouldn't you have to go something like:
Code:
Private Sub Form_Load()
frmMapChat.txtMap.Text = 1
frmMapChat.lblPlayers.Caption = GetTotalMapPlayers(1)

        frmMapChat.lstPlayers.Clear
    For i = 1 To max_players
        if GetPlayerMap(i) = txtMap.Text
            frmMapChat.lstPlayers.AddItem i & ": " & GetPlayerName(i)
        end if
    Next i
End Sub
or something simular (didn't check syntax)

Wouldn't it be easier to call that with a command button, so you don't have to reload the form to 'refresh' the list too?
Reply
#10
Would that only check the online players once when the form loads? What about checking when a player connects and leaves? Unless that's what you want to do. I'll work with a new method, I don't need all the data, just the character name, so I'll get rid of my listview box.
Reply
#11
Zel, Elmrok's isn't lazy, he is showing whos on a map, not showing everyone online. Maybe that suites his purpose, and if you just didn't see that, read the whole code first.

JoinGame:
Code:
frmServer.lstOnline.AddItem GetPlayerName(index)

LeaveGame: this should be the only time you have to refresh the list, but you could probably manage without it to
Code:
frmServer.lstOnline.Clear
for i = 1 to MAX_PLAYERS
     if IsPlaying(i) then
            frmServer.lstOnline.AddItem GetPlayerName(i)
     end if
next i
Reply
#12
I never said anybody was lazy... lol, what's that all about?
Reply
#13
I misread your post about you being lazy then. But the bad method thing is still being scrutinized Tongue
Reply
#14
It checks the list for all online players when the form loads. That wouldn't really work on frmServer would it, since it only loads once...
Reply
#15
Ya, but for what he wanted, it works perfectly for. For what you want, the code i posted is ideal.
Reply
#16
Written a new one, works fine now.

Thanks to everybody for the help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)