20-09-2007, 04:42 AM
Okey, This is only my first tutorial so don't yell at me.
Basically, this tutorial will check to see whether the person logging in is a male or female, and then blt their name to the Male color or Female color. This wasn't hard to figure out but since I did it on my own, I thought I would share it.
I'm not sure if there is already a tutorial on this, but if there is then this one can be deleted. Okey, on to the tutorial.
Server Side:
First, you should add these two functions at the bottom of modGameLogic.
Once you have those two functions added, head over to modServerTCP and search for "Sub SendStats(ByVal Index As Long)". Change that entire sub to:
Done with Server!
Client Time!
Now that we are in the client, we need to make changes to the SendStats packet so that we can receive the player's sex. To do this we need to search for, "' :: Player stats packet ::" in modHandleData. Change this entire packet to:
Now that our client recieves the player's sex, it still doesn't have the function to actually make the client know what sex they have. So we need to two functions to the client. In modGameLogic add these two functions at the bottom.
There, now our client receives the player's sex and knows what to do with it. Finally we need to make the client check if the player is Male or Female and then blt their name. Go to modGameLogic and search for, "Sub BltPlayerName(ByVal Index As Long)" and change the entire sub to:
In that sub, we check to see if the person is a male or female. If the player is a male, then their name will show up to be Orange. If they're a female then it will be a purplish color. To change the color of the names, find the RGB(Blah, Blah, Blah) beside the SEX_MALE or SEX_FEMALE and change it to the desired color.
That should be it for this tutorial so if there is any problems, post back! I'll try to help as much as I can and I'm sure the community will help also!
Edit: I forgot to add the Sex to the Player Type. Go into modTypes and go to Type PlayerRec and under, "Name As String * NAME_LENGTH" add, "Sex as Byte".
Also, go into frmNewChar and change all three Label3, optMale, and optFemale's visibility to True instead of false.


Server Side:
First, you should add these two functions at the bottom of modGameLogic.
Code:
Function GetPlayerSex(ByVal Index As Long) As Long
GetPlayerSex = Player(Index).Char(Player(Index).CharNum).Sex
End Function
Sub SetPlayerSex(ByVal Index As Long, ByVal Sex As Byte)
Player(Index).Char(Player(Index).CharNum).Sex = Sex
End Sub
Once you have those two functions added, head over to modServerTCP and search for "Sub SendStats(ByVal Index As Long)". Change that entire sub to:
Code:
Sub SendStats(ByVal Index As Long)
Dim Packet As String
Packet = "PLAYERSTATS" & SEP_CHAR & GetPlayerSTR(Index) & SEP_CHAR & GetPlayerDEF(Index) & SEP_CHAR & GetPlayerSPEED(Index) & SEP_CHAR & GetPlayerMAGI(Index) & SEP_CHAR & GetPlayerSex(Index) & SEP_CHAR & END_CHAR
Call SendDataTo(Index, Packet)
End Sub
Done with Server!
Client Time!
Now that we are in the client, we need to make changes to the SendStats packet so that we can receive the player's sex. To do this we need to search for, "' :: Player stats packet ::" in modHandleData. Change this entire packet to:
Code:
' :::::::::::::::::::::::::
' :: Player stats packet ::
' :::::::::::::::::::::::::
If LCase(Parse(0)) = "playerstats" Then
Call SetPlayerSTR(MyIndex, Val(Parse(1)))
Call SetPlayerDEF(MyIndex, Val(Parse(2)))
Call SetPlayerSPEED(MyIndex, Val(Parse(3)))
Call SetPlayerMAGI(MyIndex, Val(Parse(4)))
Call SetPlayerSex(MyIndex, Val(Parse(5)))
Exit Sub
End If
Now that our client recieves the player's sex, it still doesn't have the function to actually make the client know what sex they have. So we need to two functions to the client. In modGameLogic add these two functions at the bottom.
Code:
Sub SetPlayerSex(ByVal Index As Long, ByVal Sex As Byte)
Player(Index).Sex = Sex
End Sub
Function GetPlayerSex(ByVal Index As Long) As Long
GetPlayerSex = Player(Index).Sex
End Function
There, now our client receives the player's sex and knows what to do with it. Finally we need to make the client check if the player is Male or Female and then blt their name. Go to modGameLogic and search for, "Sub BltPlayerName(ByVal Index As Long)" and change the entire sub to:
Code:
Sub BltPlayerName(ByVal Index As Long)
Dim TextX As Long
Dim TextY As Long
Dim Color As Long
' Check access level
If GetPlayerPK(Index) = NO Then
Select Case GetPlayerAccess(Index)
Case 0
Select Case GetPlayerSex(Index)
Case SEX_MALE
Color = RGB(255, 123, 60)
Case SEX_FEMALE
Color = RGB(190, 70, 193)
End Select
Case 1
Color = QBColor(DarkGrey)
Case 2
Color = QBColor(Cyan)
Case 3
Color = QBColor(Blue)
Case 4
Color = QBColor(Pink)
End Select
Else
Color = QBColor(BrightRed)
End If
' Draw name
TextX = GetPlayerX(Index) * PIC_X + Player(Index).XOffset + Int(PIC_X / 2) - ((Len(GetPlayerName(Index)) / 2) * 8)
TextY = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset - Int(PIC_Y / 2) - 4
Call DrawText(TexthDC, TextX, TextY, GetPlayerName(Index), Color)
End Sub
In that sub, we check to see if the person is a male or female. If the player is a male, then their name will show up to be Orange. If they're a female then it will be a purplish color. To change the color of the names, find the RGB(Blah, Blah, Blah) beside the SEX_MALE or SEX_FEMALE and change it to the desired color.
That should be it for this tutorial so if there is any problems, post back! I'll try to help as much as I can and I'm sure the community will help also!
Edit: I forgot to add the Sex to the Player Type. Go into modTypes and go to Type PlayerRec and under, "Name As String * NAME_LENGTH" add, "Sex as Byte".
Also, go into frmNewChar and change all three Label3, optMale, and optFemale's visibility to True instead of false.