Jump to content
  • 0

Party Checker (Job)


kyeme

Question


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  164
  • Reputation:   12
  • Joined:  03/08/12
  • Last Seen:  

I need a Party checker NPC script for not allowing same Job in the Party. Can anyone help me?

Link to comment
Share on other sites

Recommended Posts


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  118
  • Reputation:   6
  • Joined:  01/25/12
  • Last Seen:  

try this

prontera,156,180,4 script Party Checker 100,{
if(getcharid(1) != 1) {
mes "Sorry you don't have party.";
close;
}
getpartymember getcharid(1),1;
getpartymember getcharid(1),2;

for( set .@i,0; .@i<$@partymembercount && !.@classdupe; set .@i,.@i+1 ) {
 if (isloggedin($@partymemberaid[.@i],$@partymembercid[.@i]) ) {
  attachrid($@partymemberaid[.@i]); set .@comparemember1, Class;
  attachrid($@partymemberaid[.@i+1]); set .@comparemember2, Class;
   if(.@comparemember2 == .@comparemember1)
 set .@classdupe, 1;
  detachrid;
 }
}
if(.@classdupe) {
mes "Sorry there is someone in your party with the same Class.";
close;
}
mes "Good your ready to go";
close;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  164
  • Reputation:   12
  • Joined:  03/08/12
  • Last Seen:  

Thank you deathscythe13 /thx

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  323
  • Reputation:   9
  • Joined:  11/19/11
  • Last Seen:  

bump not working on me he say always "Sorry you don't have party."

I have a party with same job.

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

change

if(getcharid(1) != 1) {

into

if(!getcharid(1) ) {

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

The script above can't work :

- If the party is : mage, archer, swordman, mage, it will not find the 2 mages.

- Can have problem with offline member (Class will throw an error ?)

- What about a user disconnect before the test and reconnect after ?

So here a function (not tested), I just write on the fly, should do the work.

function	script	party_has_duplicate_job
{
set .@party_id, getarg( 0, getcharid(1) );

// Need to have a party.
if ( .@party_id != 1 )
{
	return -1;
}

// Loading party members variables
getpartymember getcharid(1),1;
getpartymember getcharid(1),2;

// Keep rid attached.
set .@rid, playerattached();


// Check all members
for ( set .@i,0; .@i<$@partymembercount; set .@i, .@i+1 )
{

	// Online user
	if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i]) )
	{
		// Attach the member to access "Class"
		attachrid( $@partymemberaid[.@i] );
		if ( compare( .@tmp_class$ + "|", "|" + Class + "|" ) )
		{
			if ( .@rid )
				attachrid(.@rid);
			else
				detachrid;
			return 1;
		}
		set .@tmp_class$, .@tmp_class$ + "|" + Class;
	}

	// Offline user (use sql)
	else
	{
		set .@sql$, .@sql$ + ( .@sql_i ? "OR " : "" ) "`char_id`='" + $@partymembercid[.@i] + "' ";
		set .@sql_i, .@sql_i + 1;
	}
}

// SQL for offline users
if ( getstrlen(.@sql$) )
{
	// get class from offline members
	set .@count, query_sql("SELECT `class` FROM `char` WHERE " + .@sql$, .@class );

	// Check the class.
	for ( set .@i, 0; .@i<.@count; set .@i, .@i+1 )
	{
		if ( compare( .@tmp_class$ + "|", "|" + .@class[.@i] + "|" ) )
		{
			if ( .@rid )
				attachrid(.@rid);
			else
				detachrid;
			return 1;
		}
		set .@tmp_class$, .@tmp_class$ + "|" + .@class[.@i];
	}
}


// Restore RID.
if ( .@rid )
	attachrid(.@rid);
else
	detachrid;

return 0;
}

Example of used:

if ( callfunc("party_has_duplicate_job") ) {
   mes "It seems that someone in the party has the same class than another member. Please check again the requirements...";
   close;
}
mes "OK, no problem with your party, let's go !";
...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  92
  • Topics Per Day:  0.02
  • Content Count:  354
  • Reputation:   22
  • Joined:  11/17/11
  • Last Seen:  

The script above can't work :

- If the party is : mage, archer, swordman, mage, it will not find the 2 mages.

- Can have problem with offline member (Class will throw an error ?)

- What about a user disconnect before the test and reconnect after ?

So here a function (not tested), I just write on the fly, should do the work.

function	script	party_has_duplicate_job
{
set .@party_id, getarg( 0, getcharid(1) );

// Need to have a party.
if ( .@party_id != 1 )
{
	return -1;
}

// Loading party members variables
getpartymember getcharid(1),1;
getpartymember getcharid(1),2;

// Keep rid attached.
set .@rid, playerattached();


// Check all members
for ( set .@i,0; .@i<$@partymembercount; set .@i, .@i+1 )
{

	// Online user
	if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i]) )
	{
		// Attach the member to access "Class"
		attachrid( $@partymemberaid[.@i] );
		if ( compare( .@tmp_class$ + "|", "|" + Class + "|" ) )
		{
			if ( .@rid )
				attachrid(.@rid);
			else
				detachrid;
			return 1;
		}
		set .@tmp_class$, .@tmp_class$ + "|" + Class;
	}

	// Offline user (use sql)
	else
	{
		set .@sql$, .@sql$ + ( .@sql_i ? "OR " : "" ) "`char_id`='" + $@partymembercid[.@i] + "' ";
		set .@sql_i, .@sql_i + 1;
	}
}

// SQL for offline users
if ( getstrlen(.@sql$) )
{
	// get class from offline members
	set .@count, query_sql("SELECT `class` FROM `char` WHERE " + .@sql$, .@class );

	// Check the class.
	for ( set .@i, 0; .@i<.@count; set .@i, .@i+1 )
	{
		if ( compare( .@tmp_class$ + "|", "|" + .@class[.@i] + "|" ) )
		{
			if ( .@rid )
				attachrid(.@rid);
			else
				detachrid;
			return 1;
		}
		set .@tmp_class$, .@tmp_class$ + "|" + .@class[.@i];
	}
}


// Restore RID.
if ( .@rid )
	attachrid(.@rid);
else
	detachrid;

return 0;
}

Example of used:

if ( callfunc("party_has_duplicate_job") ) {
mes "It seems that someone in the party has the same class than another member. Please check again the requirements...";
close;
}
mes "OK, no problem with your party, let's go !";
...

Can you make this script + limit the party members to seven only?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  323
  • Reputation:   9
  • Joined:  11/19/11
  • Last Seen:  

Not working sir.

post-389-0-06293000-1341913925_thumb.jpg

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

Can you make this script + limit the party members to seven only?
Just 7 members or 1 to 7 members ?
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  323
  • Reputation:   9
  • Joined:  11/19/11
  • Last Seen:  

Im trying....

Still not working i need this script. bump

post-389-0-26551600-1341918140_thumb.jpg

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

Im trying....

Still not working i need this script. bump

post-389-0-26551600-1341918140_thumb.jpg

Maybe due to the header "{" in the next line, try replace this:

function    script    party_has_duplicate_job
{

With:

function    script    party_has_duplicate_job    {

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  69
  • Topics Per Day:  0.02
  • Content Count:  592
  • Reputation:   31
  • Joined:  11/14/11
  • Last Seen:  

- waiting for this to finish.. :D this will be a good start for RPC 7vs 7 event

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  323
  • Reputation:   9
  • Joined:  11/19/11
  • Last Seen:  

Yes ill try this later. im on work i hope it works this is my last script to finish my rwc organizer automated.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  69
  • Topics Per Day:  0.02
  • Content Count:  592
  • Reputation:   31
  • Joined:  11/14/11
  • Last Seen:  

http://rathena.org/board/topic/66873-party-vs-party/

= check this script i found on eAthena

- its check party but not that good

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  323
  • Reputation:   9
  • Joined:  11/19/11
  • Last Seen:  

Thanks but i have already party registration this script is 1 missing :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  92
  • Topics Per Day:  0.02
  • Content Count:  354
  • Reputation:   22
  • Joined:  11/17/11
  • Last Seen:  

Can you make this script + limit the party members to seven only?
Just 7 members or 1 to 7 members ?

Yup just 7 members fixed. not 1 to 7. I'll try to make some too, but just in case could you make it possible.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  323
  • Reputation:   9
  • Joined:  11/19/11
  • Last Seen:  

Error again.

post-389-0-13799700-1341927967_thumb.jpg

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

@Khaii

This should fixed the problem :

function	script	party_has_duplicate_job	{
set .@party_id, getarg( 0, getcharid(1) );

// Need to have a party.
if ( .@party_id != 1 )
{
		return -1;
}

// Loading party members variables
getpartymember .@party_id,1;
getpartymember .@party_id,2;

// Keep rid attached.
set .@rid, playerattached();


// Check all members
for ( set .@i,0; .@i<$@partymembercount; set .@i, .@i+1 )
{

	// Online user
	if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i]) )
	{
		// Attach the member to access "Class"
		attachrid( $@partymemberaid[.@i] );
		if ( compare( .@tmp_class$ + "|", "|" + Class + "|" ) )
		{
			if ( .@rid )
				attachrid(.@rid);
			else
				detachrid;
			return 1;
		}
		set .@tmp_class$, .@tmp_class$ + "|" + Class;
	}

	// Offline user (use sql)
	else
	{
		set .@sql$, .@sql$ + ( .@sql_i ? "OR " : "" ) + "`char_id`='" + $@partymembercid[.@i] + "' ";
		set .@sql_i, .@sql_i + 1;
	}
}

// SQL for offline users
if ( getstrlen(.@sql$) )
{
	// get class from offline members
	set .@count, query_sql("SELECT `class` FROM `char` WHERE " + .@sql$, .@class );

	// Check the class.
	for ( set .@i, 0; .@i<.@count; set .@i, .@i+1 )
	{
		if ( compare( .@tmp_class$ + "|", "|" + .@class[.@i] + "|" ) )
		{
			if ( .@rid )
				attachrid(.@rid);
			else
				detachrid;
			return 1;
		}
		set .@tmp_class$, .@tmp_class$ + "|" + .@class[.@i];
	}
}


// Restore RID.
if ( .@rid )
	attachrid(.@rid);
else
	detachrid;

return 0;
}

@Emnaj

if ( callfunc("party_has_duplicate_job") ) {
mes "It seems that someone in the party has the same class than another member. Please check again the requirements...";
close;
}

if ( $@partymembercount != 7 ) {
mes "You have to be 7 on the team.";
close;
}

mes "OK, no problem with your party, let's go !";

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  92
  • Topics Per Day:  0.02
  • Content Count:  354
  • Reputation:   22
  • Joined:  11/17/11
  • Last Seen:  

@khaii

have you tried this?

function<tab>script<tab>party_has_duplicate_job<tab>{
	set .@party_id, getarg( 0, getcharid(1) );
	// Need to have a party.
	if ( .@party_id != 1 )
	{
			return -1;
	}
	// Loading party members variables
	getpartymember getcharid(1),1;
	getpartymember getcharid(1),2;
	// Keep rid attached.
	set .@rid, playerattached();

	// Check all members
	for ( set .@i,0; .@i<$@partymembercount; set .@i, .@i+1 )
	{
			// Online user
			if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i]) )
			{
					// Attach the member to access "Class"
					attachrid( $@partymemberaid[.@i] );
					if ( compare( .@tmp_class$ + "|", "|" + Class + "|" ) )
					{
							if ( .@rid )
									attachrid(.@rid);
							else
									detachrid;
							return 1;
					}
					set .@tmp_class$, .@tmp_class$ + "|" + Class;
			}
			// Offline user (use sql)
			else
			{
					set .@sql$, .@sql$ + ( .@sql_i ? "OR " : "" ) "`char_id`='" + $@partymembercid[.@i] + "' ";
					set .@sql_i, .@sql_i + 1;
			}
	}
	// SQL for offline users
	if ( getstrlen(.@sql$) )
	{
			// get class from offline members
			set .@count, query_sql("SELECT `class` FROM `char` WHERE " + .@sql$, .@class );
			// Check the class.
			for ( set .@i, 0; .@i<.@count; set .@i, .@i+1 )
			{
					if ( compare( .@tmp_class$ + "|", "|" + .@class[.@i] + "|" ) )
					{
							if ( .@rid )
									attachrid(.@rid);
							else
									detachrid;
							return 1;
					}
					set .@tmp_class$, .@tmp_class$ + "|" + .@class[.@i];
			}
	}

	// Restore RID.
	if ( .@rid )
			attachrid(.@rid);
	else
			detachrid;
	return 0;
}

Edited by Emnaj
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  323
  • Reputation:   9
  • Joined:  11/19/11
  • Last Seen:  

@Emnaj , KeyWorld

Its working now thank you very much! for fast reply.

Now my problem is i have a 2 jobs not same. look the picture

post-389-0-56905300-1341936029_thumb.jpg

prontera,153,167,3	script	War Organizer	89,{

	mes "[War Organizer]";
	mes "Welcome "+strcharinfo(0)+"!";
	mes "I am the War Arena Organizer";
	menu "Choose the Room Battle",L_Choose;

L_Choose:
	menu "Arena 3 (Open)",L_Arena3;

L_Arena3:
next;
mes "[War Organizer]";
if ( callfunc("party_has_duplicate_job") ) {
	mes "It seems that someone in the party has the same class than another member. Please check again the requirements...";
	close;
}

if ( $@partymembercount != 2 ) {
	mes "You have to be 2 on the team.";
	close;
}

mes "OK, no problem with your party, let's go !";
warp "quiz_02",37,63;
end;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  92
  • Topics Per Day:  0.02
  • Content Count:  354
  • Reputation:   22
  • Joined:  11/17/11
  • Last Seen:  

i have not yet tested this but I will reply as soon as i can,

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  323
  • Reputation:   9
  • Joined:  11/19/11
  • Last Seen:  

bump!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

My fault, I copy deathscythe13's base script without reading :

function    script    party_has_duplicate_job    {
   set .@party_id, getarg( 0, getcharid(1) );

   // Need to have a party.
   if ( !.@party_id )
   {
           return -1;
   }

   // Loading party members variables
   getpartymember .@party_id, 1;
   getpartymember .@party_id, 2;

   // Keep rid attached.
   set .@rid, playerattached();


   // Check all members
   for ( set .@i,0; .@i<$@partymembercount; set .@i, .@i+1 )
   {

       // Online user
       if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i]) )
       {
           // Attach the member to access "Class"
           attachrid( $@partymemberaid[.@i] );
           if ( compare( .@tmp_class$ + "|", "|" + Class + "|" ) )
           {
               if ( .@rid )
                   attachrid(.@rid);
               else
                   detachrid;
               return 1;
           }
           set .@tmp_class$, .@tmp_class$ + "|" + Class;
       }

       // Offline user (use sql)
       else
       {
           set .@sql$, .@sql$ + ( .@sql_i ? "OR " : "" ) + "`char_id`='" + $@partymembercid[.@i] + "' ";
           set .@sql_i, .@sql_i + 1;
       }
   }

   // SQL for offline users
   if ( getstrlen(.@sql$) )
   {
       // get class from offline members
       set .@count, query_sql("SELECT `class` FROM `char` WHERE " + .@sql$, .@class );

       // Check the class.
       for ( set .@i, 0; .@i<.@count; set .@i, .@i+1 )
       {
           if ( compare( .@tmp_class$ + "|", "|" + .@class[.@i] + "|" ) )
           {
               if ( .@rid )
                   attachrid(.@rid);
               else
                   detachrid;
               return 1;
           }
           set .@tmp_class$, .@tmp_class$ + "|" + .@class[.@i];
       }
   }


   // Restore RID.
   if ( .@rid )
       attachrid(.@rid);
   else
       detachrid;

   return 0;
}

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  323
  • Reputation:   9
  • Joined:  11/19/11
  • Last Seen:  

Its working now thank you! i have organizer rwc now.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  111
  • Topics Per Day:  0.02
  • Content Count:  573
  • Reputation:   20
  • Joined:  11/19/11
  • Last Seen:  

Its working now thank you! i have organizer rwc now.

will you share it ? :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  92
  • Topics Per Day:  0.02
  • Content Count:  354
  • Reputation:   22
  • Joined:  11/17/11
  • Last Seen:  

its not quite easy to make one but if he is willing to share it it would be great for the others.

clue : make the KVM scripts as a pattern then add the partychecker. at least thats what i did.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...