| Mirage Source http://web.miragesource.net/forums/ |
|
| Sex Determines Name Color http://web.miragesource.net/forums/viewtopic.php?f=210&t=2728 |
Page 1 of 1 |
| Author: | Hayashi [ Thu Sep 20, 2007 4:42 am ] |
| Post subject: | Sex Determines Name Color |
Okey, This is only my first tutorial so don't yell at me. 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. |
|
| Author: | Lea [ Thu Sep 20, 2007 11:19 am ] |
| Post subject: | Re: Sex Determines Name Color |
I am uncertain... Does this get the sex of all the other players, or just your own? |
|
| Author: | Hayashi [ Thu Sep 20, 2007 4:26 pm ] |
| Post subject: | Re: Sex Determines Name Color |
Hmm, I'm not sure. I haven't tested it with more than one person on. I'll test it when I get home from college. |
|
| Author: | Robin [ Thu Sep 20, 2007 5:30 pm ] |
| Post subject: | Re: Sex Determines Name Color |
It should work on all players. |
|
| Author: | Tony [ Thu Sep 20, 2007 7:32 pm ] |
| Post subject: | Re: Sex Determines Name Color |
Kuja Robin Big tutorial done by a new user :] Great way to start off! |
|
| Author: | Rezeyu [ Thu Sep 20, 2007 11:09 pm ] |
| Post subject: | Re: Sex Determines Name Color |
Holy shit, I can see Dave's avatar and sig. o.O I did something like this for human - vampire(transformed) But took it off cus it annoyed me immensely. |
|
| Author: | Lea [ Thu Sep 20, 2007 11:20 pm ] |
| Post subject: | Re: Sex Determines Name Color |
The avatar is now hosted via MS. The sig is still on EF. |
|
| Author: | Hayashi [ Fri Sep 21, 2007 2:46 am ] |
| Post subject: | Re: Sex Determines Name Color |
So, has anyone tried this with multiple user's on at the same time? I would try to get more than one on at the same time but I don't know how to do that multiple logging because when I log in the second character I get an automation error. But anyway, thanks for all the replies! |
|
| Author: | Rezeyu [ Fri Sep 21, 2007 2:59 am ] |
| Post subject: | Re: Sex Determines Name Color |
No, it should work fine. I know once I messed up displaying player names on the GUI, and it showed whoever the last person was that logged on instead of the actual player's name though. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|