Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Staff Online Feature
#1
So, once again, I was bored. To test myself, I made this. How it works, is when you type /staff, it displays all the people that have > 0 access, that are online. Once more, this is just a rip and edit, of an already existing feature (Whos Online). Yeah, I know. I'm a n00b. When this is done, just type /staff, and it displays what staff members are online! GASP. Amazing rite? :roll:
[spoiler]Server Side:
Find:
Code:
Sub SendWhosOnline(ByVal Index As Long)
Dim s As String
Dim n As Long, i As Long

    For i = 1 To MAX_PLAYERS
        If IsPlaying(i) Then
            If i  Index Then
                s = s & GetPlayerName(i) & ", "
                n = n + 1
            End If
        End If
    Next i
            
    If n = 0 Then
        s = "There are no other players online."
    Else
        s = Mid$(s, 1, Len(s) - 2)
        s = "There are " & n & " other players online: " & s & "."
    End If
        
    Call PlayerMsg(Index, s, WhoColor)
End Sub

Now above that add:
Code:
Sub SendWhosStaff(ByVal Index As Long)
Dim s As String
Dim n As Long, i As Long

    For i = 1 To MAX_PLAYERS
        If IsPlaying(i) Then
           If GetPlayerAccess(i) > 0 Then
                s = s & GetPlayerName(i) & ", "
                n = n + 1
            End If
        End If
    Next i
            
    If n = 0 Then
        s = "There are no staff members online."
    Else
        s = Mid$(s, 1, Len(s) - 2)
        s = "There is " & n & " staff members online: " & s & "."
    End If
        
    Call PlayerMsg(Index, s, WhoColor)
End Sub

Now find:
Code:
CWhosOnline

Above it add:
Code:
CWhosStaff

Now find:
Code:
' :::::::::::::::::::::::
        ' :: Who online packet ::
        ' :::::::::::::::::::::::
        Case CWhosOnline
            Call SendWhosOnline(Index)
            Exit Sub

Above it add:
Code:
' :::::::::::::::::::::::
        ' :: Whos staff packet ::
        ' :::::::::::::::::::::::
        Case CWhosStaff
            Call SendWhosStaff(Index)
            Exit Sub

Client Side:

Find:
Code:
Sub SendWhosOnline()
Dim Packet As String

    Packet = CWhosOnline & END_CHAR
    Call SendData(Packet)
End Sub

Above it add:
Code:
Sub SendWhosStaff()
Dim Packet As String

    Packet = CWhosStaff & END_CHAR
    Call SendData(Packet)
End Sub

Now Find:
Code:
CWhosOnline

Above it add:
Code:
CWhosStaff

Now find:
Code:
' Whos Online
                Case "/who"
                    SendWhosOnline

Above it add:
Code:
' Staff Online
                Case "/staff"
                    SendWhosStaff

And thats it. I hope you enjoyed it.... Yeah.[/spoiler]
Reply
#2
You should really try and do something from scratch.

It's alright to copy stuff, but then look through it and understand exactly how it works and repeat the steps to yourself. Like:

"Alright so this code loops through every player, checks their access, if it's greater than 0 blah blah blah"

Why do you think Elysium and rip offs of MS were so shitty? Because all they did was copy shit and didn't try to improve it and so on.
Reply
#3
GIAKEN Wrote:You should really try and do something from scratch.

It's alright to copy stuff, but then look through it and understand exactly how it works and repeat the steps to yourself. Like:

"Alright so this code loops through every player, checks their access, if it's greater than 0 blah blah blah"

Why do you think Elysium and rip offs of MS were so shitty? Because all they did was copy shit and didn't try to improve it and so on.

Yeah, I know. But I'm horrible at coding from scratch, and I never really think of anything to code, until I see something like the whos online, and then, I think "hey, this would be a good basis for this". I'm new at this, and I don't really seem to be getting better at coding from scratch. I do understand how most of this works, I'm just not very creative.
Reply
#4
It doesn't take creativity really...only when thinking of things to do.

Your creativity came into play with the command, then you decide how it should be done. Example: Player types /staff, send packet to server, server processes and does the loop through the accesses, put results in playermsg, done.
Reply
#5
This won't work in the latest version of MS4.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)