zenmen Posted April 24, 2012 Author Share Posted April 24, 2012 Hey! How to fix this issue? I want my HPBar load from the bottom to the top, not like now, from top to bottom ..Scree: ![](http://s6.ifotos.pl/img/hpzleladu_rexqanh.PNG)How to fix it? Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 Please post your HandlePlayerHP sub from the clientside. Link to comment Share on other sites More sharing options...
zenmen Posted April 24, 2012 Author Share Posted April 24, 2012 ```Private Sub HandlePlayerHp(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim Buffer As clsBuffer ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler Set Buffer = New clsBuffer Buffer.WriteBytes Data() Player(MyIndex).MaxVital(Vitals.HP) = Buffer.ReadLong Call SetPlayerVital(MyIndex, Vitals.HP, Buffer.ReadLong) If GetPlayerMaxVital(MyIndex, Vitals.HP) > 0 Then 'frmMain.lblHP.Caption = Int(GetPlayerVital(MyIndex, Vitals.HP) / GetPlayerMaxVital(MyIndex, Vitals.HP) * 100) & "%" frmMain.lblHP.Caption = GetPlayerVital(MyIndex, Vitals.HP) & "/" & GetPlayerMaxVital(MyIndex, Vitals.HP) ' hp bar frmMain.ImgHPBar.height = ((GetPlayerVital(MyIndex, Vitals.HP) / HPBar_Height) / (GetPlayerMaxVital(MyIndex, Vitals.HP) / HPBar_Height)) * HPBar_Height End If ' Error handler Exit Suberrorhandler: HandleError "HandlePlayerHP", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub``` Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 This is a bit of a guess, but try``` If GetPlayerMaxVital(MyIndex, Vitals.HP) > 0 Then 'frmMain.lblHP.Caption = Int(GetPlayerVital(MyIndex, Vitals.HP) / GetPlayerMaxVital(MyIndex, Vitals.HP) * 100) & "%" frmMain.lblHP.Caption = GetPlayerVital(MyIndex, Vitals.HP) & "/" & GetPlayerMaxVital(MyIndex, Vitals.HP) ' hp bar frmMain.ImgHPBar.top = ((GetPlayerVital(MyIndex, Vitals.HP) / frmMain.ImgHPBar.top) / (GetPlayerMaxVital(MyIndex, Vitals.HP) / frmMain.ImgHPBar.top)) * frmMain.ImgHPBar.top End If ' Error handler Exit Suberrorhandler: HandleError "HandlePlayerHP", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit Sub```It's definatly the .Top attribute you need to adjust instead of the .Height variable that's used now. Im just not sure if the math works out like this. Link to comment Share on other sites More sharing options...
zenmen Posted April 24, 2012 Author Share Posted April 24, 2012 Hah, now its funny ; D Please chceck the screenshot:![](http://s4.ifotos.pl/img/noobPNG_renhenp.PNG) Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 ``` If GetPlayerMaxVital(MyIndex, Vitals.HP) > 0 Then 'frmMain.lblHP.Caption = Int(GetPlayerVital(MyIndex, Vitals.HP) / GetPlayerMaxVital(MyIndex, Vitals.HP) * 100) & "%" frmMain.lblHP.Caption = GetPlayerVital(MyIndex, Vitals.HP) & "/" & GetPlayerMaxVital(MyIndex, Vitals.HP) ' hp bar frmMain.ImgHPBar.top = ((GetPlayerVital(MyIndex, Vitals.HP) / frmMain.ImgHPBar.top) / (GetPlayerMaxVital(MyIndex, Vitals.HP) / frmMain.ImgHPBar.top)) * frmMain.ImgHPBar.top + *insert ur thing* End If ' Error handler Exit Suberrorhandler: HandleError "HandlePlayerHP", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit Sub```Can you try again with this code, and fill in *insert ur thing* with the .Top of your frmMain.ImgHPBar. Link to comment Share on other sites More sharing options...
zenmen Posted April 24, 2012 Author Share Posted April 24, 2012 I dont understand:> and fill in *insert ur thing* with the .Top of your frmMain.ImgHPBar.How it must look? You mean "frmMain.ImgHPBar.top + HPBar_Height" ?But if i do that with this code its nothing change, still the same what is on the screen. Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 no, go into your frmMain, click the hp frame and check what value "Top" is, add that to the code Link to comment Share on other sites More sharing options...
zenmen Posted April 24, 2012 Author Share Posted April 24, 2012 Now i dont see my bitmap of ImgHPBar.> If GetPlayerMaxVital(MyIndex, Vitals.HP) > 0 Then> 'frmMain.lblHP.Caption = Int(GetPlayerVital(MyIndex, Vitals.HP) / GetPlayerMaxVital(MyIndex, Vitals.HP) * 100) & "%"> frmMain.lblHP.Caption = GetPlayerVital(MyIndex, Vitals.HP) & "/" & GetPlayerMaxVital(MyIndex, Vitals.HP)> ' hp bar> frmMain.ImgHPBar.top = ((GetPlayerVital(MyIndex, Vitals.HP) / frmMain.ImgHPBar.top) / (GetPlayerMaxVital(MyIndex, Vitals.HP) / frmMain.ImgHPBar.top)) * frmMain.ImgHPBar.top + 589> End If> > ' Error handler> Exit Sub> errorhandler:> HandleError "HandlePlayerHP", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext> Err.Clear> Exit Sub> End Sub Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 I think both Top + height need to be adjusted properly to set it up properly and to be honest I am way too stoned to do smart mathz. The top needs to move down so the image moves down, while the height needs to shrink with an equal amount to make sure the image doesnt just go down but stays on the same spot. Link to comment Share on other sites More sharing options...
zenmen Posted April 24, 2012 Author Share Posted April 24, 2012 That is, You will try to help me (read - do it for me ^ ^)? Unfortunately I do not know much about programming, so or I find a ready-made solution, or the GUI to be thrown away : PAnyway, now I thank you for the above help! :) Link to comment Share on other sites More sharing options...
Joost Posted April 25, 2012 Share Posted April 25, 2012 In ModGlobal add```Public HPTop As LongPublic HPHeight As LongPublic HPOffset As Long```In```Private Sub Form_Load()```on frmMain add``` HpTop = ImgHPBar.TopHpHeight = ImpHpBar.HeightHpOffSet = HpHeight - HpTop```Replace``` frmMain.ImgHPBar.top = ((GetPlayerVital(MyIndex, Vitals.HP) / frmMain.ImgHPBar.top) / (GetPlayerMaxVital(MyIndex, Vitals.HP) / frmMain.ImgHPBar.top)) * frmMain.ImgHPBar.top + 589```with```Percentage = (GetPlayerVital(MyIndex, Vitals.HP / GetPlayerMaxVital(MyIndex, Vitals.HP)ImgHpBar.Top = HpTop + (HpOffSet * Percentage)ImgHpBar.Height = HpHeight - (HPOffset * Percentage)```Add Dim Percentage As Long at the top of that sub. Link to comment Share on other sites More sharing options...
Joost Posted April 25, 2012 Share Posted April 25, 2012 This was my proof of concept to make sure my math was ok. Make a new project, add a Picture1 and a Hscroll1 and you can test the math. So if there are any mistakes in the above code, it is probably something small and stupid.```Public A As LongPublic B As LongPublic C As LongPublic Percentage As LongPrivate Sub Change() Picture1.Top = A - (C * Percentage / 100) Picture1.Height = B + (C * Percentage / 100)End SubPrivate Sub Form_Load() A = Picture1.Top B = Picture1.Height C = (A - B)End SubPrivate Sub HScroll1_Change()Percentage = HScroll1.ValueCall ChangeEnd Sub``` Link to comment Share on other sites More sharing options...
zenmen Posted April 25, 2012 Author Share Posted April 25, 2012 Thank you! But.. (yeah thats only me..) i have got some error (ofcoure i add all Publics etc in modGlobals and frmMain):Link: ![](http://s6.ifotos.pl/img/errorPNG_renxwnq.PNG)And there is some bugs:> HpTop = ImgHPBar.Top> HpHeight = Im**p**HpBar.Height> HpOffSet = HpHeight - HpTopand parentheses but I do not know how they should be:> Percentage = (GetPlayerVital(MyIndex, Vitals.HP / GetPlayerMaxVital(MyIndex, Vitals.HP)**))**> ImgHpBar.Top = HpTop + (HpOffSet * Percentage)> ImgHpBar.Height = HpHeight - (HPOffset * Percentage)or:> Percentage = (GetPlayerVital(MyIndex, Vitals.HP**)** / GetPlayerMaxVital(MyIndex, Vitals.HP)**)**> ImgHpBar.Top = HpTop + (HpOffSet * Percentage)> ImgHpBar.Height = HpHeight - (HPOffset * Percentage)I really thank you for your help! :embarrassed: Link to comment Share on other sites More sharing options...
Joost Posted April 25, 2012 Share Posted April 25, 2012 ```Percentage = (GetPlayerVital(MyIndex, Vitals.HP / GetPlayerMaxVital(MyIndex, Vitals.HP)frmMain.ImgHpBar.Top = HpTop + (HpOffSet * Percentage)frmMain.ImgHpBar.Height = HpHeight - (HPOffset * Percentage)```That should fix that problem.```HpHeight = ImpHpBar.Height```That was just a typo, but I assume you fixed that already```Percentage = GetPlayerVital(MyIndex, Vitals.HP) / GetPlayerMaxVital(MyIndex, Vitals.HP)ImgHpBar.Top = HpTop + (HpOffSet * Percentage)ImgHpBar.Height = HpHeight - (HPOffset * Percentage)```That one is correct. Link to comment Share on other sites More sharing options...
zenmen Posted April 25, 2012 Author Share Posted April 25, 2012 Haha now its crazy! : D Just look:![](http://s6.ifotos.pl/img/errorPNG_renxsrx.PNG):confused: Link to comment Share on other sites More sharing options...
Joost Posted April 25, 2012 Share Posted April 25, 2012 can you pm/post your source code so I can fix it properly? In my demo project the stuff seems to work so Im not really sure what's wrong. Link to comment Share on other sites More sharing options...
zenmen Posted April 25, 2012 Author Share Posted April 25, 2012 Joost, what about this code?``` With Health_Bar If Player.Stats.Total_Health <> 0 Then HP = (Player.Stats.Current_Health / Player.Stats.Total_Health) * .Frame_Size.BottomVertex_List(0) = Create_TLVertex(.X + .Frame_Size.Left, .Y + .Frame_Size.Top, 0, 1, D3DColorRGBA(255, 255, 255, 255), 0, 0, 0)Vertex_List(1) = Create_TLVertex(.X + .Frame_Size.Left, .Y + HR, 0, 1, D3DColorRGBA(255, 255, 255, 255), 0, 0, 1) End With ```Its something change? Link to comment Share on other sites More sharing options...
Joost Posted April 25, 2012 Share Posted April 25, 2012 That is the code for drawing the health bar under players, and is not really related. It's just something with my math is still fucked up, I will look into it tonight. Link to comment Share on other sites More sharing options...
Ruins of Hell Posted April 25, 2012 Share Posted April 25, 2012 Try this:* * *Find:```Public HPBar_Width As Long```and under add:```Public HPBar_Height As Long```Next find:```' store the bar widths for calculations```and under add:``` HPBar_Height = frmMain.imgHPBar.height```Then use this code for the calculations in HandlePlayerHP:```frmMain.imgHPBar.height = GetPlayerVital(MyIndex, Vitals.HP) / GetPlayerMaxVital(MyIndex, Vitals.HP) * HPBar_Height``` Link to comment Share on other sites More sharing options...
zenmen Posted April 25, 2012 Author Share Posted April 25, 2012 Yes, I exactly do that at the begginging which gave me that effect:>! ![](http://s6.ifotos.pl/img/hpzleladu_rexqanh.PNG) 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