Jump to content
Sign in to follow this  
rokimoki

PvP Rank (SQL)

Recommended Posts

PvP Rank (needs SQL version)

 

Hello,

This is another script I made years ago and I updated for Hercules and made SQL version, just put in your server and @reloadscript in order to implement the waiting room and create the sql table (you don't need to create anything, the script will do for you). Or just reboot the server.

 

What it really does?

  1. Warps you to a PvP Map: "pvp_n_1-5".
  2. If you kill someone you gain 1 pvp point and will broadcast a map announce.
  3. If you die you don't loose anything.
  4. If you commit suicide you don't gain/loose anything, but will show a map announce that you commited suicide.
  5. Shows the PvP Rank Ladder.
  6. Every time you enter the pvp map it will be displayed your current pvp points.

How does it work?

  1. Join PvP map through prontera warp.
  2. Read the pvp ladder through bulletin board in prontera npc.

If you want to change the pvp map I think it's pretty easy, just read the script and do it.

 

You can download from GitHub link the attached file is the initial release, use GitHub for the lastest version.

pvpRank.txt

Share this post


Link to post
Share on other sites

Hey, Rokimoki. It's been awhile since I last saw you in forum (probably back in eA forum) :D

 

Some tips for you to improve it, if you want.

 

1.

query_sql("SELECT `char_id` FROM `custom_pvprank` WHERE `char_id` = " + getcharid(0) + ";", .@flag[0]);
if (!.@flag[0]) { // create kill_count
	query_sql("INSERT INTO `custom_pvprank` (char_id, kill_count) VALUES ('" + getcharid(0) + "','" + kill_count + "');");
} else { // update kill_count
	query_sql("UPDATE `custom_pvprank` SET `kill_count` = " + kill_count + ";");
}

this part can actually be simplified into 1 query.. which is

INSERT INTO..... ON DUPLICATE KEY UPDATE .....

but, you have to set the `char_id` as primary key for the table. Since the ladder only store 1 row per characters, so you won't need to worry on duplicate `char_id`.

Anyway you already made it as primary key...

 

2.

cleararray .@players$[0], "", 10; // defining 10 positions
cleararray .@kill_count[0], 0, 10;

if (strcmp(.@players$[.@i], "") == 0) break; // if some is empty, stop printing

these are not really necessary .... those npc scope variable will be auto cleared once the conversation with the NPC ended.

char name shall never be empty unless somewhere in your query gone wrong...  but yet you can skip this by adding another checking in the query which is better if you really need it.

another reason for that would be, IF it happen one of the player having empty name, the ranking display will be a mess. :D

 

3.

getmapxy(.@map$,.@x,.@y,0);

since the .@x and .@y variable are not used, you can actually replace the getmapxy() into strcharinfo(3) which work the same, return the current map name.

 

4.

if (rid2name(killedrid) == strcharinfo(0)) { // prevent suicide for gaining points

can be replace by this ... 

if ( killedrid == getcharid(0) ) 

 

5.

sleep 50;

haha, you dont really need to update the waitingroom display that frequent, it keep resources. 1 seconds are better :D

Share this post


Link to post
Share on other sites

Hi,

I was fully active in eA forums. I will probabbly update those tips soon and I just recycled the script in order to get into this again, of course new scripts will be more clean and optimized than this, anyway there are lot of new script functions and changes.

  1. I wanted to do for everyone without changing anything. I prefer sending the job to the db engine instead of coding but... well... it's enough and simple xD.
  2. I did the break because I loop 0 to 9 instead of using getarraysize (or whatever) because it didn't work for me, or I did it in a wrong way.
  3. Yeah, I forgot lot of things and that's was recycled.
  4. That's much better optimization, but was recycled too.
  5. Anyway, I don't think that will hurt, but I don't know... maybe you are right.

I really appreciate your feedback I will update soon.

 

Thanks.

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.