Jump to content
  • 0

Getting average level of Online party members.


crazyarashi

Question


  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

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.
			                               
                                               
                                               


 

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   703
  • Joined:  12/21/14
  • Last Seen:  

maybe because you misspell partmemberaid at readparam(BaseLevel,.$@partmemberaid[.@i]) or just in the post ?

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

ah its just in the post :))

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  342
  • Reputation:   169
  • Joined:  02/25/12
  • Last Seen:  

.@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
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

@Alayne Apparently I tried that kind of code a while ago and no hope for it. I just tried yours too it ended up in the same results it gives me 0
with no errors in console.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  342
  • Reputation:   169
  • Joined:  02/25/12
  • Last Seen:  

Strange...What does it give as result for totalLevel and online variables?

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   431
  • Joined:  01/26/16
  • Last Seen:  

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.

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

It all returns 0 :< kinda odd w

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

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

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  342
  • Reputation:   169
  • Joined:  02/25/12
  • Last Seen:  

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.

Link to comment
Share on other sites

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   703
  • Joined:  12/21/14
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  342
  • Reputation:   169
  • Joined:  02/25/12
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   703
  • Joined:  12/21/14
  • Last Seen:  

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

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

Going to retest again later thank you for your time testing it. 

Link to comment
Share on other sites

  • 0

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

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