Jump to content
  • 0

Getting average level of Online party members.


Question

Posted

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,.$@partmemberaid[.@i]) but it didnt work somehow. Thank you in advance
 

.@party_id = getcharid(1);
	if(.@party_id){
		getpartymember( .@party_id,2 );
		getpartymember( .@party_id,1 );
		for( .@i = 0; .@i < $@partymembercount; .@i++ )
     	if(isloggedin($@partymemberaid[.@i],$@partymembercid[.@i])) .@online += 1;
			if(attachrid($@partymemberaid[.@i])) {
            	//= Currently stuck what to put here.
			                               
                                               
                                               


 

14 answers to this question

Recommended Posts

  • 0
Posted (edited)
.@party_id = getcharid(1);
	if(.@party_id){
		.@totalLevel = 0;
		getpartymember( .@party_id,2 );
		getpartymember( .@party_id,1 );
		for( .@i = 0; .@i < $@partymembercount; .@i++ )
        {
     		if(isloggedin($@partymemberaid[.@i],$@partymembercid[.@i])) 
            {
                .@online += 1;
				if(attachrid($@partymemberaid[.@i])) {
        	    	.@totalLevel += BaseLevel;
        	    }
            }   
        }
        .@averagLvl = .@totalLevel / .@online;
     }
			                               

Something like that.

Edited by Alayne
  • 0
Posted

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.

  • 0
Posted
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

  • 0
Posted

AHHHH found the issue I think!

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

		getpartymember( .@party_id,2 );
		getpartymember( .@party_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. $@partymemberaid is set.

You're calling GPM with flag 1. $@partymembercid is set, but maybe $@partymemberaid 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.

  • 0
Posted (edited)

it's working for me x.X

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

 

Edited by sader1992
  • Upvote 1
  • 0
Posted

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 ^^

  • 0
Posted (edited)
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
  • 0
Posted
.@aid = getcharid(3);
getpartymember getcharid(1), 2;
.@count = $@partymembercount;
copyarray(.@pt_aid, $@partymemberaid, .@count);
for (.@i = 0; .@i < .@count; .@i++)
	if (attachrid(.@pt_aid[.@i])) {
		.@total_base_lv += BaseLevel;
		.@count++;
	}
attachrid(.@aid);
mes "average level of your party are "+ (.@total_base_lv / .@count);
close;

you can try like this...

  • Upvote 1

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