Jump to content
  • 0
crazyarashi

Getting average level of Online party members.

Question

Hi good day rathena I'm currently stuck on the stuff i'm trying to make I basically want to take the average level of the online party members. I tried to use readparam(BaseLevel,[email protected][[email protected]]) but it didnt work somehow. Thank you in advance
 

[email protected]_id = getcharid(1);
	if([email protected]_id){
		getpartymember( [email protected]_id,2 );
		getpartymember( [email protected]_id,1 );
		for( [email protected] = 0; [email protected] < [email protected]; [email protected]++ )
     	if(isloggedin([email protected][[email protected]],[email protected][[email protected]])) [email protected] += 1;
			if(attachrid([email protected][[email protected]])) {
            	//= Currently stuck what to put here.
			                               
                                               
                                               


 

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0
[email protected]_id = getcharid(1);
	if([email protected]_id){
		[email protected] = 0;
		getpartymember( [email protected]_id,2 );
		getpartymember( [email protected]_id,1 );
		for( [email protected] = 0; [email protected] < [email protected]; [email protected]++ )
        {
     		if(isloggedin([email protected][[email protected]],[email protected][[email protected]])) 
            {
                [email protected] += 1;
				if(attachrid([email protected][[email protected]])) {
        	    	[email protected] += BaseLevel;
        	    }
            }   
        }
        [email protected] = [email protected] / [email protected];
     }
			                               

Something like that.

Edited by Alayne
Link to comment
Share on other sites

  • 0
2 minutes ago, Secrets said:

The cleanest way imo is coding a custom script command to get the average level so you don't have to go through the trouble that may be caused by attachrid.

I guess that's the reasonable choice at the moment thanks

Link to comment
Share on other sites

  • 0

AHHHH found the issue I think!

Isn't it linked to the fact you're using 

		getpartymember( [email protected]_id,2 );
		getpartymember( [email protected]_id,1 );

At the same time? I don't know the source, but aren't the array cleaning between two command call? Like this:

You're calling GPM with flag 2. [email protected] is set.

You're calling GPM with flag 1. [email protected] is set, but maybe [email protected] is cleaned. Therefor, the loop to check if isloggedin always return false / incorrect values? 

Did you try adding debugmes with used ids? Can't check it myself.

Link to comment
Share on other sites

  • 0

it's working for me x.X

prontera,153,180,5	script	PARTY_AV_TEST	444,{
	if(getcharid(1)){
		getpartymember getcharid(1),1;
		copyarray [email protected]charID, [email protected]partymembercid, [email protected]partymembercount;
		getpartymember getcharid(1),2;
		copyarray [email protected]accountID, [email protected]partymemberaid, [email protected]partymembercount;
		for([email protected]i=0;[email protected]i<getarraysize([email protected]charID);[email protected]i++){
			if(isloggedin([email protected]accountID[[email protected]i],[email protected]charID[[email protected]i])){
				[email protected]blvl += readparam(BaseLevel,[email protected]charID[[email protected]i]);
			}   
		}
		debugmes "" + [email protected]blvl;
	}
}

 

Edited by sader1992
  • Upvote 1
Link to comment
Share on other sites

  • 0
6 minutes ago, Alayne said:

Yep, cause you're saving the array on temp array before calling the method again I guess.

Did you try not saving it and using directly the results of getpartymember. Can bet that you'll have the same issue ^^

nope but the array wont be overwritten anyway with this small script

however i would like to get the error xD , i would test that latter

Edited by sader1992
Link to comment
Share on other sites

  • 0
[email protected] = getcharid(3);
getpartymember getcharid(1), 2;
[email protected] = [email protected];
copyarray([email protected]_aid, [email protected], [email protected]);
for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
	if (attachrid([email protected]_aid[[email protected]])) {
		[email protected]_base_lv += BaseLevel;
		[email protected]++;
	}
attachrid([email protected]);
mes "average level of your party are "+ ([email protected]_base_lv / [email protected]);
close;

you can try like this...

  • Upvote 1
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...

Important Information

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