Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Semi-Advanced Warn System Difficulty 2/5 (C&P)
#1
Okay, so the other day, I got bored and tried to write one from scratch, needless to say it was a success. I'm pretty confident in it, as it seemed to work quite well, though I'd appreciate it if someone with a bit more knowledge than I, took a look at it to see if there was any potential bugs or problems. The good thing about this is, that it keeps track of the players warn level. So all you need to do is /warn the player. First warning sends a text warn. Second a kick, and the third a good ol' ban. Enjoy, and remember I need some constructive criticism.

Server Side

[spoiler]Find
Code:
CQuit

Under it add:

Code:
CSetWarn

Then Find:

Code:
Sub SetPlayerPK(ByVal Index As Long, ByVal PK As Long)
    Player(Index).Char(TempPlayer(Index).CharNum).PK = PK
End Sub

Under it add:
Code:
Function GetPlayerWarn(ByVal Index As Long) As Long
    GetPlayerWarn = Player(Index).Char(TempPlayer(Index).CharNum).Warn
End Function

Sub SetPlayerWarn(ByVal Index As Long, ByVal Warn As Long)
    Player(Index).Char(TempPlayer(Index).CharNum).Warn = Warn
End Sub

Then Find
Code:
Case Else
            GoTo ErrorHandle ' packet not found

Above it add:

Code:
Case CSetWarn
            HandleSetWarn Index, Parse

Then Find:
Code:
' :::::::::::::::::::::::
' :: Set sprite packet ::
' :::::::::::::::::::::::
Private Sub HandleSetSprite(ByVal Index As Long, ByRef Parse() As String)
Dim N As Long

    ' Prevent hacking
    If GetPlayerAccess(Index) < ADMIN_MAPPER Then
        Call HackingAttempt(Index, "Admin Cloning")
        Exit Sub
    End If
    
    ' The sprite
    N = CLng(Parse(1))
    
    Call SetPlayerSprite(Index, N)
    Call SendPlayerData(Index)
    Exit Sub
End Sub

And under that add:
Code:
' :::::::::::::::::::::::
' :: Set Warn packet ::
' :::::::::::::::::::::::
Sub HandleSetWarn(ByVal Index As Long, _
                  ByRef Parse() As String)
    Dim N As Long

    N = FindPlayer(Parse(1))
    
    If N > 0 Then
        If N  Index Then

            Select Case GetPlayerWarn(N) + 1

                Case 1
                    Call SetPlayerWarn(N, 1)
                    'Call SetPlayerWarn(n, GetPlayerWarn(n) + 1)
                    Call PlayerMsg(Index, "You have received your first warning, for breaking the rules. Your second will result in a kick!", Blue)

                Case 2
                    Call SetPlayerWarn(N, GetPlayerWarn(N) + 1)
                    Call AlertMsg(Index, "You have received your second warning. Your third will result in a ban")

                Case 3
                    Call SetPlayerWarn(N, GetPlayerWarn(N) + 1)
                    Call BanIndex(N, Index)
            End Select

        Else
            Call PlayerMsg(Index, "You can't warn yourself!", BrightRed)
        End If

    Else
        Call PlayerMsg(Index, "Player Isn't Online!", BrightRed)
    End If

End Sub

Then in the player rec find:
Code:
PK As Byte

Under that add:
Code:
Warn As Byte
[/spoiler]

Client Side

[spoiler]Find:
Code:
Case "/setaccess"
                    If GetPlayerAccess(MyIndex) < ADMIN_CREATOR Then
                        AddText "You need to be a high enough staff member to do this!", AlertColor
                        GoTo Continue
                    End If
                    
                    If UBound(Command) < 2 Then
                        AddText "Usage: /setaccess (name) (access)", AlertColor
                        GoTo Continue
                    End If
                    
                    If IsNumeric(Command(1)) = True Or IsNumeric(Command(2)) = False Then
                        AddText "Usage: /setaccess (name) (access)", AlertColor
                        GoTo Continue
                    End If
                    
                    SendSetAccess Command(1), CLng(Command(2))

Under it add:
Code:
Case "/warn"
                    If GetPlayerAccess(MyIndex) < ADMIN_CREATOR Then
                        AddText "You need to be a high enough staff member to do this!", AlertColor
                        GoTo Continue
                    End If
                    
                    If UBound(Command) < 1 Then
                        AddText "Usage: /warn (name)", AlertColor
                        GoTo Continue
                    End If
                    
                    If IsNumeric(Command(1)) = True Then
                        AddText "Usage: /warn (name)", AlertColor
                        GoTo Continue
                    End If
                    
                    SendSetWarn Command(1)

Then find:
Code:
Sub SendSetAccess(ByVal Name As String, ByVal Access As Byte)
Dim Packet As String

    Packet = CSetAccess & SEP_CHAR & Name & SEP_CHAR & Access & END_CHAR
    Call SendData(Packet)
End Sub

Under it add:
Code:
Sub SendSetWarn(ByVal Name As String)
Dim Packet As String

    Packet = CSetWarn & SEP_CHAR & Name & END_CHAR
    Call SendData(Packet)
End Sub

Then find:
Code:
CQuit

Under it add:
Code:
CSetWarn
[/spoiler]
That should be it. Give it a whirl, and drop me some feed back.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)