Jump to content

Recommended Posts

---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Assertion failed!

Program: I:\40k GameClient\Metin2Debug.exe
File: ..\..\source\EterLib\Camera.cpp
Line: 261

Expression: m_fDistance >= 0

---------------------------------------------------------------------------------------------------------------------------

This is client log:

0706 21:35:09784 :: SYSERR: Traceback (most recent call last):

0706 21:35:09784 :: SYSERR:   File "uiTarget.py", line 479, in OnUpdate

0706 21:35:09785 :: SYSERR: UnboundLocalError
0706 21:35:09785 :: SYSERR: :
0706 21:35:09785 :: SYSERR: local variable 'exchangeButton' referenced before assignment
0706 21:35:09785 :: SYSERR:

---------------------------------------------------------------------------------------------------------------------------

This is code block in python:

    def OnUpdate(self):
        distance = 0 // I added this definition for the error in this blok//
        if player.IsPVPInstance(self.vid):
            constInfo.VID = self.vid
            event.QuestButtonClick(constInfo.STHX)
            if not self.healthBoard.IsShow() and self.vid != 0:
                self.healthBoard.Show()
        else:
            self.healthBoard.Hide()
        if self.isShowButton:
            exchangeButton = self.buttonDict[locale.TARGET_BUTTON_EXCHANGE]
            distance = player.GetCharacterDistance(self.vid)
            
        if distance < 0:
            return distance // this solved problem > local variable 'distance' referenced before assignment


        if exchangeButton.IsShow():
            if distance > self.EXCHANGE_LIMIT_RANGE:
                self.RefreshButton()

                
        else:
            if distance < self.EXCHANGE_LIMIT_RANGE:
                self.RefreshButton()

Above code block keep giving this error .

I dont know what can I do

 

Link to comment
Share on other sites

  • 3 years later...
  • Forum Moderator
On 4/1/2019 at 6:45 PM, BigBoss said:

Bump I have the same error, any solutions?

You declared the variable into a if condition and then you try to call it from outside, that's wrong.

def main(condition):
    if condition:
        variable = 100
    print variable
    
main(True)
<< 100
main(False)
<< Traceback (most recent call last):
<<  File "main.py", line 6, in <module>
<<    main(False)
<<  File "main.py", line 4, in main
<<    print variable
<< UnboundLocalError: local variable 'variable' referenced before assignment

So, your problem is exchangeButton, declare it before condition if self.isShowButton, like:

def OnUpdate(self):
	exchangeButton = self.buttonDict[locale.TARGET_BUTTON_EXCHANGE]
	[.....]

 

  • Love 3
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.