Top 10 PK Killers with lists of characters

Lord Ganja

New member
Messages
161
Points
0
Age
34
Location
Ganja World
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.. .
Untitled.png

Thanks in advance! 
default_thx.gif


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

 
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 :/

Code:
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;}
 
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

 
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:

Code:
	.@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;		}
 
Last edited by a moderator:
that error was caused by  sleep
Thank you. I already get rid of the error. 
default_no1.gif

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?
default_hmm.gif
try this

Code:
	.@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";	}
 
Last edited by a moderator:
@@Angelmelody -

Thanks for the script.
default_no1.gif


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

Code:
[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)
 
Last edited by a moderator:
@@Angelmelody -

Thanks for the script.
default_no1.gif


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

Code:
	.@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";	}
 
Last edited by a moderator:
@@Angelmelody - Works like a charm!!!!
default_no1.gif
 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

Code:
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]..........
 
@@Angelmelody - Works like a charm!!!!
default_no1.gif
 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

Code:
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..
Code:
	.@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++;		}	}
 
@@Angelmelody - Thanks again! Anyway the script doesn't show the last entry if the player is offline..

It was displayed like this:

Code:
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
 
@@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
default_smile.png


Code:
	.@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++;		}	}
 
Last edited by a moderator:
Back
Top