Dawntide Posted August 26, 2012 Author Share Posted August 26, 2012 hello guys,I got problems with overflow runtime error with my currency and the title system:http://www.touchofdeathforums.com/community/index.php?/topic/127866-eo-titles-12/page__hl__title__st__20When i get too much money i get an overflow error, how to avoid it and just make the player does not get more gold?When i choose an title and the title reward gives me stats so i would have stats above 255, i get an overflow runtime error, how to avoid that, so it just stops at 255 without oveeflow error?thanks in advance! Link to comment Share on other sites More sharing options...
Exception Posted August 26, 2012 Share Posted August 26, 2012 You either check that you're not exceeding the limit, or you have an error-trap in place, that handles and corrects it.ie.```If ThingHere > Limit Then ThingHere = Limit - 1```Or```On Error GoTo errorhandler Exit Suberrorhandler: If Err.Number = 6 ' From my memory, this is Overflow. ValueToCorrect = Limit - 1 ' Whatever the hell the resuming line is, I can't remember it. xD Else ' It's a different error, handle accordingly. End If Err.Clear```I recommend you use the first method, just for [your] simplicity. Link to comment Share on other sites More sharing options...
Dawntide Posted August 26, 2012 Author Share Posted August 26, 2012 Okay, but i can not get it to work:```Sub UseTitulo(ByVal index As Long, ByVal Slot As Long) Dim i As Long ' Verificar se está usando o titulo selecionado, se sim sair da sub If GetPlayerTUsando(index) = GetPlayerTitulo(index, Slot) Then Exit Sub ' Remover recompenças If GetPlayerTUsando(index) > 0 Then For i = 1 To Stats.Stat_Count - 1 Call SetPlayerStat(index, i, GetPlayerStat(index, i) - Titulo(GetPlayerTUsando(index)).StatRec(i)) Next End If ' Recompenças For i = 1 To Stats.Stat_Count - 1 Call SetPlayerStat(index, i, GetPlayerStat(index, i) + Titulo(GetPlayerTitulo(index, Slot)).StatRec(i)) Next ' Dar o titulo ao jogador Call SetPlayerTUsando(index, GetPlayerTitulo(index, Slot)) ' Atualizar Call SendPlayerData(index) Call SendStats(index) Call SendPlayerTitulos(index)End Sub```Where do i have to paste the first method now?And where to paste it for currency, because there are so many subs i guess, bank, shop etc. Link to comment Share on other sites More sharing options...
blkcrow Posted August 26, 2012 Share Posted August 26, 2012 this happens because eclipse uses the byte data type for stats if you want your stats to be able to go higher than 255 you have to change it to either integer or longif you dont want to change the data type use the code below```Sub UseTitulo(ByVal index As Long, ByVal Slot As Long) Dim i As Long ' Verificar se está usando o titulo selecionado, se sim sair da sub If GetPlayerTUsando(index) = GetPlayerTitulo(index, Slot) Then Exit Sub ' Remover recompenças If GetPlayerTUsando(index) > 0 Then For i = 1 To Stats.Stat_Count - 1 Call SetPlayerStat(index, i, GetPlayerStat(index, i) - Titulo(GetPlayerTUsando(index)).StatRec(i)) Next End If ' Recompenças For i = 1 To Stats.Stat_Count - 1 if (GetPlayerStat(index, i) + Titulo(GetPlayerTitulo(index, Slot)).StatRec(i)) <= 255 then Call SetPlayerStat(index, i, GetPlayerStat(index, i) + Titulo(GetPlayerTitulo(index, Slot)).StatRec(i)) end if Next ' Dar o titulo ao jogador Call SetPlayerTUsando(index, GetPlayerTitulo(index, Slot)) ' Atualizar Call SendPlayerData(index) Call SendStats(index) Call SendPlayerTitulos(index)End Sub``` Link to comment Share on other sites More sharing options...
Dawntide Posted August 26, 2012 Author Share Posted August 26, 2012 I am still getting overflow runtime error at setstat Link to comment Share on other sites More sharing options...
blkcrow Posted August 26, 2012 Share Posted August 26, 2012 whats this code for```For i = 1 To Stats.Stat_Count - 1 Call SetPlayerStat(index, i, GetPlayerStat(index, i) - Titulo(GetPlayerTUsando(index)).StatRec(i))Next``` Link to comment Share on other sites More sharing options...
Dawntide Posted August 26, 2012 Author Share Posted August 26, 2012 I guess it removes the actual title stats if you switch the title.I do not understand how your code avoids an overflow, it just adds the stats.The if check is completly without effect, isn't it?I noticed that there is some kind of bug in the title system, but i do not know where and how to fix it.If i just go to maxlevel (70) and invest my stat points i got this stats:50 5840 4050Then i choose the first title, which has NO reward stats, then i got this stats:100 10890 90100Then i choose the second title, which has NO reward stats, then i got this stats:200 208190 190200If i choose the third title, i get overflow runtime errorThis only happens if i am wearing armor, helmet etc.It just adds 100 stat points completly random. Link to comment Share on other sites More sharing options...
blkcrow Posted August 26, 2012 Share Posted August 26, 2012 my code checks whether the stats points will go beyond 255 if you add the titles points if it does it just doesnt add themi will go over the tutorial to see if i can find somethingEdit: i downloaded the files in the tutorial but the code is different it doesnt add stats anywhere Link to comment Share on other sites More sharing options...
Dawntide Posted August 26, 2012 Author Share Posted August 26, 2012 It does. modTitulos: Sub UseTitulo(ByVal index As Long, ByVal Slot As Long)I tested your code without equipment and i still get overflow Link to comment Share on other sites More sharing options...
blkcrow Posted August 26, 2012 Share Posted August 26, 2012 are you sure the error is in sub UseTitulo? i cant see anything wrong with it Link to comment Share on other sites More sharing options...
Dawntide Posted August 26, 2012 Author Share Posted August 26, 2012 There is no error in the sub UseTitulo, but the overflow appears here:```Public Sub SetPlayerStat(ByVal index As Long, ByVal stat As Stats, ByVal Value As Long) Player(index).stat(stat) = ValueEnd Sub``` Link to comment Share on other sites More sharing options...
blkcrow Posted August 26, 2012 Share Posted August 26, 2012 ```Public Sub SetPlayerStat(ByVal index As Long, ByVal stat As Stats, ByVal Value As Long) if value >= 255 then Player(index).stat(stat) = 255 else Player(index).stat(stat) = Value end ifEnd Sub```this should fix the overflow error but not the title system Link to comment Share on other sites More sharing options...
Dawntide Posted August 26, 2012 Author Share Posted August 26, 2012 Okay, nice. No overflow anymore, but the title system seems buged like bum candy.It just sums up to 255 on each stats when i change titles, but no title has any rewards. How to fix this?What a pitty that 99% of all tutorials in this forum are buggy as hell ![:(](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/sad.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