• 0
Sign in to follow this  
Followers 0
keough

PvP Ranking! - Request

Question

Hello!

 

I have this idea to make the pvp active on my server with a twist. Anyone can do this? I am willing to pay

 

PvP Rank

- Top 10 per week

- The top ten will be rewarded at the end of the week and it will be reset

- Every kill in the pvp map gain 3 PvP Point in rank

- Every Death in the pvp map will have penalty of -2 points

- Once a player kill he will receive a notification which is dispbottom "You gain 3 points on PvP Rank"

- Same once a player died in the pvp room dispbottom "You received -2 points penalty on PvP Rank"

- The top ten rank at the end of the week will be rewarded a Rok Star Badge - item id 7729

Top 1 - 100 Rok Star Badge

Top 2 - 90 Rok Star Badge

Top 3 - 80 Rok Star Badge

Top 4 - 70 Rok Star Badge

Top 5 - 60 Rok Star Badge

Top 6 - 50 Rok Star Badge

Top 7 - 40 Rok Star Badge

Top 8 - 30 Rok Star Badge

Top 9 - 20 Rok Star Badge

Top 10 - 10 Rok Star Badge

 

- Our client has 2 client maximum or dual client how can we restrict it from getting points?

Share this post


Link to post
Share on other sites

3 answers to this question

  • 0

working on it, I'll post here the script asap, free of charge

Share this post


Link to post
Share on other sites
  • 0

Posted (edited)

here's a rough draft (not tested)

 

-	script	PvP Ranking	FAKE_NPC,{

OnPCKillEvent:
    pvp_rank[.this_week] += 3; // raise our own pvp rank
    dispbottom("You gain 3 points on PvP Rank");
    attachrid(killedrid);
    pvp_rank[.this_week] = max(0, pvp_rank[.this_week] - 3); // decrease their pvp rank
    dispbottom("You received -3 points penalty on PvP Rank");
    end;

OnPCLoginEvent:
OnClaimReward:
    .@char = getcharid(CHAR_ID_CHAR);
    if ($pending_badges[.@char] < 1) {
        end;
    }

    pvp_rank[$last_week] = 0;
    dispbottom(sprintf("PvP Rank: you obtained %i points this week, putting you at rank %i.",
        $pending_points[.@char], $pending_rank[.@char] + 1));
    dispbottom(sprintf("Reward: %i badges.", $pending_badges[.@char]));
    getitem(Rok_Star_Badge, $pending_badges[.@char]);

    $pending_badges[.@char] = 0;
    $pending_points[.@char] = 0;
    $pending_rank[.@char] = 0;
    end;

OnInit:
    .top_len = 10; // we want a top 10

    // fallthrough

OnSun0001:
    // every Sunday at 00:01 AM
    $last_week = .this_week;
    .this_week = atoi(gettimestr("%y%W", 4)); // YYWW

    if ($last_week < 1) {
        end; // this is our first week running this script
    }

    .@count = query_sql(sprintf("SELECT c.char_id, c.name, r.value"
                  "FROM `char_reg_num_db` r "
                  "JOIN `char` c ON r.char_id = c.char_id "
                  "WHERE `key`='pvp_rank' AND `index`='%i' "
                  "ORDER BY `value` DESC "
                  "LIMIT " + .top_len + ";", $last_week),
                  .top_char[0], .top_char$[0], .top_points[0]); // store that info so it can be reused throughout the week

    query_sql(sprintf("DELETE FROM `char_reg_num_db` WHERE `key`='pvp_rank' AND `index` <= %i", $last_week)); // janitor task

    for (.@i = 0; .@i < .@count; .@i++) {
        .@badges = (10 * .top_len) - (10 * .@i); // the badges this player won
        .@char = .top_char[.@i];
        .@acc = charid2rid(.@char);

        $pending_badges[.@char] += .@badges;
        $pending_points[.@char] = .top_points[.@i];
        $pending_rank[.@char] = (.@i + 1);

        if (.@acc > 0) {
            addtimer(rand(5000), "PvP Ranking::OnClaimReward", .@acc);
        }
    }
    end;
}

You'll notice I did +3 and -3 for both killing and being killed; This is on purpose, else someone could just make 2 characters and kill each other to keep getting +1 every time (+3, -2)

 

 

To display the top 10 from last week in a npc you'd do something like:

mes("Here's the ranking for last week:");
next();

if (getvariableofnpc(.top_char[0], "PvP Ranking") < 1) {
    mes("(no ranking available for that week)");
    next();
}

.@max = getvariableofnpc(.top_len, "PvP Ranking");
for (.@i = 0; .@i < .@max; .@i++) {
    .@points = getvariableofnpc(.top_points[.@i], "PvP Ranking");
    if (.@points < 1) {
        break;
    }
    mes(sprintf("%i. %s — %i points.", .@i + 1,
        getvariableofnpc(.top_char$[.@i], "PvP Ranking"), .@points));
    next();
}
Edited by meko

Share this post


Link to post
Share on other sites
  • 0

Posted (edited)

@meko

 

I will be testing this on my test server.

 

How about if there is a restriction on dual client users.

Edited by keough

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0