Jump to content
Zeiyan

Achievement System [ Script Only ]

Recommended Posts

Hello hercules!. I just want to share this script i made. I'm fully aware that the coding style sucks, hard to modify and hard to understand (even i have problems reading it when i finished.)

nonetheless i wanted to share it and hopefully someone can optimize it and make it easy to modify and clean the whole thing up (if possible add achievements to make it easier)

 

NOTE:

for pvp achievement my separate script has variable "KILL" (using ghost's pvp script so don't need to do checking for abuse)

for event achievement i added the variable "evtjunk" to all my custom events

 

Script:

http://pastebin.com/vBuWaiKd

 

SQL:

CREATE TABLE IF NOT EXISTS `achievement` (  `id` int(11) NOT NULL auto_increment,  `account_id` int(11) NOT NULL default '0',  `char_id` varchar(23) NOT NULL default '',  `name` varchar(23) NOT NULL default '',  `achievement` varchar(23) NOT NULL default '',  `val` int(11) NOT NULL default '0',  PRIMARY KEY (`id`),  KEY (`id`)) ENGINE=MyISAM;

Please leave comments, tips and advices below. (Hoping to hear from people i learned from, emistry and annieruru! smile.png

 

Share this post


Link to post
Share on other sites

 

Hello hercules!. I just want to share this script i made. I'm fully aware that the coding style sucks, hard to modify and hard to understand (even i have problems reading it when i finished.)

nonetheless i wanted to share it and hopefully someone can optimize it and make it easy to modify and clean the whole thing up (if possible add achievements to make it easier)

 

NOTE:

for pvp achievement my separate script has variable "KILL" (using ghost's pvp script so don't need to do checking for abuse)

for event achievement i added the variable "evtjunk" to all my custom events

 

Script:

http://pastebin.com/vBuWaiKd

 

SQL:

CREATE TABLE IF NOT EXISTS `achievement` (  `id` int(11) NOT NULL auto_increment,  `account_id` int(11) NOT NULL default '0',  `char_id` varchar(23) NOT NULL default '',  `name` varchar(23) NOT NULL default '',  `achievement` varchar(23) NOT NULL default '',  `val` int(11) NOT NULL default '0',  PRIMARY KEY (`id`),  KEY (`id`)) ENGINE=MyISAM;

Please leave comments, tips and advices below. (Hoping to hear from people i learned from, emistry and annieruru! smile.png

and that your script here?

link(br):http://www.i9ro.com/...a_de_Conquistas

u8oB6y9.jpg

Share this post


Link to post
Share on other sites

no. i think that one have src modifications. mine is basically just a simple quests that saves into db. ( i suck at arrays)

Share this post


Link to post
Share on other sites

no. i think that one have src modifications. mine is basically just a simple quests that saves into db. ( i suck at arrays)

the only difference I saw was that your have to talk to the npc and that my system and automatic acknowledges that he killed the guy poring 1000 and the conquest of him.

Share this post


Link to post
Share on other sites

mine does'nt check for monster id. it just counts killed monsters in general. then another achievement for mvps and another for lighthalzen mobs.

Share this post


Link to post
Share on other sites

Well, if you want to add individual monsters to your script for achievements then it is very simple. In fact, it won't take away from your script much at all. Just in corporate this bit of code in to your script:

This is for OnInit, as it will handle the variables used.

OnInit:// Each element of the array can be set to the amount needed to be killed.// Allowing you to dynamically set each monster achievements, sort of .// Example, if I wanted a regular monster achievement for 500 kills just add this:// .mob_master[500] = 500; // 500 kills will be another achievement. Listed as: 'Monster_Name Master' '500'..mob_master[10000] = 10000;.mob_master[20000] = 20000;.mob_master[30000] = 30000;end;

This is for OnNPCKillEvent, as it will deal with calculating each monster's kills.

OnNPCKillEvent:setd ""+ killedrid +"", getd(""+ killedrid +"") + 1;if( getd(""+ killedrid +"") == .mob_master[getd(""+ killedrid +"")] ){	.@prize = getd(""+ killedrid +"");	announce ""+ strcharinfo(0) +" just achieved "+ getmonsterinfo( killedrid, 0 ) +" Master "+ getd(""+ killedrid +"") +"",bc_all;	query_sql("INSERT INTO `achievement` VALUES (NULL, "+ getcharid(3) +","+ getcharid(0) +",'"+ escape_sql(strcharinfo(0)) +"','"+ getmonsterinfo( killedrid, 0 )+" Master', "+ getd(""+ killedrid +"") +")");	callsub OnRegularMaster, .@prize; // Call the label, with the value to be used for giving prizes.}end;

Lastly, this is the prize section, they only get red potions for now, but that's because I didn't get into detail on what they should receive xD

OnRegularMaster:switch( getarg(0) ){	case 10000:		getitem 501,1;		break;	case 20000:		getitem 501,2;		break;	case 30000:		getitem 501,3;		break;	// More as needed.}end;

 

That's it really O.o; Heck you could even just make it another NPC all together, since it uses your sql_database as it's placer. The only part I didn't do was the ranking system. I'll leave that to you =P

So as an example, let's say I wanted an achievement for 1,000,000 kills of a mosnter. I'd just do the following ( This is a sample script ):

-    script    monster_kills    -1,{OnInit:.mob_master[1000000] = 1000000;end;OnNPCKillEvent:setd ""+ killedrid +"", getd(""+ killedrid +"") + 1;// Checks to see if the monsters I killed is equal to the array.// This works, because if 0->999,999 are all 0, then it won't do anything, since my kills will always be 1 or higher.// Meaning any element that has a value of 0 is disabled and will not be an achievement, which means you can even enable/disable some for events =P.if( getd(""+ killedrid +"") == .mob_master[getd(""+ killedrid +"")] ){    // announcement;    // query_sql;    // This will make me call the label with the given value as getarg(0). In this sample, case, it will send 1,000,000 as the number.    callsub OnRegularMonster, getd(""+ killedrid +"");}end;OnRegularMonster:switch( getarg(0) ){    // This means I killed 1,000,000 monsters, and there is a reward for doing so.    // If you do not add a case for the relative achievement, it just means they don't get a reward for doing it.    // So, let's say they got an achievement for killing 10, and that's too easy, well we just don't make a case 10: and then they don't get a reward.    // Still get the achievement though =P    case 1000000:        getitem 501,1;        break;}end;

 

O.o hope this helps. Make use of it if you want, or don't up to you.

Edited by GmOcean

Share this post


Link to post
Share on other sites

Well, if you want to add individual monsters to your script for achievements then it is very simple. In fact, it won't take away from your script much at all. Just in corporate this bit of code in to your script:

This is for OnInit, as it will handle the variables used.

OnInit:// Each element of the array can be set to the amount needed to be killed.// Allowing you to dynamically set each monster achievements, sort of .// Example, if I wanted a regular monster achievement for 500 kills just add this:// .mob_master[500] = 500; // 500 kills will be another achievement. Listed as: 'Monster_Name Master' '500'..mob_master[10000] = 10000;.mob_master[20000] = 20000;.mob_master[30000] = 30000;end;

This is for OnNPCKillEvent, as it will deal with calculating each monster's kills.

OnNPCKillEvent:setd ""+ killedrid +"", getd(""+ killedrid +"") + 1;if( getd(""+ killedrid +"") == .mob_master[getd(""+ killedrid +"")] ){	.@prize = getd(""+ killedrid +"");	announce ""+ strcharinfo(0) +" just achieved "+ getmonsterinfo( killedrid, 0 ) +" Master "+ getd(""+ killedrid +"") +"",bc_all;	query_sql("INSERT INTO `achievement` VALUES (NULL, "+ getcharid(3) +","+ getcharid(0) +",'"+ escape_sql(strcharinfo(0)) +"','"+ getmonsterinfo( killedrid, 0 )+" Master', "+ getd(""+ killedrid +"") +")");	callsub OnRegularMaster, .@prize; // Call the label, with the value to be used for giving prizes.}end;

Lastly, this is the prize section, they only get red potions for now, but that's because I didn't get into detail on what they should receive xD

OnRegularMaster:switch( getarg(0) ){	case 10000:		getitem 501,1;		break;	case 20000:		getitem 501,2;		break;	case 30000:		getitem 501,3;		break;	// More as needed.}end;

 

That's it really O.o; Heck you could even just make it another NPC all together, since it uses your sql_database as it's placer. The only part I didn't do was the ranking system. I'll leave that to you =P

So as an example, let's say I wanted an achievement for 1,000,000 kills of a mosnter. I'd just do the following ( This is a sample script ):

-    script    monster_kills    -1,{OnInit:.mob_master[1000000] = 1000000;end;OnNPCKillEvent:setd ""+ killedrid +"", getd(""+ killedrid +"") + 1;// Checks to see if the monsters I killed is equal to the array.// This works, because if 0->999,999 are all 0, then it won't do anything, since my kills will always be 1 or higher.// Meaning any element that has a value of 0 is disabled and will not be an achievement, which means you can even enable/disable some for events =P.if( getd(""+ killedrid +"") == .mob_master[getd(""+ killedrid +"")] ){    // announcement;    // query_sql;    // This will make me call the label with the given value as getarg(0). In this sample, case, it will send 1,000,000 as the number.    callsub OnRegularMonster, getd(""+ killedrid +"");}end;OnRegularMonster:switch( getarg(0) ){    // This means I killed 1,000,000 monsters, and there is a reward for doing so.    // If you do not add a case for the relative achievement, it just means they don't get a reward for doing it.    // So, let's say they got an achievement for killing 10, and that's too easy, well we just don't make a case 10: and then they don't get a reward.    // Still get the achievement though =P    case 1000000:        getitem 501,1;        break;}end;

 

O.o hope this helps. Make use of it if you want, or don't up to you.

Thanks but i already do know how to add individual monsters :P I just shared this for others to use if they want. although I was hoping others can sort of optimize the code. (it really sucks and hard to read) I have redundant lines so i feel like i kinda made it longer than it should be. (maybe use arrays or use more efficient sql queries)

Share this post


Link to post
Share on other sites

What about if we wanted to use it for certain days like isnight isday achievements and weekend achievements? It would be amazing to have it so diverse. Spice things up anyhelp on this comment? Gmocean XD

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

×
×
  • Create New...

Important Information

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