Jump to content
  • 0
Sign in to follow this  
Lord Ganja

Top 10 PK Killers with lists of characters

Question

Can anyone create an npc script for me that shows the top 10 pk killers. I just don't know how to script using query_sql.

 

The variable of the point is #PK_Points(account based) and the npc will also show the character names of the account

 

This is the explanation of the picture below

[ Top 10 PK Killers ]1. (How much point does this account id has)// here the list of the character names of the account id and if the character is online or offline - character name [online/offline] - character name 2 [online/offline]and so on.. .

post-1008-0-59297800-1441304185_thumb.png

 

 

Thanks in advance!  :thx:

Edited by Lord Ganja

Share this post


Link to post
Share on other sites

17 answers to this question

Recommended Posts

  • 0

 

@@Angelmelody -

 

Thanks for the script. :no1:

 

Anyway i'm having this error whenever I clicked the npc

 

[Warning]: script:getelementofarray: index out of range (-1)[Debug]: Data: variable name='.@value' index=0[Debug]: Source (NPC): Most Wanted List at prontera (141,177)

index goes to -1 XD, now should be fixed ...try again...

	.@nb = query_sql("select `name`, r.value, `online` from `char` as c INNER JOIN( select `account_id`, `value` from `acc_reg_num_db` WHERE `key` ='#PK_Points' AND `value` > 0 GROUP BY `account_id` order by `value` desc limit 10) as r on c.account_id = r.account_id order by r.value desc,char_num asc", .@name$, .@value, .@online);	if(.@nb) mes "Top "+( ++.@j)+" - Points: "+.@value[.@i];	for( .@i = 0; .@i < .@nb; .@i++ ) {		if(.@i ) {			if(.@value[.@i] != .@value[.@i-1] ){				mes "Top "+(++.@j)+" - Points: "+.@value[.@i];			}		}		mes " > "+ .@name$[.@i] +" "+( ( .@online[.@i] )? "^00FF00[Online]" : "^FF0000[Offline]" )+"^000000";	}
Edited by Angelmelody

Share this post


Link to post
Share on other sites
  • 0

becuz if you use account base, '#' sometimes may not produce correct character names since rid means  account id :v

Maybe it might work like selecting the '#PK_Points' variable first to set the account_id with the highest #PK_points,

 

Then when the account id is already set, there goes the character lists..

If you check this POST by annieruru, it list down the char names of the searched player. Maybe this can help creating the script?

I just don't know how to do query_sql. can't try anything with this :/

prontera,157,178,5    script    Sample    757,{    if ( getgmlevel() < 80 ) end;    mes "Input Player Name";    if ( input( .@input$, 4, 23 ) ) {        mes "invalid name length";        close;    }    if ( set( .@nb, query_sql( "select name, online from `char` where account_id = ( select account_id from `char` where name = '"+ escape_sql(.@input$) +"' ) order by char_num", .@name$, .@online ) ) )        for ( set .@i, 0; .@i < .@nb; set .@i, .@i +1 )            mes " > "+ .@name$[.@i] +" "+( ( .@online[.@i] )? "^00FF00[Online]" : "^FF0000[Offline]" )+"^000000";    else        mes "No character found";    close;}

Share this post


Link to post
Share on other sites
  • 0

easy to make this script but that i told you, but more query :v with # account_base

 

secondly, select query in account_reg_number is not real time update

Share this post


Link to post
Share on other sites
  • 0

easy to make this script but that i told you, but more query :v with # account_base

 

secondly, select query in account_reg_number is not real time update

It's okay. xD

 

Can you make the script for me? please?

 

EDIT: I tried and make it on my own but it's not working well ( I already expected that xD)

It only shows the top 1. not the others.

 

The error I received:

[Debug]: Function: mes (1 parameter):[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Data: string value="Top 1 - Points: 1458"[Debug]: Source (NPC): test at prontera (141,177)

 

The script:

	.@nb = query_sql("SELECT `account_id`, `value` FROM `acc_reg_num_db` WHERE `key`='#PK_Points' ORDER BY `value` DESC LIMIT 10", .@aid, .@value);	.@nb2 = query_sql("SELECT `name`, `online` FROM `char` WHERE `account_id` ='"+.@aid+"' ORDER BY `char_num`", .@name$, .@online );		for( .@a = 0; .@a < 10; .@a++ ) {			mes "Top "+(.@a + 1)+" - Points: "+.@value[.@a];			for( .@i = 0; .@i < .@nb2; .@i++ ) {				mes " > "+ .@name$[.@i] +" "+( ( .@online[.@i] )? "^00FF00[Online]" : "^FF0000[Offline]" )+"^000000";			}			sleep 10;		}
Edited by Lord Ganja

Share this post


Link to post
Share on other sites
  • 0

that error was caused by  sleep

Thank you. I already get rid of the error.  :no1:

 

What im encountering now is it prints only the char names of the top 1..

Below top 2,3,4 and so on.. The names are the same as top 1.

 

Does the script only saves and run 1 account id? :hmm:

Share this post


Link to post
Share on other sites
  • 0

 

that error was caused by  sleep

Thank you. I already get rid of the error.  :no1:

 

What im encountering now is it prints only the char names of the top 1..

Below top 2,3,4 and so on.. The names are the same as top 1.

 

Does the script only saves and run 1 account id? :hmm:

 

try this

	.@nb = query_sql("select `name` , r.value, `online` from `char` as c INNER JOIN(select `account_id`, `value` from `acc_reg_num_db` WHERE `key` ='#PK_Points' AND `value` > 0 GROUP BY `account_id` order by `value` desc limit 10) as r on c.account_id = r.account_id order by r.value desc,char_num asc", .@name$, .@value, .@online);	if(.@nb) mes "Top "+( ++.@j)+" - Points: "+.@value[.@i];	for( .@i = 0; .@i < .@nb; .@i++ ) {		if(.@i && .@value[.@i] != .@value[.@i-1] ){			mes "Top "+(++.@j)+" - Points: "+.@value[.@i];		}			mes " > "+ .@name$[.@i] +" "+( ( .@online[.@i] )? "^00FF00[Online]" : "^FF0000[Offline]" )+"^000000";	}
Edited by Angelmelody

Share this post


Link to post
Share on other sites
  • 0

@@Angelmelody -

 

Thanks for the script. :no1:

 

Anyway i'm having this error whenever I clicked the npc

 

[Warning]: script:getelementofarray: index out of range (-1)[Debug]: Data: variable name='.@value' index=0[Debug]: Source (NPC): Most Wanted List at prontera (141,177)
Edited by Lord Ganja

Share this post


Link to post
Share on other sites
  • 0

@@Angelmelody - Works like a charm!!!! :no1:  Thank you so much.

 

Anyway what about if it will only show the online char and disregard the offline one? when no character is online on that account id. it will just show

e.g

Top 1 - Points: 1300> [Offline] // None of the character is online so it will only put one offline but won't put any character nameTop 2 - Points: 1000> Lord Ganja // This is the online character on the account_id. It won't put the offline character namesTop 3 - Points: 800> [Offline]..........

Share this post


Link to post
Share on other sites
  • 0

@@Angelmelody - Works like a charm!!!! :no1:  Thank you so much.

 

Anyway what about if it will only show the online char and disregard the offline one? when no character is online on that account id. it will just show

e.g

Top 1 - Points: 1300> [Offline] // None of the character is online so it will only put one offline but won't put any character nameTop 2 - Points: 1000> Lord Ganja // This is the online character on the account_id. It won't put the offline character namesTop 3 - Points: 800> [Offline]..........

 

 

ok try this..
	.@nb = query_sql("select `name`, r.value, `online` from `char` as c INNER JOIN( select `account_id`, `value` from `acc_reg_num_db` WHERE `key` ='#PK_Points' AND `value` > 0 GROUP BY `account_id` order by `value` desc limit 10) as r on c.account_id = r.account_id order by r.value desc,char_num asc", .@name$, .@value, .@online);	if(.@nb) mes "Top "+( ++.@j)+" - Points: "+.@value[.@i];	for( .@i = 0; .@i < .@nb; .@i++ ) {		if(.@i ) {			if(.@value[.@i] != .@value[.@i-1] ){				if(!.@k){					mes " > [Offline]";				}				mes "Top "+(++.@j)+" - Points: "+.@value[.@i];				.@k = 0;			}		}		if(.@online[.@i]) {			mes " > "+ .@name$[.@i];			.@k++;		}	}

Share this post


Link to post
Share on other sites
  • 0

@@Angelmelody - Thanks again! Anyway the script doesn't show the last entry if the player is offline..

 

It was displayed like this:

Top 1 - Points: 1214> Lord GanjaTop 2 - Points: 68> [Offline]Top 3 - Points:45// And it is now blank here// If they player is only the char name is displayed. but if not online, it's just blank

Share this post


Link to post
Share on other sites
  • 0

 

@@Angelmelody - Thanks again! Anyway the script doesn't show the last entry if the player is offline..

 

It was displayed like this:

Top 1 - Points: 1214> Lord GanjaTop 2 - Points: 68> [Offline]Top 3 - Points:45// And it is now blank here// If they player is only the char name is displayed. but if not online, it's just blank

ok updated :)

	.@nb = query_sql("select `name`, r.value, `online` from `char` as c INNER JOIN( select `account_id`, `value` from `acc_reg_num_db` WHERE `key` ='#PK_Points' AND `value` > 0 GROUP BY `account_id` order by `value` desc limit 10) as r on c.account_id = r.account_id order by r.value desc,char_num asc", .@name$, .@value, .@online);	if(.@nb) mes "Top "+( ++.@j)+" - Points: "+.@value[.@i];	for( .@i = 0; .@i < .@nb; .@i++ ) {		if(.@i ) {			if(.@value[.@i] != .@value[.@i-1] ){				if(!.@k){					mes " > [Offline]";				}				mes "Top "+(++.@j)+" - Points: "+.@value[.@i];				.@k = 0;			}			if(!.@k && .@i == (.@nb-1) ) {				mes " > [Offline]";			}		}		if(.@online[.@i]) {			mes " > "+ .@name$[.@i];			.@k++;		}	}
Edited by Angelmelody

Share this post


Link to post
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.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

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