Jump to content
  • 0

Party Checker (Job)


Question

Recommended Posts

Posted

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

Posted

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 !";
...

Posted

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?

Posted

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    {

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

Posted

@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 !";

Posted (edited)

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

@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;
}

Posted

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
Posted

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.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...