Jump to content
  • 0
Sign in to follow this  
nasagnilac

Duplicate Class Checking NPC HELP

Question

I made a script where can check duplicate class in a party.

 

Disable Class

Priest - High Priest

Monk - Champion

 

Enable Class

Priest - Monk

High Priest - Champion

 

 

Here is the code.

 

gonryun,26,112,4	script	Test	1_M_PUBMASTER,{ // get the charID and accountID of character's party membersgetpartymember getcharid(1), 1;getpartymember getcharid(1), 2;if ( $@partymembercount != .register_num ) {	mes "Please form a party of "+ .register_num +" to continue";	close;}// loop through both and use 'isloggedin' to count online party membersfor ( set .@i, 0; .@i < $@partymembercount; set .@i, .@i +1 ){	if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) )		attachrid ($@partymemberaid[.@i]);			for ( set .@p, 0; .@p < getarraysize(.jobs); set .@p, .@p +1 )				if(BaseJob == .jobs[.@p])					// Problem 1 cant set a new value for each variables in .class$.					set getd("+.class$[.@p]+"),getd("+.class$[.@p]+") + 1;						// this part is to check if the variable value changed.			mes ""+.@priest+" ";		close;		}									//for ( set .@l, 0; .@l < getarraysize(.class$); set .@l, .@l +1 ){//			if(getd(.class$[.@l]) == 2){//				dispbottom "Your party has a duplicate job class of "+jobname(.jobs$[.@l])+".";//			}				//}		OnInit:set .register_num, 2; // How many party members are required?setarray .jobs,"8";setarray .class$,".@priest";end;}

 

All red text is the problem. Please help me,

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
prontera,155,185,5	script	kdjshfksdjfh	1_F_MARIA,{//	get party info	getpartymember getcharid(1), 1;	getpartymember getcharid(1), 2;//	check party amount	if ( $@partymembercount < 4 ) {		mes "you have to form at least 4 party members";		close;	}//	check online count	for ( .@i = 0; .@i < $@partymembercount; ++.@i )		if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) )			.@online++;	if ( .@online < 4 ) { // less than 4 people online		mes "your party need at least 4 party member online";		close;	}//	save the attachrd RID. going to use attachrid this time	.@origin = getcharid(3);//	loop through these members and check for duplicate class	for ( .@i = 0; .@i < $@partymembercount; ++.@i ) {		if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) ) {			attachrid $@partymemberaid[.@i];			for ( .@j = 0; .@j < .@checkjobarraysize; ++.@j ) { // loop with saved job ID				if ( .@checkjobarray[.@j] == BaseJob ) { // if found					.@duplicatejob[.@duplicatejobsize++] = BaseJob;					break; // break if found duplicates				}			}			.@checkjobarray[.@checkjobarraysize++] = BaseJob;		}	}//	attachrid back ... surely you don't want the message display on other party members	attachrid .@origin;	if ( .@duplicatejobsize ) { // if there are duplicate jobs, the array size is more than 0		mes "found duplicate job in your party";		for ( .@i = 0; .@i < .@duplicatejobsize; ++.@i )			mes "BaseJob = "+ jobname( .@duplicatejob[.@i] );		close;	}//	OK !	warpparty "prontera", 155,185, getcharid(1);	end;}

Share this post


Link to post
Share on other sites
  • 0

I remember I did this before on rathena forum,

however I'm unable to retrieve it due to their forum can't do advance forum search

prontera,155,185,5	script	kdjshfksdjfh	1_F_MARIA,{//	get party info	getpartymember getcharid(1), 1;	getpartymember getcharid(1), 2;//	check party amount	if ( $@partymembercount < 4 ) {		mes "you have to form at least 4 party members";		close;	}//	check online count	for ( .@i = 0; .@i < $@partymembercount; ++.@i )		if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) )			.@online++;	if ( .@online < 4 ) { // less than 4 people online		mes "your party need at least 4 party member online";		close;	}//	save the attachrd RID. going to use attachrid this time	.@origin = getcharid(3);//	loop through these members and check for duplicate class	for ( .@i = 0; .@i < $@partymembercount; ++.@i ) {		if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) ) {			attachrid $@partymemberaid[.@i];			for ( .@j = 0; .@j < .@checkjobarraysize; ++.@j ) { // loop with saved job ID				if ( .@checkjobarray[.@j] == BaseJob ) { // if found					.@duplicatejob = BaseJob;					break; // break				}			}			if ( .@j < .@checkjobarraysize ) // still loop within all party member, break;				break;			.@checkjobarray[.@checkjobarraysize++] = BaseJob;		}	}//	attachrid back ... surely you don't want the message display on other party members	attachrid .@origin;	if ( .@checkjobarraysize != .@online ) { // if the number of different jobs is not equal to online party members count		mes "found duplicate job in your party";		mes "BaseJob = "+ jobname( .@duplicatejob );		close;	}//	OK !	warpparty "prontera", 155,185, getcharid(1);	end;}
Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

Thnx.. its working..



how about adding a loop here?

 

 

        mes "BaseJob = "+ jobname( .@duplicatejob );

 

what if the jobs are 2 priest 2 monk? There should be a 2 result that 2 same job is in the party.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.