Jump to content
  • 0

pvp ladder ranking not working.


Cisqua

Question


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  131
  • Reputation:   1
  • Joined:  12/29/12
  • Last Seen:  

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

12 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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 by AnnieRuru
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  131
  • Reputation:   1
  • Joined:  12/29/12
  • Last Seen:  

BUMP!..

its rumble again...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  131
  • Reputation:   1
  • Joined:  12/29/12
  • Last Seen:  

Thanks AnnieRuru!

Link to comment
Share on other sites


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

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;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

Why does most of the scripter here don't use the

query_sql "CREATE TABLE IF NOT EXIST .....

Instead of commenting it out?

/?

Link to comment
Share on other sites


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

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

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

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.

Link to comment
Share on other sites


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

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

Ahh nevermind, you really missed my point... /panic

Link to comment
Share on other sites


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

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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 possible

access 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

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