Jump to content
  • 0
Sign in to follow this  
DarkWolf

[Python+Quest]Python Button

Question

Hi all,

 

I'm trying to make a button in python who is only visible if the player has a quest flag, but I'm having some problems, when I enter the client he falls.

 

quest

quest Button begin
    state start begin
        when login begin
            if pc.getqf("test_1") == 1 then
                cmdchat("SHOW_TEST_BUTTON 1")
            end
        end
    end
end

Game.py

##TESTBUTTON
"SHOW_TEST_BUTTON"			: self.__ShowTestButton,
##END_TESTBUTTON

constInfo.py

SHOW_TEST_BUTTON = 0

uitarget.py

"TEST_BUTTON",


self.buttonDict["TEST_BUTTON"].SetEvent(ui.__mem_func__(self.OnTest))


if constInfo.SHOW_TEST_BUTTON() == 1:
            self.__ShowTestButton("TEST_BUTTON")

def OnTest(self):
net.SendChatPacket("/stun " + str(chr.GetNameByVID(self.vid)))

Can someone help me pls.

 

 

Regards,

 

DarkWolf

Share this post


Link to post

12 answers to this question

Recommended Posts

  • 0

I made an example for you, follow these steps:
 
uitarget.py - >
 
Search for this: 
 

BUTTON_NAME_LIST = ( 

 
Add this to the list:
 

"M2DEV_BUTTON",

 
Search for this:
 

self.buttonDict[locale.TARGET_BUTTON_EXCLUDE].SetEvent(ui.__mem_func__(self.OnPartyRemove))

 
Add this under that:
 

self.buttonDict["M2DEV_BUTTON"].SetEvent(ui.__mem_func__(self.OnM2Dev))

 
Search for this:
 

		if not messenger.IsFriendByName(self.nameString):
			self.__ShowButton(locale.TARGET_BUTTON_FRIEND)

 
Add this under that:
 

		if str(constInfo.HAVEQF) == "1":
			self.__ShowButton("M2DEV_BUTTON")

 
Add the event to somewhere you want:
 

	def OnM2Dev(self):
		import dbg
		dbg.LogBox("Hello there!")

 
game.py - >
 
Search for this:
 

"PlayMusic"				: self.__PlayMusic,

 
Add this under that:
 

"m2devqf"				: self.__ReceiveQF,

 
Add the event to somewhere you want:
 

	def __ReceiveQF(self):
		constInfo.HAVEQF = 1

 
constInfo.py - >
 
Add this to somewhere you want:

constInfo.HAVEQF = 0

 
Quest - > 
 

quest Button begin
    state start begin
        when login begin
            if pc.getqf("m2dev") == 1 then
                cmdchat("m2devqf")
            end
        end
    end
end
  • Love 3

Share this post


Link to post
  • 0

I'm getting always the same problem, client falls.

 

syserr:

0317 02:49:06691 :: 
networkModule.py(line:194) SetSelectCharacterPhase
system.py(line:130) __pack_import
system.py(line:110) _process_result
introSelect.py(line:26) ?
system.py(line:130) __pack_import

networkModule.SetSelectCharacterPhase - exceptions.SyntaxError:invalid syntax (line 297)

0317 02:49:06691 :: ============================================================================================================
0317 02:49:06691 :: Abort!!!!

Share this post


Link to post
  • 0

It's just a syntax error, upload your game and uitarget.py or every what file you modified.

Share this post


Link to post
  • 0

all in uitraget:

	BUTTON_NAME_LIST = (

example

		"Kill",

done. under the

self.buttonDict[locale.TARGET_BUTTON_EXCLUDE].SetEvent(ui.__mem_func__(self.OnPartyRemove))

this


		self.buttonDict["Kill"].SetEvent(ui.__mem_func__(self.OnKill))

done. then look for the:

def RefreshButton(self):

and add this:

		if str(player.GetName())[0] == "[":
			self.__ShowButton("Kill")
 
and at the bottom of the:

	def OnKill(self):
		net.SendChatPacket("/kill " + str(chr.GetNameByVID(self.vid)))

I'm sorry for my bad english I'm German: D

 

  • Love 1

Share this post


Link to post
  • 0

You forgot a ) character at the 296. line. 

 

Still doesn't work :unsure:

Share this post


Link to post
  • 0

 

I made an example for you, follow these steps:

 

uitarget.py - >

 

Search for this: 

 

BUTTON_NAME_LIST = ( 

 

Add this to the list:

 

"M2DEV_BUTTON",

 

Search for this:

 

self.buttonDict[locale.TARGET_BUTTON_EXCLUDE].SetEvent(ui.__mem_func__(self.OnPartyRemove))

 

Add this under that:

 

self.buttonDict["M2DEV_BUTTON"].SetEvent(ui.__mem_func__(self.OnM2Dev))

 

Search for this:

 

		if not messenger.IsFriendByName(self.nameString):
			self.__ShowButton(locale.TARGET_BUTTON_FRIEND)

 

Add this under that:

 

		if str(constInfo.HAVEQF) == "1":
			self.__ShowButton("M2DEV_BUTTON")

 

Add the event to somewhere you want:

 

	def OnM2Dev(self):
		import dbg
		dbg.LogBox("Hello there!")

 

game.py - >

 

Search for this:

 

"PlayMusic"				: self.__PlayMusic,

 

Add this under that:

 

"m2devqf"				: self.__ReceiveQF,

 

Add the event to somewhere you want:

 

	def __ReceiveQF(self):
		constInfo.HAVEQF = 1

 

constInfo.py - >

 

Add this to somewhere you want:

constInfo.HAVEQF = 0

 

Quest - > 

 

quest Button begin
    state start begin
        when login begin
            if pc.getqf("m2dev") == 1 then
                cmdchat("m2devqf")
            end
        end
    end
end

 

Thank you so much!!! it's working!

  • Love 2

Share this post


Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • 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.