Jump to content

[Python+Quest]Python Button


Go to solution Solved by Sanchez,

Recommended Posts

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

Link to comment
Share on other sites

  • Premium
  • Solution

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
Link to comment
Share on other sites

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!!!!
Link to comment
Share on other sites

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
Link to comment
Share on other sites

 

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
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



  • Similar Content

  • Activity

    1. 0

      Target Information System

    2. 1

      Feeding game source to LLM

    3. 2

      anti exp explanation pls

    4. 1

      Feeding game source to LLM

    5. 2

      anti exp explanation pls

    6. 0

      [GR2] Positioning an object added with "Attach"

    7. 1417

      [40250] Reference Serverfile + Client + Src [15 Available Languages]

  • Recently Browsing

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