28-12-2006, 11:40 PM
Okay, well it occurred to me that some players have dynamic IP addresses and things that can "change" or mask their IP, so I added this bit of code below just to make each ban official. Most of you here probably already have thought of this, but for those who haven't, here you go:
Server Side:
in modTypes, add this to the PlayerRec:
in modDatabase, add the following:
Make sure it comes before the "AlertMsg" at the end of that sub or the player's ban status will not be saved, since AlertMsg disconnects the players socket.
Now in modServerTCP, add this function:
in modHandleData find:
and right after that, add this:
And that's it, done.
Explanation: Depending on where you placed the code in the BanIndex sub, the server sets a "banned" variable in the PlayerRec to true. Then, when the user tries to log in, the "IsCharBanned" function checks to see if that users "Banned" variable is set to true, if so, they are denied access to the game.
Very simple, and as far as me and my tester are concerned, effective.
If I've left anything out, let me know.
EDIT: Almost forgot, saving and loading:
in modDatabase, in the SavePlayer sub, add this:
and in the LoadPlayer sub add this:
Server Side:
in modTypes, add this to the PlayerRec:
Code:
' Banned Player
Banned As Byte
in modDatabase, add the following:
Code:
Player(BanPlayerIndex).Char(Player(BanPlayerIndex).Charnum).Banned = 1
Now in modServerTCP, add this function:
Code:
Function IsCharBanned(ByVal index As Long) As Boolean
IsCharBanned = False
If Player(index).Char(Player(index).Charnum).Banned = 1 Then
IsCharBanned = True
End If
End Function
in modHandleData find:
Code:
' ::::::::::::::::::::::::::::
' :: Using character packet ::
' ::::::::::::::::::::::::::::
If LCase(Parse(0)) = "usechar" Then
If Not IsPlaying(index) Then
Charnum = Val(Parse(1))
' Prevent hacking
If Charnum < 1 Or Charnum > MAX_CHARS Then
Call HackingAttempt(index, "Invalid CharNum")
Exit Sub
End If
' Check to make sure the character exists and if so, set it as its current char
If CharExist(index, Charnum) Then
Player(index).Charnum = Charnum
and right after that, add this:
Code:
If IsCharBanned(index) = True Then
Call AlertMsg(index, "Sorry, you are banned from playing this server.")
Exit Sub
End If
And that's it, done.
Explanation: Depending on where you placed the code in the BanIndex sub, the server sets a "banned" variable in the PlayerRec to true. Then, when the user tries to log in, the "IsCharBanned" function checks to see if that users "Banned" variable is set to true, if so, they are denied access to the game.
Very simple, and as far as me and my tester are concerned, effective.
If I've left anything out, let me know.
EDIT: Almost forgot, saving and loading:
in modDatabase, in the SavePlayer sub, add this:
Code:
Call PutVar(FileName, "CHAR" & i, "Banned", STR(Player(index).Char(i).Banned))
and in the LoadPlayer sub add this:
Code:
Player(index).Char(i).Banned = Val(GetVar(FileName, "CHAR" & i, "Banned"))