| Mirage Source http://miragesource.net/forums/ |
|
| Server Players List http://miragesource.net/forums/viewtopic.php?f=210&t=1172 |
Page 1 of 2 |
| Author: | Xlithan [ Tue Jan 16, 2007 2:27 pm ] |
| Post subject: | Server Players List |
I know this was around somewhere before. Basically just a listbox with the characters that are currently playing. |
|
| Author: | lucidar [ Wed Jan 17, 2007 11:46 pm ] |
| Post subject: | |
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 |
|
| Author: | Matt [ Thu Jan 18, 2007 12:23 am ] |
| Post subject: | |
I have this somewhere. I can post it if you want? |
|
| Author: | Xlithan [ Thu Jan 18, 2007 2:08 pm ] |
| Post subject: | |
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 |
|
| Author: | Elmrok [ Fri Jan 19, 2007 1:02 am ] |
| Post subject: | |
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. |
|
| Author: | Xlithan [ Fri Jan 19, 2007 3:28 am ] |
| Post subject: | |
That seems like a really really really bad method to me |
|
| Author: | James [ Fri Jan 19, 2007 3:28 am ] |
| Post subject: | |
Well, when a player logs on have them cleared or added to the list. It'd be something like Code: frmServer.lstOnline.Clear
For I = 1 to MAX_PLAYERS If IsPlaying(I) Then frmServer.lstOnline.AddItem I & ": " & Player(I).Name End If Next I Add something like that to the sub where the player logs in server side, or rather begins playing. |
|
| Author: | Elmrok [ Fri Jan 19, 2007 3:31 am ] |
| Post subject: | |
GameBoy wrote: That seems like a really really really bad method to me
How is that bad? |
|
| Author: | Xlithan [ Fri Jan 19, 2007 3:32 am ] |
| Post subject: | |
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!!! |
|
| Author: | lucidar [ Sat Jan 20, 2007 7:50 am ] |
| Post subject: | |
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 or for $2 I'll do it to your exact specs. 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? |
|
| Author: | Xlithan [ Sat Jan 20, 2007 2:03 pm ] |
| Post subject: | |
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. |
|
| Author: | grimsk8ter11 [ Sat Jan 20, 2007 2:27 pm ] |
| Post subject: | |
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 |
|
| Author: | Xlithan [ Sun Jan 21, 2007 4:30 am ] |
| Post subject: | |
I never said anybody was lazy... lol, what's that all about? |
|
| Author: | grimsk8ter11 [ Sun Jan 21, 2007 4:51 am ] |
| Post subject: | |
I misread your post about you being lazy then. But the bad method thing is still being scrutinized |
|
| Author: | Xlithan [ Sun Jan 21, 2007 6:03 pm ] |
| Post subject: | |
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... |
|
| Author: | grimsk8ter11 [ Sun Jan 21, 2007 6:48 pm ] |
| Post subject: | |
Ya, but for what he wanted, it works perfectly for. For what you want, the code i posted is ideal. |
|
| Author: | Xlithan [ Sun Jan 21, 2007 11:38 pm ] |
| Post subject: | |
Written a new one, works fine now. Thanks to everybody for the help. |
|
| Page 1 of 2 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|