Jump to content

question about second argument in python command


Recommended Posts

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://metin2.download/picture/RIn4R7mpKto1CyKwvfgEEfhZbVq7CgUo/.gif


greetings

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

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:

Link to comment
Share on other sites

  • Premium

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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();
}

 

Link to comment
Share on other sites

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())]

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1

I completely abandoned working on the files for this game. I do not respond to private messages.

.png

Link to comment
Share on other sites

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:

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1
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.