Jump to content
  • 0

MVP RANKER PROBLEM


eloscar23

Question


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.06
  • Content Count:  49
  • Reputation:   0
  • Joined:  02/21/23
  • Last Seen:  

Hello, here is the issues.

When example top 2 reaches top 1 his name still stays on top 2 when he goes and is added on top 1.image.png.bad054e6e59917a5318c1706b0721ad8.png

here the script:

prontera,146,161,5    script    CheckRank    118,{
        

                
        mes "Hello, this is an Npc Ranker";
        mes "Would you like to know the MvP Ranking?";
        next;
        switch(select("Top 20:Leave")){

        case 1:
        mes "Top 1 is : [" +$n1$ +"], Kills : [" +$k1 +"] MVPS";
        mes "Top 2 is : [" +$n2$ +"], Kills : [" +$k2 +"] MVPS";
        mes "Top 3 is : [" +$n3$ +"], Kills : [" +$k3 +"] MVPS";
        mes "Top 4 is : [" +$n4$ +"], Kills : [" +$k4 +"] MVPS";
        mes "Top 5 is : [" +$n5$ +"], Kills : [" +$k5 +"] MVPS";
        mes "Top 6 is : [" +$n6$ +"], Kills : [" +$k6 +"] MVPS";
        mes "Top 7 is : [" +$n7$ +"], Kills : [" +$k7 +"] MVPS";
        mes "Top 8 is : [" +$n8$ +"], Kills : [" +$k8 +"] MVPS";
        mes "Top 9 is : [" +$n9$ +"], Kills : [" +$k9 +"] MVPS";
        mes "Top 10 is : [" +$n10$ +"], Kills : [" +$k10 +"] MVPS";
        close;
        break;

        case 2:
        mes "Have a nice day";
        mes "bye";
        close;
        end;

        }// end switch

}// end npc

-    script    count    -1,{
    OnNPCKillEvent:
    if(killedrid == 1002){
        set @rankp, @rankp + 1;
        dispbottom "You have obtained 1 Rank Point, now you have "+@rankp+" .";
        callfunc ("mvpladder",@rankp,strcharinfo(0));
    }


}


function    script    mvpladder    {
    set @puntos, getarg(0);
    set @nombres$, getarg(1);

    if (@puntos > $k1) {
        // Si el nombre se repite, eso se verifica con strcharinfo
        if (@nombres$ == strcharinfo(0)) {
            set $k1, @puntos;
            set $n1$, @nombres$;
        } else {
            // Guardo el top1 anterior
            set @oldn1$, $n1$;
            set @oldk1, $k1;

            // Ahora el top 2 se vuelve top1
            set $k1, $k2;
            set $n1$, $n2$;

            // Ahora el top1 que teníamos guardado se vuelve top2
            set $k2, @oldk1;
            set $n2$, @oldn1$;
        }
    } else if (@puntos > $k2) {
        if (@nombres$ == strcharinfo(0)) {
            set $k2, @puntos;
            set $n2$, @nombres$;
        } else {
            // Guardo el top2 anterior
            set @oldn2$, $n2$;
            set @oldk2, $k2;

            // El nuevo top2 toma el lugar del antiguo top2
            set $k2, $k3;
            set $n2$, $n3$;

            // El antiguo top2 se convierte en el nuevo top3
            set $k3, @oldk2;
            set $n3$, @oldn2$;
        }
    }


 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  896
  • Reputation:   117
  • Joined:  05/23/12
  • Last Seen:  

Why don't use a SQL Ranking? Otherwise u need to loop throw every rank after on changes and update the ranking.

 

Rynbef~

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  896
  • Reputation:   117
  • Joined:  05/23/12
  • Last Seen:  

//additional comment

U can also use the mvp log SQL table.

 

Rynbef~

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