damian666 Posted April 14, 2013 Author Share Posted April 14, 2013 SERVER SIDE:First go to modTypes, and in PlayerRec add```Hair As byte```at the bottom.At the bottom of modPlayer, add```Function GetPlayerHair(ByVal Index As Long) As byteIf Index <= 0 Or Index > MAX_PLAYERS Then Exit FunctionGetPlayerHair = Player(Index).HairEnd FunctionSub SetPlayerHair(ByVal Index As Long, ByVal Hair As byte)If Index <= 0 Or Index > MAX_PLAYERS Then Exit SubPlayer(Index).Hair = HairEnd Sub```in modDatabase find```Sub AddChar(ByVal Index As Long, ByVal Name As String, ByVal Sex As Byte, ByVal ClassNum As Long, ByVal Sprite As Long)```and replace it with```Sub AddChar(ByVal Index As Long, ByVal Name As String, ByVal Sex As Byte, ByVal ClassNum As Long, ByVal Sprite As Long, ByVal Hair As byte)```then, inside the sub, change```If Player(Index).Sex = SEX_MALE ThenPlayer(Index).Sprite = Class(ClassNum).MaleSprite(Sprite)ElsePlayer(Index).Sprite = Class(ClassNum).FemaleSprite(Sprite)End If```to```If Player(Index).Sex = SEX_MALE ThenPlayer(Index).Sprite = SpriteElsePlayer(Index).Sprite = SpriteEnd If```under```Player(Index).Level = Level```Add```Player(Index).Hair = Hair```Now, in modHandleData, find```HandleAddChar```and under```Dim n As Long```Add```Dim Hair As byte```, under```Sprite = Buffer.ReadLong```add```Hair = Buffer.Readbyte```then find```Call AddChar(Index, Name, Sex, Class, Sprite)```and replace with```Call AddChar(Index, Name, Sex, Class, Sprite, Hair)```Next, in modServerTCP, find```Function PlayerData```and under```Buffer.WriteLong GetPlayerLevel(Index)```Add```Buffer.Writebyte GetPlayerHair(Index)```And that's the server work. Now comes the client work.CLIENT SIDE:Like with the server, first go to modTypes, and in PlayerRec add```Hair As byte```at the bottom.Then in modClientTCP find```Public Sub SendAddChar(ByVal Name As String, ByVal Sex As Long, ByVal ClassNum As Long, ByVal Sprite As Long)```and replace with```Public Sub SendAddChar(ByVal Name As String, ByVal Sex As Long, ByVal ClassNum As Long, ByVal Sprite As Long, ByVal Hair As byte)```and under```Buffer.WriteLong Sprite```Add```Buffer.Writebyte Hair```In modDatabase add, at the bottom or somewhere:```Public Sub CheckHair()Dim i As Long' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandleri = 1While FileExist(GFX_PATH & "Characters\hair\" & i & GFX_EXT)NumHair = NumHair + 1i = i + 1WendIf NumHair = 0 Then Exit SubReDim DDS_Hair(1 To NumHair)ReDim DDSD_Hair(1 To NumHair)ReDim HairTimer(1 To NumHair)frmMenu.scrlHair.Max = NumHair' Error handlerExit Suberrorhandler:HandleError "CheckHair", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd SubFunction GetPlayerHair(ByVal Index As Long) As byte' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf Index > MAX_PLAYERS Then Exit FunctionGetPlayerHair = Player(Index).Hair' Error handlerExit Functionerrorhandler:HandleError "GetPlayerSprite", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit FunctionEnd FunctionSub SetPlayerHair(ByVal Index As Long, ByVal Hair As byte)' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf Index > MAX_PLAYERS Then Exit SubPlayer(Index).Hair = Hair' Error handlerExit Suberrorhandler:HandleError "SetPlayerSprite", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```in modGlobals, under```Public newCharClass As Long```Add```Public newCharHair As byte```now, in modGeneral you have to find```Call SendAddChar```it will look somewhat like this:```If frmMenu.optMale.Value ThenCall SendAddChar(frmMenu.txtCName, SEX_MALE, frmMenu.cmbClass.ListIndex + 1, newCharSprite)ElseCall SendAddChar(frmMenu.txtCName, SEX_FEMALE, frmMenu.cmbClass.ListIndex + 1, newCharSprite)End If```replace it with this:```If frmMenu.optMale.Value ThenCall SendAddChar(frmMenu.txtCName, SEX_MALE, frmMenu.cmbClass.ListIndex + 1, newCharSprite, newCharHair)ElseCall SendAddChar(frmMenu.txtCName, SEX_FEMALE, frmMenu.cmbClass.ListIndex + 1, newCharSprite, newCharHair)End If```go to modHandleData and find```Call SetPlayerLevel(i, Buffer.ReadLong)```and add under it```Call SetPlayerHair(i, Buffer.Readbyte)```in modDirectDraw7, somewhere along or under```Public DDS_Face() As DirectDrawSurface7```Add```Public DDS_Hair() As DirectDrawSurface7```Under```Public DDSD_Face() As DDSURFACEDESC2```Add```Public DDSD_Hair() As DDSURFACEDESC2```, under```Public FaceTimer() As Long```Add```Public HairTimer() As Long```Under```Public NumFaces As Long```Add```Public NumHair As Long```under```Call CheckFaces```in Sub main, modgeneral, add```Call CheckHair```find BltPlayer and at the top add```Dim Hair As ByteDim recHair As DxVBLib.RECT```Then under```Sprite = GetPlayerSprite(Index)```Add```Hair = GetPlayerHair(Index)```Then Under```If Sprite < 1 Or Sprite > NumCharacters Then Exit Sub```Add```If Hair < 1 Or Hair > NumHair Then Exit Sub```Then Under```CharacterTimer(Sprite) = GetTickCount + SurfaceTimerMax```Add```HairTimer(Hair) = GetTickCount + SurfaceTimerMax```Under```If DDS_Character(Sprite) Is Nothing ThenCall InitDDSurf("characters\" & Sprite, DDSD_Character(Sprite), DDS_Character(Sprite))End If```Add```If DDS_Hair(Hair) Is Nothing ThenCall InitDDSurf("characters\hair\" & Hair, DDSD_Hair(Hair), DDS_Hair(Hair))End If```Under```' Set the leftSelect Case GetPlayerDir(Index)Case DIR_UPspritetop = 3Case DIR_RIGHTspritetop = 2Case DIR_DOWNspritetop = 0Case DIR_LEFTspritetop = 1End Select```Add```With recHair.Top = spritetop * (DDSD_Hair(Hair).lHeight / 4).Bottom = .Top + (DDSD_Hair(Hair).lHeight / 4).Left = Anim * (DDSD_Hair(Hair).lWidth / 4).Right = .Left + (DDSD_Hair(Hair).lWidth / 4)End With```Under```' render the actual spriteCall BltSprite(Sprite, x, y, recSprite)```Add```Call BltHair(Hair, x, y, recHair)```and at the bottom or somewhere in the module add```Public Sub BltHair(ByVal Hair As Byte, ByVal x2 As Long, ByVal y2 As Long, rec As DxVBLib.RECT)Dim x As LongDim y As LongDim Width As LongDim Height As Long' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf Hair < 1 Or Hair > NumHair Then Exit Subx = ConvertMapX(x2)y = ConvertMapY(y2)Width = (rec.Right - rec.Left)Height = (rec.Bottom - rec.Top)' clippingIf y < 0 ThenWith rec.Top = .Top - yEnd Withy = 0End IfIf x < 0 ThenWith rec.Left = .Left - xEnd Withx = 0End IfIf y + Height > DDSD_BackBuffer.lHeight Thenrec.Bottom = rec.Bottom - (y + Height - DDSD_BackBuffer.lHeight)End IfIf x + Width > DDSD_BackBuffer.lWidth Thenrec.Right = rec.Right - (x + Width - DDSD_BackBuffer.lWidth)End If' /clippingCall Engine_BltFast(x, y, DDS_Hair(Hair), rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)' Error handlerExit Suberrorhandler:HandleError "BltHair", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd SubPublic Sub NewCharacterBltHair()Dim sRECT As DxVBLib.RECTDim dRECT As DxVBLib.RECTDim Width As Long, Height As Long' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf newCharHair < 1 Or newCharHair > NumHair ThenfrmMenu.picHair.ClsExit SubEnd IfHairTimer(newCharHair) = GetTickCount + SurfaceTimerMaxIf newCharHair > 0 ThenIf DDS_Hair(newCharHair) Is Nothing ThenCall InitDDSurf("characters\hair\" & newCharHair, DDSD_Hair(newCharHair), DDS_Hair(newCharHair))End IfEnd IfWidth = DDSD_Hair(newCharHair).lWidth / 4Height = DDSD_Hair(newCharHair).lHeight / 4frmMenu.picHair.Width = WidthfrmMenu.picHair.Height = HeightsRECT.Top = 0sRECT.Bottom = sRECT.Top + HeightsRECT.Left = 0sRECT.Right = sRECT.Left + WidthdRECT.Top = 0dRECT.Bottom = HeightdRECT.Left = 0dRECT.Right = WidthCall Engine_BltToDC(DDS_Hair(newCharHair), sRECT, dRECT, frmMenu.picHair)' Error handlerExit Suberrorhandler:HandleError "NewCharacterBltHair", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```in sub NewCharacterBltSprite, change```If frmMenu.optMale.Value = True ThenSprite = Class(frmMenu.cmbClass.ListIndex + 1).MaleSprite(newCharSprite)ElseSprite = Class(frmMenu.cmbClass.ListIndex + 1).FemaleSprite(newCharSprite)End If```to```If frmMenu.optMale.Value = True ThenSprite = newCharSpriteElseSprite = newCharSpriteEnd If```Now open up frmMenu and make sure you've got picCharacter in front (make sure you can see the "new character" menu box), then add:> A hscrollbar that will act as a button to change the sprite, named scrlSprite> A hscrollbar that will act as a button to change the hair named scrlHair> A picturebox called picHair, same size as picSpriteNow, inside frmMenu's code, add…```Private Sub scrlHair_Change()' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf newCharHair >= scrlHair.Max ThennewCharHair = 0ElsenewCharHair = scrlHair.ValueEnd IfNewCharacterBltHair' Error handlerExit Suberrorhandler:HandleError "scrlShirt_Change", "frmMenu", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd SubPrivate Sub scrlSprite_Change()Dim spritecount As Long' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf optMale.Value Thenspritecount = UBound(Class(cmbClass.ListIndex + 1).MaleSprite)Elsespritecount = UBound(Class(cmbClass.ListIndex + 1).FemaleSprite)End IfIf newCharSprite >= scrlSprite.Max ThennewCharSprite = 0ElsenewCharSprite = scrlSprite.ValueEnd IfNewCharacterBltSprite' Error handlerExit Suberrorhandler:HandleError "scrlSprite_Change", "frmMenu", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```Add```newCharHair = 1```under```' Load the username + passtxtLUser.text = Trim$(Options.Username)If Options.SavePass = 1 ThentxtLPass.text = Trim$(Options.Password)chkPass.Value = Options.SavePassEnd If```EDITforgot to put in the cleanup code xdin ModGameLogic, somewhere beneath "' * Check surface timers *"add```If NumHair > 0 Then For i = 1 To NumHair 'Check to unload surfaces If HairTimer(i) > 0 Then 'Only update surfaces in use If HairTimer(i) < Tick Then 'Unload the surface Call ZeroMemory(ByVal VarPtr(DDSD_Hair(i)), LenB(DDSD_Hair(i))) Set DDS_Hair(i) = Nothing HairTimer(i) = 0 End If End If Next End If```then in modDirectDraw7, in sub DestroyDirectDraw add```For i = 1 To NumHair Set DDS_Hair(i) = Nothing ZeroMemory ByVal VarPtr(DDSD_Hair(i)), LenB(DDSD_Hair(i)) Next```that's all the code! Now, for the non-code stuff.Inside the client folder, in "data files\graphics\characters", create a new folder called hairAdd your numbered hair files.You will also have to replace the classes sprites with hairless/bald sprites so the hair isn't drawn over more hairplease note this is untested, since i ripped it from my heavily modded source, could be i forgot something xdthis is based on > [http://www.touchofde…air-hair-color/](http://www.touchofdeathforums.com/community/index.php?/topic/132296-eo-30-character-customization-hair-hair-color/)premade clean Eo > http://freemmorpgmaker.com/uploadfiles/ba78e7f84aca93d16bf72291ae559c55.zip Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 Long but epic tutorial tnx ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png)i'll add it right away ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png) Link to comment Share on other sites More sharing options...
damian666 Posted April 14, 2013 Author Share Posted April 14, 2013 thanx mate, hope it works right away, else ask me, i proberly forgot something then xdand if you know a way to draw the hair ontop of the sprite, do let me know ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 > thanx mate, hope it works right away, else ask me, i proberly forgot something then xd> > and if you know a way to draw the hair ontop of the sprite, do let me know ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)Doesn't it work if you let your engine load from pngthen ontop loading normally works Link to comment Share on other sites More sharing options...
damian666 Posted April 14, 2013 Author Share Posted April 14, 2013 nope ![:(](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/sad.png) Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 Call CheckHairs not defined Link to comment Share on other sites More sharing options...
damian666 Posted April 14, 2013 Author Share Posted April 14, 2013 should be checkhair xdedited it ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png) Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 in BltSpritehair not defined Link to comment Share on other sites More sharing options...
damian666 Posted April 14, 2013 Author Share Posted April 14, 2013 its there mate o.ofind BltPlayer and at the top addDim Hair As ByteDim recHair As DxVBLib.RECTi didnt touch bltsprite. Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 hair is NewCharacterBltSprite not definedIf DDS_Hair(Hair) Is Nothing ThenCall InitDDSurf("characters\hair\" & Hair, DDSD_Hair(Hair), DDS_Hair(Hair))End If Link to comment Share on other sites More sharing options...
damian666 Posted April 14, 2013 Author Share Posted April 14, 2013 did'nt touch NewCharacterBltSprite either?those things go in bltplayer man. Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 > did'nt touch NewCharacterBltSprite either?> > those things go in bltplayer man.i already thought so ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png) Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 In Private Sub scrlSprite_Change()spritecount isn't definedI think you forgot dim spritecount as long? Link to comment Share on other sites More sharing options...
damian666 Posted April 14, 2013 Author Share Posted April 14, 2013 yep, ill add it ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 Now it finally works ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Link to comment Share on other sites More sharing options...
damian666 Posted April 14, 2013 Author Share Posted April 14, 2013 good xd Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 I've only tested it with run with full compile ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)I will stress test it after i converted all the hairs you've put in png ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png) Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 Ok i started stresstesting ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png)And now it marks this:Player(Index).x = xIn Sub SetPlayerX(ByVal Index As Long, ByVal x As Long) Link to comment Share on other sites More sharing options...
damian666 Posted April 14, 2013 Author Share Posted April 14, 2013 try replacingSprite = Class(frmMenu.cmbClass.ListIndex + 1).MaleSprite(newCharSprite)withSprite = newCharSprite Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 I fixed that but now it marks :Player(Index).x = xin Sub SetPlayerX(ByVal Index As Long, ByVal x As Long)It says overflow Link to comment Share on other sites More sharing options...
damian666 Posted April 14, 2013 Author Share Posted April 14, 2013 i didnt even come close to that sub xd Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 Then how the heck did i ducked up that sub ![:(](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/sad.png) Link to comment Share on other sites More sharing options...
damian666 Posted April 14, 2013 Author Share Posted April 14, 2013 perhaps a mistake in the function playerdata server side, make sure it sends and then recieves in client the same way.seeying thats where it sends the hair stuff, it could be where it ducks up. Link to comment Share on other sites More sharing options...
damian666 Posted April 14, 2013 Author Share Posted April 14, 2013 yep, found it, its sending a long, and it should be a byte, my bad xdfunction playerdata, buffer.Writelong GetPlayerHair(Index), should be buffer.WriteByte GetPlayerHair(Index) Link to comment Share on other sites More sharing options...
santa-clause Posted April 14, 2013 Share Posted April 14, 2013 Still not working…![](http://www.touchofdeathforums.com/community/uploads/profile/photo-73490.gif?_r=1365954960) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now