Jump to content
metin2dev
  • 0
Sign in to follow this  
Syriza

open question about second argument in python command

Question

Hello people,

I have adjusted my command regarding the status points,  now I am able to distribute several status points immediately.

I have also found a release which is a gui to distribute the status points, but the function in the release executes the / stat command several times .

So:

/stat st

Instead of:

/stat (entered value, example 20)

Unfortunately, I do not understand much of Python, I hope someone agrees to help me. :)

 

Pictures say more than thousand words: https://gyazo.com/2bb776774d0fdc2f2e42db63f51f559b


greetings

Share this post


Link to post
Share on other sites

11 answers to this question

Recommended Posts

  • 0

Dont understand your problem...

After you put the status it return back???

 

If is that, the problem is not from python...

Share this post


Link to post
Share on other sites
  • 0
vor 1 Stunde schrieb WeedHex:

Dont understand your problem...

After you put the status it return back???

 

If is that, the problem is not from python...

 

hey weedhex, my problem is that the command is currently being executed several times, which can lead to kicks if the number is high. I have now adjusted the command when distributing the status points so that you get the status points immediately. but in python the command is still being executed several times.

 

 

Example

before my changes:

 

i could only give 1 stat

/state st

 

now im able to distribute what ever value i type in

e.g.

/stat st 20

 

 

 

the function im using currently executes this

        self.statusPlusCommandDict={
            "HTH" : "/stat ht",
            "INT" : "/stat iq",
            "STR" : "/stat st",
            "DEX" : "/stat dx",
        }

 

couple times, but i need it like this:

        self.statusPlusCommandDict={
            "HTH" : "/stat ht ( entered value e.g. 20)",
            "INT" : "/stat iq ( entered value e.g. 20)",
            "STR" : "/stat st ( entered value e.g. 20)",
            "DEX" : "/stat dx ( entered value e.g. 20)",
        }

 

Just look for def ChooseCountPlusStatConfirm(self, statusKey):  in my uiCharacter :unsure:

Share this post


Link to post
Share on other sites
  • 0

It's ok 

problem is   for i in xrange(count):  net.SendChatPacket(statusPlusCommand)

 

of course it makes a crash because you're repeating the command with hight speed.

 

Best solution is doing from srv side... you pass from python the command with the count and do getstat=getstat+count;  so you can send a command only 1 time.

Share this post


Link to post
Share on other sites
  • 0
vor 4 Minuten schrieb WeedHex:

It's ok 

problem is   for i in xrange(count):  net.SendChatPacket(statusPlusCommand)

 

of course it makes a crash because you're repeating the command with hight speed.

 

Best solution is doing from srv side... you pass from python the command with the count and do getstat=getstat+count;  so you can send a command only 1 time.

 

That's exactly what I want, could you help me? I really don't understand Python at all..

 

I knew what cause the crash i dont need to repeat the command, my command has a second argument now, im able to distribute all without repeating..

:D

Share this post


Link to post
Share on other sites
  • 0
Gerade eben schrieb WeedHex:

Show us 

ACMD(do_stat)

Bro, my command is working :D

 

I dont need to change sth. in my command, i already did that. If i type in /state st (value) it works.

 

i only need to adapt the python-code.. :(

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

I need to know the changes on  CPP to adjust the python...

Tell me just the arguments that c++ takes from py.

 

You made a new argument for  iQnt  ??

  • Confused 1

Share this post


Link to post
Share on other sites
  • 0
vor 9 Minuten schrieb WeedHex:

I need to know the changes on  CPP to adjust the python...

Tell me just the arguments that c++ takes from py.

 

You made a new argument for  iQnt  ??

ACMD(do_stat)
{
	char arg1[256], arg2[256];
	two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2));

	if (!*arg1)
		return;

	int iStatUp = 1;
	if (*arg2)
		iStatUp = atoi(arg2);

	if (ch->IsPolymorphed())
	{
		ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("µÐ°© Áß¿¡´Â ´É·ÂÀ» ¿Ã¸± ¼ö ¾ø½À´Ï´Ù."));
		return;
	}

	if (ch->GetPoint(POINT_STAT) < iStatUp)
		iStatUp = ch->GetPoint(POINT_STAT);

	BYTE idx = 0;
	
	if (!strcmp(arg1, "st"))
		idx = POINT_ST;
	else if (!strcmp(arg1, "dx"))
		idx = POINT_DX;
	else if (!strcmp(arg1, "ht"))
		idx = POINT_HT;
	else if (!strcmp(arg1, "iq"))
		idx = POINT_IQ;
	else
		return;

	if ((ch->GetRealPoint(idx) + iStatUp) > MAX_STAT)
		iStatUp = MAX_STAT - ch->GetRealPoint(idx);

	if (iStatUp < 1)
		return;

	ch->SetRealPoint(idx, ch->GetRealPoint(idx) + iStatUp);
	ch->SetPoint(idx, ch->GetPoint(idx) + iStatUp);
	ch->ComputePoints();
	ch->PointChange(idx, 0);

	if (idx == POINT_IQ)
	{
		ch->PointChange(POINT_MAX_HP, 0);
	}
	else if (idx == POINT_HT)
	{
		ch->PointChange(POINT_MAX_SP, 0);
	}

	ch->PointChange(POINT_STAT, -iStatUp);
	ch->ComputePoints();
}

 

Share this post


Link to post
Share on other sites
  • 0

Replace:

if count > 1:
	for i in xrange(count):
		net.SendChatPacket(statusPlusCommand)

To:

if count > 1:
	net.SendChatPacket("%s %s" % (statusPlusCommand, count))

My test [without your CMD source edit]
shouldwork.PNG

If it doesn't work, change second %s to %d because you have integer convert set. [count = int(self.inputDialog.GetText())]

  • Thanks 1

Share this post


Link to post
Share on other sites
  • 0
vor 19 Minuten schrieb Nirray:

Replace:


if count > 1:
	for i in xrange(count):
		net.SendChatPacket(statusPlusCommand)

To:


if count > 1:
	net.SendChatPacket("%s %s" % (statusPlusCommand, count))

My test [without your CMD source edit]
shouldwork.PNG

If it doesn't work, change second %s to %d because you have integer convert set. [count = int(self.inputDialog.GetText())]

 

Thank you very much man!

 

I adapted the Code, now it works as i wanted ! :wub:

  • Like 1

Share this post


Link to post
Share on other sites

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.

×