Cisqua Posted February 7, 2013 Group: Members Topic Count: 46 Topics Per Day: 0.01 Content Count: 131 Reputation: 1 Joined: 12/29/12 Last Seen: August 10, 2016 Share Posted February 7, 2013 (edited) why this script ladder like most highiest kill will be on top 1. its rumble. anybody can fix this? thanks! prontera,164,170,2 script PvP Ladder 786,{ while(1) { set .@nb, query_sql("select name, kills, deaths, class from pvpladder order by kills"+( (@menu == 2)?"/deaths":" desc" )+" limit 10", .@name$, .@kills, .@deaths, .@class ); if ( .@nb == 0 ) mes "ladder is empty"; else { for ( set .@i, 0; .@i < .@nb; set .@i, .@i +1 ) mes "^0000FF"+ (.@i+1) +": ^228B22"+ .@name$[.@i] +" ^606060"+ jobname(.@class[.@i]) +" ^006699"+ .@kills[.@i] +" / ^C80000"+ .@deaths[.@i] +"^000000"; close; } } end; // I dont think can get here anyway OnInit: delwaitingroom strnpcinfo(1); set .@nb, query_sql("select name, kills, deaths, class from pvpladder order by kills desc limit 1", .@name$, .@kills, .@deaths, .@class ); waitingroom (.@nb)? ( .@name$ +" ("+ jobname(.@class[.@i]) +") : "+ .@kills[.@i] +" / "+ .@deaths[.@i] +"" ):"PVP Ladder !", 0; end; } Edited February 8, 2013 by Cisqua Quote Link to comment Share on other sites More sharing options...
AnnieRuru Posted February 8, 2013 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted February 8, 2013 (edited) try this one instead /* create table pvpladder ( cid int(11) primary key, name varchar(23), kills int(11), deaths int(11), class int(11), key (kills) ) engine = myisam; */ prontera,164,170,2 script PvP Ladder 786,{ .@nb = query_sql( "select name, kills, deaths, class from pvpladder order by kills desc limit 10", .@name$, .@kills, .@deaths, .@class ); if ( !.@nb ) { mes "ladder is empty"; close; } for ( .@i = 0; .@i < .@nb; .@i++ ) mes "^0000FF"+ (.@i+1) +": ^228B22"+ .@name$[.@i] +" ^606060"+ jobname(.@class[.@i]) +" ^006699"+ .@kills[.@i] +" / ^C80000"+ .@deaths[.@i] +"^000000"; close; OnPCKillEvent: query_sql "insert into pvpladder values ( "+ getcharid(0) +", '"+ escape_sql( strcharinfo(0) ) +"', 1, 0, "+ class +" ) on duplicate key update kills = kills +1, name = '"+ escape_sql( strcharinfo(0) ) +"', class = "+ class; attachrid killedrid; query_sql "insert into pvpladder values ( "+ getcharid(0) +", '"+ escape_sql( strcharinfo(0) ) +"', 0, 1, "+ class +" ) on duplicate key update deaths = deaths +1, name = '"+ escape_sql( strcharinfo(0) ) +"', class = "+ class; delwaitingroom; // continue read OnInit: if ( query_sql( "select name, kills, deaths, class from pvpladder order by kills desc limit 1", .@name$, .@kills, .@deaths, .@class ) ) waitingroom .@name$ +" ("+ jobname(.@class) +") : "+ .@kills +" / "+ .@deaths, 0; else waitingroom "PVP Ladder !", 0; end; } EDIT: fix a typo on table creation Edited February 8, 2013 by AnnieRuru 1 Quote Link to comment Share on other sites More sharing options...
Cisqua Posted February 8, 2013 Group: Members Topic Count: 46 Topics Per Day: 0.01 Content Count: 131 Reputation: 1 Joined: 12/29/12 Last Seen: August 10, 2016 Author Share Posted February 8, 2013 BUMP!.. its rumble again... Quote Link to comment Share on other sites More sharing options...
Cisqua Posted February 8, 2013 Group: Members Topic Count: 46 Topics Per Day: 0.01 Content Count: 131 Reputation: 1 Joined: 12/29/12 Last Seen: August 10, 2016 Author Share Posted February 8, 2013 Thanks AnnieRuru! Quote Link to comment Share on other sites More sharing options...
GM Takumirai Posted February 9, 2013 Group: Members Topic Count: 69 Topics Per Day: 0.01 Content Count: 592 Reputation: 31 Joined: 11/14/11 Last Seen: July 29, 2015 Share Posted February 9, 2013 how to put a GM selection to reset the ladder Quote Link to comment Share on other sites More sharing options...
Emistry Posted February 9, 2013 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted February 9, 2013 try for ( .@i = 0; .@i < .@nb; .@i++ ) mes "^0000FF"+ (.@i+1) +": ^228B22"+ .@name$[.@i] +" ^606060"+ jobname(.@class[.@i]) +" ^006699"+ .@kills[.@i] +" / ^C80000"+ .@deaths[.@i] +"^000000"; if( getgmlevel() > 90 ){ next; if( select("Close","Clear Ladder") == 2 ){ if( query_sql( "TRUNCATE `pvpladder`" ) ){ mes "Ladder Cleared."; } } close; Quote Link to comment Share on other sites More sharing options...
nanakiwurtz Posted February 9, 2013 Group: Members Topic Count: 81 Topics Per Day: 0.02 Content Count: 1654 Reputation: 583 Joined: 08/09/12 Last Seen: January 14, 2020 Share Posted February 9, 2013 Why does most of the scripter here don't use the query_sql "CREATE TABLE IF NOT EXIST ..... Instead of commenting it out? Quote Link to comment Share on other sites More sharing options...
Emistry Posted February 9, 2013 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted February 9, 2013 so that there is a need to re-run it if the table already implemented...and of course there are still have uses for this...like auto fix the problem if table missing.. but i dun like to write the table structure in "one line" and some ppl might not "notice" there is a SQL Table for the scripts..... and...it's easier to view the table structure when it's formatted correctly... 1 Quote Link to comment Share on other sites More sharing options...
nanakiwurtz Posted February 10, 2013 Group: Members Topic Count: 81 Topics Per Day: 0.02 Content Count: 1654 Reputation: 583 Joined: 08/09/12 Last Seen: January 14, 2020 Share Posted February 10, 2013 No, that's not what I mean. I mean why not create a check by using the 'query_sql', so the users don't have to do the query manually on the SQL. Quote Link to comment Share on other sites More sharing options...
Emistry Posted February 10, 2013 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted February 10, 2013 just to confirm with the SQL Machine before it create a new table...so that there wont be any error shown in map server when you try to create another table with same name... Quote Link to comment Share on other sites More sharing options...
nanakiwurtz Posted February 10, 2013 Group: Members Topic Count: 81 Topics Per Day: 0.02 Content Count: 1654 Reputation: 583 Joined: 08/09/12 Last Seen: January 14, 2020 Share Posted February 10, 2013 Ahh nevermind, you really missed my point... Quote Link to comment Share on other sites More sharing options...
Emistry Posted February 10, 2013 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted February 10, 2013 No, that's not what I mean. I mean why not create a check by using the 'query_sql', so the users don't have to do the query manually on the SQL. explained my point of view here..... so that there is a need to re-run it if the table already implemented...and of course there are still have uses for this...like auto fix the problem if table missing.. but i dun like to write the table structure in "one line" and some ppl might not "notice" there is a SQL Table for the scripts..... and...it's easier to view the table structure when it's formatted correctly... Quote Link to comment Share on other sites More sharing options...
AnnieRuru Posted February 10, 2013 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted February 10, 2013 I mean why not create a check by using the 'query_sql', so the users don't have to do the query manually on the SQL. because I prefer to use query_sql as few times as possibleaccess query_sql once = 0.01 second (won't feel lag) access query_sql 100 times = 1 second (start to feel lag) OnInit will trigger every time the server start up or @reloadscript and that has already using a lot resources query_sql so much is just like a waste of energy since this kinda stuff is just need to run once and forget, why run it so many times ? reason 2: if you previously have a table create table test ( id int(11) primary key count int(11) ); and you want to edit this table alter table test add column name varchar(23) after id; there is no way you can do this with OnInit that's why its better to let the user learn to create the table manually, and they will remember that they have already created it so when you updated the script plus update the sql database, they will run this alter table syntax in their SQL browser maybe you say can do it with certain tricks select name from test limit 1 .... this will display an error on the user, and might just bombard your release topic with replies with negative opinions on your topic Quote Link to comment Share on other sites More sharing options...
Question
Cisqua
why this script ladder like most highiest kill will be on top 1. its rumble. anybody can fix this? thanks!
Edited by CisquaLink to comment
Share on other sites
12 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.