Jump to content
  • 0
anticlimax18

[Request Support] Player Customized Quest Script + SQL Track [ALMOST COMPLETE]

Question

Player Paid Quest Generator Script 

 

 

TO DO:

OnNPCKillEvent

 

I Am Trying to make this Script that Uses SQL to store Quest Auto Generated.

I have scraped that Auto generate idea instead i now made it player to select combining Gather and hunting together.

 

Players Pay Some to Create a Quest in return for Reward if someone Completes his Quest.

Also The Quest Taker gets a Reward.

So why not use Flux Credit and add another Custom Credit for other purposed and also utilized Cash Points for Cash Shop.

 

My NEW Aim here is to make a Quest NPC System used by players to create and earn credits or kafra Cash points.

 

The Player Publish Quest.

Other Player Takes Available Quest.

The Publisher get Kafra Cash Points when his Publish Quest Completes.

The Player who took the Quest get some Custom Credits which he can use for other purposes.

 

 

 

Also I intend to RELEASE THIS SCRIPT AS SOON AS IT COMPLETES.

 

STATUS:  ALMOST COMPLETE

 

Thanks to gmOcean till now. [For sample codes]

 

DataBase Table : [sUBJECTED TO CHANGE AS SCRIPT DEVELOPS.]

 

Table name >>  "Paid_Quest"

// SQL TABLE TO BE USED.

/*
CREATE TABLE `master_main`.`paid_quests` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(255) NOT NULL,
  `pub_id` INT(11) NOT NULL,
  `TrackID` INT(11) NOT NULL DEFAULT 0,
  `mob_id` INT(11) NOT NULL DEFAULT 0,
  `item_id` INT(11) NOT NULL DEFAULT 0,
  `tar_kill` INT(11) NOT NULL DEFAULT 0,
`tar_collect` INT(11) NOT NULL DEFAULT 0,
  `reward` INT(11) NOT NULL DEFAULT 0,
  `time` BIGINT NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `id_UNIQUE` (`id` ASC));
*/

Now What I have not done in this Script.

  1. Not added OnNPC Events.
  2. SQL Queries for storing Information
  3. checking if player has already posted quest of that name.
  4. Rewarding Player. Which has to be done while calling Status from @pqstatus and OnPCLoginEvent:

 

Yes Yes I know .. Its taking more than a week. (I am very busy got job and do this in spare time + I am not good at scripting so I need help develop it)

 

BELOW SCRIPT IS A COMPLETE QUEST

/************************************************************Player Paid Quest Generator Script Created By: Anticlimax18Helped by: gmOceanVersion: 1.0**************************************************************/prontera,147,168,4	script	QuestMachine	877,{function mobinfo;mes "[Quest Machine]";mes "Your Reward is ^FF0000Cash Shop Points^000000";mes "^FF0000NOTE: REWARD WILL ONLY BE AWARDED ONCE THE QUEST IS COMPLETE BY SOMEONE.^000000";.@option = select("[Post Quest?]:[My Quest Status]");if (.@option == 1) goto PostQuest;goto QuestStatus;PostQuest:	switch(select("New Quest : How it Works?")){	case 1:	.@questcheck = query_sql("SELECT `name` From `paid_quests` where `pub_id`='"+getcharid(3)+"'",@name$);	if(.@questcheck) { next; mes "[Quest Machine]"; mes "Quest Limit Reached. Max 1 Quest"; mes "Last Quest Published "+ @name$; close; }	next;	mes "[Follow 6 Steps]";	mes "1. Type Monster Tag ID";	mes "2. Confirm  Randomize Ammount"; 	mes "3. View Monster Kill Details";	mes "4. Select Drop Pick for Quest";	mes "5. Set Amount for Pick";	mes "6. Proceed and Pay";	next;	input .@id;		//Check Exist	if (getmonsterinfo(.@id,0) == "null"){ mes "[Quest Machine]"; mes "No monsters with that ID tag"; mes "Lets Try again and Read Steps please"; next; goto PostQuest;}		mes mobinfo(.@id);		set .@option,select("Next Monster:Close");		while ( .@option == 1){		mes mobinfo(.@id);		}	close;//For Safety is something goes wrong above.	end;		case 2:	next;	mes "[Quest Machine]";	mes "You can create a Paid quest by follow steps given at the time of creation.";	next;	mes "[Quest Machine]";	mes "Reward is 'Cash Shop Points' [Charged Credit x 2].";	mes "Eg. You where charged 200 Credit. You are rewarded 400 Cash Shop points.";	next;	mes "[Quest Machine]";	mes "Once someone completes your quest You will be rewarded";	next;	mes "[Quest Machine]";	mes "Remember Credits are charged based upon Monster Level";	close;	end;	}end;QuestStatus:mes ".... Type @pqstatus to view status.";close;end;OnPCDieEvent:end;		function mobinfo	{		 .@id = getarg(0);	//Loop While Selected is Randomized Kill Amount		.@lvl =  getmonsterinfo(.@id,1); //get level		if(.@lvl < 20) set .@val,1;		if(.@lvl >= 21 && .@lvl <= 30) set .@val,2;		if(.@lvl >= 31 && .@lvl <= 50) set .@val,4;		if(.@lvl >= 51 && .@lvl <= 60) set .@val,5;		if(.@lvl > 60) set .@val,6;			mes "[Quest Machine]";				mes "Monster Selected : ^ff0000"+getmonsterinfo(.@id,0)+"^000000";		mes "[Amount to Kill Amount] Min 10 | Max 30";		input .@killamt;		if(.@killamt < 10 || .@killamt > 30 || .@killamt == 0 ){		mes "Out of Range. Random Amount in Range Selected.";		 set .@killamt,rand(10,30);		}		//Set Credit charged half of lvl times killamt		set .@charge,(.@lvl * .@killamt)/2;		next;				//Display Info		mes "Monster: ^0000FF"+getmonsterinfo(.@id,0)+"^000000";		mes "Level: ^00ff00"+.@lvl+"^000000";		mes "Kill Amount:["+.@killamt+"]";		mes "Amount Charged: "+.@charge+" Credits";		mes getmonsterinfo(.@id,0) +"x"+ .@killamt;		if(.@lvl < 25) mes "Difficulty: ^00FF00Easy^000000";		if(.@lvl >= 25 && .@lvl <= 50) mes "Difficulty: ^0000FFMiddium^000000";		if(.@lvl >= 51 && .@lvl <= 75) mes "Difficulty: ^FF0000Hard^000000";		if(.@lvl > 75 ) mes "Difficulty: ^FF0000Insane^000000";			next;				mes "[Quest Machine]";		mes "Enter Available Item Pick Up [Min 20,Max 50]:";		if (getmobdrops(getarg(0))){		.@count = $@MobDrop_count;		copyarray .@item[0],$@MobDrop_item[0],.@count;		copyarray .@rate[0],$@MobDrop_rate[0],.@count;		for (.@i = 0; .@i < .@count; ++.@i) {                         //HELP HERE			//Show ONLY Items Drop Rate > 50% in Mes			if(.@rate[.@i] >= 5500) {			mes .@item[.@i] + " (" + getitemname(.@item[.@i]) + ") " + .@rate[.@i]/100 + ((.@rate[.@i]%100 < 10) ? ".0":".") + .@rate[.@i]%100 + "%";			}		}		input .@item;		while( !compare(.@item, getmobdrops(getarg(0)))) mes "Only Input Item Listed";  input .@item;		input .@itm,20,50;	   if(.@itm < 10 || .@itm > 50 || .@itm == 0 ){		mes "Out of Range. Random Amount in Range Selected.";		 set .@itm,rand(10,50);		}		                  .@ChargedCredit = .@itm + .@charge;			mes"Net Amount Charged: "+.@ChargedCredit;			next;  		mes "[Quest Machine]";		mes "Final Step. Name You Quest.";		mes "Min :5 | Max:15 - Characters.";		input .@name$,5,31;		next;					}		mes "[Quest Machine]";		        mes "Quest Name:^00FF00"+.@name$+"^000000";                mes "Total Credit Charged: "+ .@ChargedCredit; 				if (select("Proceed?:CreateAgain") == 2) goto PostQuest;                //Query_SQL (Get credit Balance) 				query_sql("SELECT balance FROM `cp_credits` WHERE `account_id`='"+getcharid(3)+"'",.@CreditAmount);				if(!.@CreditAmount) set .@CreditAmount,0;				if (.@CreditAmount < .@ChargedCredit ) { mes "Sorry You dont have enough credit"; mes"Credit Balance: "+.@CreditAmount;  close;}				//query_sql (Update) 				query_sql("UPDATE `cp_credits` SET `balance` VALUE `balance`='balance-"+.@ChargeCredit+"'");				query_sql("SELECT balance FROM `cp_credits` WHERE `account_id`='"+getcharid(3)+"'",.@NewAmount);				mes "Credits Charged. Credit Blance Remaining: "+.@NewAmount; 				.@reward = .@CreditAmount/2; //Reward is 50% Cash Credit that of Charged Credit.				query_sql("INSERT INTO `paid_quests` (`name`,`pub_id`,`TrackID`,`mob_id`,`item_id`,`tar_kill`,`tar_collect`,`reward`,`time`) VALUE('"+.@name$+"','"+getcharid(3)+"','0','"+.@id+"','"+.@item+"','"+.@killamt+"','"+.@itm+"','"+.@reward+"','"+.today+"')");				mes "Quest Added.";				mes "You Can Check status with @pqstatus";				mes "Thank you for Your Time.";				close;				}//End FunctionOnInit:OnClock0000:	.today = gettimestr("%Y-%m/%d %H:%M:%S",21);//OnEvents Are Set in other Files for Customize purposes. }//Additional Script for Status Display.-	script	atcmd	-1,{OnInit:bindatcmd "pqstatus",strnpcinfo(3)+"::OnPQStatus";OnPQStatus:mes "[Paid Quest Status]";.@progress = query_sql("SELECT `name`,`trackid`,`time` FROM `paid_quests` WHERE pub_id='"+getcharid(3)+"'",.@quest$,.@status,.@date);if (!.@progress) { mes "No Quest Alloted. Only use if you have posted a Quest."; close;}mes "Quest Name: ^00FF00"+.@quest$+"^000000";mes "Status:"+((.@status)?"^0000ffIn Progress^000000":"^ff0000Waiting to be taken^000000");mes "Post Date:"+.@date;close;end;}

 

 

 

ANY ONE WHO PARTICIPATE IN HELPING WILL GET ITS NAME IN THE CREDITS. 

Edited by anticlimax18

Share this post


Link to post
Share on other sites

14 answers to this question

Recommended Posts

  • 0

Perhaps something like this:

-	script	sql_quest_generator	-1,{OnHuntingCreate:freeloop(1); // Freeloop to prevent infinite loop error.while( .@hunting != .hunting_generate ){ // Loop through the below until a total of (.hunting_generate) amount of quests have been created.    .@a = rand(.min_hunting_objective, .max_hunting_ojbective); // Select a random amount of objectives for this quest.    .@name$ = "Hunting:"; // Start of the quest name.        // Loop the below until the selected amount of objectives have been added to the proper variables.    while( .@b != .@a ){	.@i = rand(1001,3000); // Selecting a random mob_id # from 1001 (Scorpion) -> 3000 ( Just going beyond what exists to add support for custom mobs ).	if( !compare( .blacklist$, ""+ getmonsterinfo( .@i, 0 ) +"" ) ){ // Compares monster ID number to see if it is blacklisted or not.		.@mob_objectives[.@b] = .@i; // Adds the monster as an objective.		.@mob_obj_amount[.@b] = rand(.min_hunting_amount, .max_hunting_amount); // Adds a random amount to be killed to complete that objective.		.@name$ = .@name$ + getmonsterinfo( .@i, 0 ); // Adds the monster's name as part of the quest name.	        .@b++;		}	}        // We create an entry in our custom quest_database using just the Quest name for now.        // This will serve as a pointer when adding in all the objectives later, since the amounts were dynamically chosen and not set in stone.	query_sql("INSERT INTO quest_database `quest_name` = '"+ .@name$ +"'");        // Loop through this until ALL objectives & the amount needed to complete it, have been added to the quest we listed above.	while( .@c < getarraysize( .@mob_objectives ) ){                // Adding in each objective and it's amount to the quest we just created above.		query_sql("Update quest_database SET( `obj"+ .@c +"`, `amt"+ .@c +"'`) VALUES( '"+.@mob_objectives[.@c]+"', '"+.@mob_obj_amount[.@c]+"') WHERE `quest_name`='"+ .@name$ +"'");		.@c++;	}        // Set this variable +1 to say we have completed creating a quest. And to continue looping if not all of them have been created.	.@hunting++;}// Freeloop(0) to let server know we are done looping and to stop trying to prevent infinite loops.freeloop(0);end;// This is where the settings go to configure the above to do what you want.OnInit:.hunting_generate = 3; // How many hunting quests to create and add to sql.// Minimum and Maximum amount of different monsters to be used as an objective..min_hunting_objective = 1;.max_hunting_objective = 5; // Note - This can not be higher than the number of objectives listed in your sql table. So if your sql table only supports 3, this can be no higher than 3.// Minimum and Maximum amount to be killed for each objective..min_hunting_amount = 5;.max_hunting_amount = 20;// Bonus, a custom command that when used, will attempt to create a (.hunting_generate) more quests and add them to the database.bindatcmd "huntgen", strnpcinfo(3)+"::OnHuntingCreate";end;}

 

It's untested, but if it works, it should generate 3 hunting quests, with random amount of 1-5 different monsters to hunt, ranging from 5-20 of each to kill. And place them into a sql database.

Edited by GmOcean

Share this post


Link to post
Share on other sites
  • 0

Nope Gets a strange Error

 

 Capture.jpg

 

 

It seem as no brackets are missing but still it points out an error.

 

Whats going on?

 

Lots have  been changed since hercules do not post new Sript_Command.txt I wish they do.

Edited by anticlimax18

Share this post


Link to post
Share on other sites
  • 0

Sorry my bad, I meant to use getmonsterinfo( .@i, 0); but I forgot to change it after I was done writing out the template. I updated my previous post. And again, I haven't tested whether or not it will fully work, I just know it doesn't have syntax errors.

Share this post


Link to post
Share on other sites
  • 0

Sorry my bad, I meant to use getmonsterinfo( .@i, 0); but I forgot to change it after I was done writing out the template. I updated my previous post. And again, I haven't tested whether or not it will fully work, I just know it doesn't have syntax errors.

Sure, I will check out by tomorrow morning.. 

Share this post


Link to post
Share on other sites
  • 0

Sorry my bad, I meant to use getmonsterinfo( .@i, 0); but I forgot to change it after I was done writing out the template. I updated my previous post. And again, I haven't tested whether or not it will fully work, I just know it doesn't have syntax errors.

 

Your Scripts is a good sample unless you comment what you are trying to do.. I don't understand it quit well. Comment it.

Share this post


Link to post
Share on other sites
  • 0

While, I don't quite like your " tone " depicted with your choice of words, I have commented it. * note - again this hasn't been tested *

This won't help do everything you listed, but it will help give you an idea of how to generate quests and add them to sql.

Share this post


Link to post
Share on other sites
  • 0

Perhaps something like this:

-	script	sql_quest_generator	-1,{OnHuntingCreate:freeloop(1); // Freeloop to prevent infinite loop error.while( .@hunting != .hunting_generate ){ // Loop through the below until a total of (.hunting_generate) amount of quests have been created.    .@a = rand(.min_hunting_objective, .max_hunting_ojbective); // Select a random amount of objectives for this quest.    .@name$ = "Hunting:"; // Start of the quest name.        // Loop the below until the selected amount of objectives have been added to the proper variables.    while( .@b != .@a ){	.@i = rand(1001,3000); // Selecting a random mob_id # from 1001 (Scorpion) -> 3000 ( Just going beyond what exists to add support for custom mobs ).	if( !compare( .blacklist$, ""+ getmonsterinfo( .@i, 0 ) +"" ) ){ // Compares monster ID number to see if it is blacklisted or not.		.@mob_objectives[.@b] = .@i; // Adds the monster as an objective.		.@mob_obj_amount[.@b] = rand(.min_hunting_amount, .max_hunting_amount); // Adds a random amount to be killed to complete that objective.		.@name$ = .@name$ + getmonsterinfo( .@i, 0 ); // Adds the monster's name as part of the quest name.	        .@b++;		}	}        // We create an entry in our custom quest_database using just the Quest name for now.        // This will serve as a pointer when adding in all the objectives later, since the amounts were dynamically chosen and not set in stone.	query_sql("INSERT INTO quest_database `quest_name` = '"+ .@name$ +"'");        // Loop through this until ALL objectives & the amount needed to complete it, have been added to the quest we listed above.	while( .@c < getarraysize( .@mob_objectives ) ){                // Adding in each objective and it's amount to the quest we just created above.		query_sql("Update quest_database SET( `obj"+ .@c +"`, `amt"+ .@c +"'`) VALUES( '"+.@mob_objectives[.@c]+"', '"+.@mob_obj_amount[.@c]+"') WHERE `quest_name`='"+ .@name$ +"'");		.@c++;	}        // Set this variable +1 to say we have completed creating a quest. And to continue looping if not all of them have been created.	.@hunting++;}// Freeloop(0) to let server know we are done looping and to stop trying to prevent infinite loops.freeloop(0);end;// This is where the settings go to configure the above to do what you want.OnInit:.hunting_generate = 3; // How many hunting quests to create and add to sql.// Minimum and Maximum amount of different monsters to be used as an objective..min_hunting_objective = 1;.max_hunting_objective = 5; // Note - This can not be higher than the number of objectives listed in your sql table. So if your sql table only supports 3, this can be no higher than 3.// Minimum and Maximum amount to be killed for each objective..min_hunting_amount = 5;.max_hunting_amount = 20;// Bonus, a custom command that when used, will attempt to create a (.hunting_generate) more quests and add them to the database.bindatcmd "huntgen", strnpcinfo(3)+"::OnHuntingCreate";end;}

 

It's untested, but if it works, it should generate 3 hunting quests, with random amount of 1-5 different monsters to hunt, ranging from 5-20 of each to kill. And place them into a sql database.

Thanks But I managed to get with my own designed script.. it was updated .. you can see it again. An many thanks to your script it helped a lot.  +1 for you. As also you can see It take me long time to manage to get till this part which take  5 to 10 mins for a Good Scripter like you.

 

EDIT: I WILL TEST THIS SCRIPT TOO AND TRY TO OPTIMIZE MY SCRIPT.

Edited by anticlimax18

Share this post


Link to post
Share on other sites
  • 0

Step 2: Of your requests, can easily be done like this:

// Sets .@size to the amount of quests we were able to grab that fits our query.// Our query says to select all information from any quest that isn't taken yet.// This is determined by assuming if a quest is taken, the `taker_id` will be filled with that player's character id#..@size = query_sql("SELECT * FROM quest_database WHERE `taker_id`='0' AND `type`='hunting'", .@quest_name$, .@quest_id, .@poster_name$, .@obj1, .@amt1); // Etc, just add variables as you need them to match the table in your database..@select = 4; // We set this to 4 so we can use our loop below and not have to worry about anything else.while( .@select == 4 ){ // As long as player keeps selecting the 4th option in the menu it will repeat this loop.	.@sel_quest = 0; // Set this to 0 here to reset the variable for use in the loop below.	.@quest_menu$ = ""; // Again, set this variable to "" to reset the variable for use in the loop below.	while( .@sel_quest != 3 ){ // This attempts to grab 3 different quests and present them as options for the player.		.@temp_variable = rand( getarraysize( .@quest_name$ ) ); // Randomly select a quest.		if( !compare( .@quest_menu$, .@quest_name$[.@temp_variable] ) ){ // Checks to see if we already chose this quest.			// Since we didn't use this one before we put it in the menu.			.@quest_menu$ = .@quest_menu$ +":"+ .@quest_name$[.@temp_variable];			.@sel_quest++; // Set to +1 to let loop know we selected a quest.		}	}	// We finished selecting our quests, now we just add a 4th option to the menu saying more quests.	.@quest_menu$ = .@quest_menu$ +":[^0000FF More Quests ^000000]";		// Then we present them with the menu and have them decide.	.@select = select( .@quest_menu$ );}// If they selected a menu option that was not [More Quests], then they come here, other wise they stay in the loop.// Here we update the sql table with the player's character id# in the taker's position to say they accepted the quest.// This is also where you begin to set things up to track their progress.

That's the basics for making the player choose a quest, that has been previously generated from a specified type.

Edited by GmOcean

Share this post


Link to post
Share on other sites
  • 0

Ohh thanks Again!! Yeah I was about to work on that and you replied  :lol:

Nice Name-The-Quest-Thingy Idea You gave me.

 

I will create an input for player so they can name their Quest.

 

I am trying to achieve a new way of Quest system... I know it my look similar to old ways but here its Like being Paid By the Player Publishing the Quest While the publisher get reward if the Quest is successfully completed without Dying 5 times or Logging out while battling. (however it comes). Else It Quest Fails and will go into Abandon/ Failed Quest. So it can be taken again.The Trickier Part for me will be to figure out how to track them if they are in battle or not.

 

SO not only players will try to avoid death by also Logging out. ;)

Share this post


Link to post
Share on other sites
  • 0

Okay, first ' bug ' I found was a mistake on my part, just need to make 2 changes.

1:

.@quest_menu$ = .@quest_menu$ +":"+ .@quest_name$[.@temp_variable];TO.@quest_menu$ = .@quest_menu$ + .@quest_name$[.@temp_variable] +":";

2:

.@quest_menu$ = .@quest_menu$ +":[^0000FF More Quests ^000000]";TO.@quest_menu$ = .@quest_menu$ +"[^0000FF More Quests ^000000]";

 

My apologizes. Was pretty tired when I wrote it originally. At any rate, it needs to be changed as such, or the menu options will be pushed down 1.

It's a small simple fix. But would have caused a lot of problems when trying to create a quest. All the information would have been messed up @.@;

 

As for tracking the quest takers, just use the labels: OnNPCKillEvent:  &  OnPCLogoutEvent: & OnPCDieEvent:

 

Example of tracking when logging out:

OnPCLogoutEvent:query_sql("UPDATE `database` SET `taker_id` VALUE '0' WHERE `taker_id` = '"+ getcharid(3) +"'");end;

That would essentially erase their ID from the custom quest database's taker id, making the quest available again.

 

Example of when the player dies:

OnPCDieEvent:if( countstr( ""+ killerrid +"" ) >= 7 && killerrid != getcharid(3) ){ end; } // Player died in PvP Combat, and did not commit suicide. Shouldn't count against them.@quest_death++; // Player either was killed by a monster or committed suicide.if( @quest_death >= .quest_death_limit ){ // Player died too many times so remove all his quests.    @quest_death = 0;    deletearray @quests$; // This would be an example of the array which holds all the data for his quests.    query_sql("UPDATE `database` SET `taker_id` VALUE '0' WHERE `taker_id` = '"+ getcharid(3) +"'");    dispbottom "You have died too many times to monsters. You have abandoned all of your quests.";}end;

 

Finally example of tracking when he kills a monster:

OnNPCKillEvent:for( .@i = 0; .@i < getarraysize( @quests$ ); .@i++ ){	explode( .@tmp_array$, @quests$[.@i] );	// .@tmp_array$[0] = Quest Name	// .@tmp_array$[1] = Monster (Objective) name	// .@tmp_array$[2] = Amount (kill, collect, etc...)	// .@tmp_array$[3] = Total needed. (kill, collect, etc...)		// Now we check to see if the monster we killed was a requirement for a quest the player has.	if( killedrid == .@tmp_array$[1] ){		//The monster was a requirement so we add +1 kills.		.@tmp_array$[2] = ""+ ( atoi( .@tmp_array$[2] ) + 1 ) +"";				// Check the amount we killed against the amount we need to kill.		if( .@tmp_array$[2] >= .@tmp_array$[3] ){			// We killed more or just enough so now we give player reward and remove quest.			// Get reward.                        getitem(501,1);			// remove quest from sql_database			query_sql("DELETE * FROM `database` WHERE `quest_name` = '"+ .@tmp_array[0]$ +"'");			// Now that player got their reward, it's time to erase the quest from the player's tracker.			@quests$[.@i] = "";		}	}}// Nothing else to do here so we end it.end;

 

To use my example of tracking when they kill a monster you need to store the quest information in a certain way when they accept the quest:

@quests$[getarraysize(@quests$)] = ""+ .@name$ +":"+ .@mob_id +":"+ 0 +":"+ .@kill_required +"";

This will store all the data of 1 quest into a single 'element' with in the array. Meaning that each player will be able to keep track of 2.1billion quests at a time.

 

This method will work for tracking monster kills. However, for cooking / gathering tracking, that would probably just be handled by countitem(<item_id>);

Edited by GmOcean

Share this post


Link to post
Share on other sites
  • 0

Still Need Help!!

 

  1. I am not able to list the Quest properly
  2. Not able to show Info while they select it
  3. not able to understand how to properly use arrays here

I Just want someone to take my script and fix that part out. I will add you in credit as I will Release this script once done.

Share this post


Link to post
Share on other sites
  • 0

Well, I wrote a variation of your script, but it's not 100% complete, nor am I fully positive it's working 100%, but script_checker says there is no errors in the syntax. Perhaps, you can use it for a comparison to your code, and find the results you need:

prontera,164,167,0	script	Quest Master	857,{mes ( .@npc$ = "[^FF0000 Quest Master ^000000" );mes "[^00FF00 Generate Requirement ^000000]";mes ""+ getitemname(.currency[0]) +" x "+ .currency[1] +"";mes "[^0000FF Taking Requirement ^000000]";mes ""+ getitemname(.currency[2]) +" x "+ .currency[3] +"";next;mes .@npc$;switch( select( "[Turn in all quests]", "[Obtain Quest]", "[Abandon Quest]", "[Generate Quests]"+ ( (getgmlevel() >= 99)?":[Generate Random Quests]" : "" )+"" ) ){	case 1:		for( .@i = 0; .@i < getarraysize( @quests$ ); .@i++ ){			explode( .@array$, @quests$[.@i], ":" );			switch( atoi(.@array$[5]) ){				case 1:					if( .@array$[4] == .@array$[3] ){						.@quests[.@a] = atoi( .@array$[6] );						.@a++;					}					break;				case 2:				case 3:					if( countitem( atoi(.@array$[2]) ) == atoi(.@array$[3]) ){						.@quests[.@a] = atoi( .@array$[6] );						.@a++;					}					break;			}		}		if( !.@quests[0] ){			mes "You don't have any completed quests.";			close;		}		getitem .currency[0], (.currency[1] * getarraysize(.@quests));		for( .@i = 0; .@i < getarraysize( @quests$ ); .@i++ ){			explode( .@array$, @quests[.@i], ":" );			for( .@j = 0; .@j < getarraysize( .@quests ); .@j++ ){				if( .@quests[.@j] == .@array$[6] ){					@quests[.@i] = "";					.@quests$ = .@quests$ + ""+ .@array$[6] +":";				}			}		}		callsub iRedeem, .@quests$; // Updates quests to have a reward so posters can redeem it.		mes "All quests have been redeemed.";		mes "Come back again, and complete some more.";		close;							case 2:		if( max_active && ( getarraysize(@quests$) >= .max_active ) ){			mes "You can not actively pursue any more quests at the moment.";			mes "You need to either complete your current quests or abandoned them.";			close;		}		mes "Only a maximum of "+ .select_limit +" available quests will be listed from a category at a time.";		mes "Select a category.";		next;		mes .@npc$;		.@select = select( "[Hunting] - [Random Difficulty]", "[Item Gather] - [Random Difficulty]", "[Cooking] - [Hard Difficulty]");		.@count = query_sql("SELECT * FROM `Paid_Quest` WHERE `TrackID` = '0' AND `type` = '"+ .@select +"'", .@quest_id, .@name$, .@pub_id, .@track_id, .@mob_id, .@itme_id, .@tar_amt, .@type, .@time);		if( !.@count ){			mes "There are no quests of this type available at this time.";			close;		}		iQSelectLoop:			if( .@count < ( .select_limit ) ){				.@select2 = ( .@count + 1 );			} else {				.@select2 = ( .select_limit + 1 );			}			.@select = .@select2;			while( .@select == .@select2 ){				.@quest_menu$ = "";				.@i = 1;				while( .@i < .@select2 ){					.@a = rand( getarraysize(.@name$) );					if( !compare( .@quest_menu$, .@name$[.@a] ) ){						.@quest_menu$ = .@quest_menu$ + .@name$[.@a] +":";						.@quest_select[.@i] = .@a;						.@i++;					}				}				.@quest_menu$ = .@quest_menu$ + "[^0000FF More Quests ^000000]";				.@select = select(	.@quest_menu$ );			}			.@a = .@quest_select[.@select];			mes .@name$[.@a];			switch( .@type[0] ){				case 1:					mes "Objective: "+ getmonsterinfo( .@mob_id[.@a], 0 ) +"";					mes "Kill amount: "+ .@tar_amt[.@a] +"";					break;				case 2:				case 3:					mes "Objective: "+ getitemname( .@item_id[.@a] ) +"";					mes ""+ ( (.@type[0] == 2)? "Collect Amount" : "Cook Amount" ) +": "+ .@tar_amt[.@a] +"";					break;			}			mes "----------------------------------";			mes "Do you accept?";			next;			if( select( "Yes, I accept", "No, let me choose another" ) == 2 ){				callsub iQSelectLoop;				end;			}			@quests$[getarraysize(@quests$)] = .@name$[.@a] +":"+ .@mob_id[.@a] +":"+ .@item_id[.@a] +":"+ .@tar_amt[.@a] +":"+ 0 +":"+ .@type[0] +":"+ .@quest_id[.@a] +"";			query_sql("UPDATE `Paid_Quest` SET(`TrackID`) VALUES('"+ getcharid(0) +"') WHERE `id` = '"+ .@quest_id[.@a] +"'");			mes .@npc$;			mes "Quest Accepted.";			mes "All quests will be abandoned upon logging out.";			close;				case 3:			mes "Did you want to abandon all your quests, or a specific one?";			next;			mes .@npc$;			if( select( "One quest", "All quests" ) == 2 ){				@quests$ = "";				mes "All quests have been abandoned.";				close;			}			for( .@i = 0; .@i < getarraysize(@quests$); .@i++ ){				explode( .@array$, @quests$[.@i], ":" );				.@quest_menu$ = .@quest_menu$ + .@array$[0] +":";			}			mes "Which quest did you want to abandon?";			next;			.@select = select( .@quest_menu$ );			explode( .@array$, @quests$[( .@select - 1 )], ":" );			mes .@array$[0];			switch( .@array$[5] ){				case 1:					mes "Objective: "+ getmonsterinfo( .@array$[1], 0 ) +"";					mes "Progress: "+ .@array$[4] +" / "+ .@array$[3] +"";					break;								case 2:				case 3:					mes "Objective: "+ getitemname( .@array$[2] ) +"";					mes "Progress: "+ countitem( .@array$[2] ) +" / "+ .@array$[3] +"";					break;			}			mes "----------------------------------";			mes "Are you sure you want to abandon this quest?";			next;			if( select( "Yes, abandon the quest.", "No, I've changed my mind." ) == 2 ){ close; }			@quests$[( .@select - 1)] = "";			mes "Quest has been abandoned.";			close;					case 4:			// Only Item Collection quests are available to create as of now.			mes "What item did you want to post for a quest?";			input .@item;			if( !getitemname( .@item ) == "null" ){				mes "^^FF0000 INVALID ITEM";				close;			}			mes "How many did you want to request?";			mes "Minimum: 1","Maximum: 1,000";			input .@amt,1,1000;			query_sql("INSERT INTO `Paid_Quests` (`name`,`pub_id`,`item_id`,`tar_amt`,`type`,`time`) VALUES('"+ escape_sql("Collection: "+ getitemname(.@item) +"") +"','"+ getcharid(0) +"','"+ .@item +"','"+ .@amt +"','2','"+ gettimetick(2) +"')");			next;			mes "Quest, successfully submitted.";			close;					case 5:			// GM only quest generator.			end;}iRedeem:explode( .@array$, getarg(0), ":" );for( .@x = 0; .@x < getarraysize( .@array$ ); .@x++ ){	query_sql("UPDATE `Paid_Quests` SET(`reward`) VALUES('1') WHERE `id` = '"+ atoi(.@array$[.@x]) +"'");}return;end;OnInit:// [0] = Item Required to post a quest. | [1] = Amount needed.// [2] = Item Required to accept a quest. | [3] = Amount needed.setarray .currency[0], 501, 5, 502, 1;// Amount of quests to post at a time.// Default: 3.select_limit = 3;// [0] = Start of Food item IDs// [1] = End of Food item IDs.setarray .cook_id[0], 12040, 12100;// Max amount of quests each player can actively pursue at a time.// Default: 3.max_active = 3;end;}// SQL TABLE TO BE USED./*CREATE TABLE `master_main`.`paid_quests` (  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,  `name` VARCHAR(255) NOT NULL,  `pub_id` INT(11) NOT NULL,  `TrackID` INT(11) NOT NULL DEFAULT 0,  `mob_id` INT(11) NOT NULL DEFAULT 0,  `item_id` INT(11) NOT NULL DEFAULT 0,  `tar_amt` INT(11) NOT NULL DEFAULT 0,  `type` INT(11) NOT NULL DEFAULT 0,  `time` BIGINT NOT NULL DEFAULT 0,  PRIMARY KEY (`id`),  UNIQUE INDEX `id_UNIQUE` (`id` ASC));*/

 

*Note - This hasn't been tested. Reason being, I do not want to setup a sql table, add quests and the such to do the testing for this. You can post back errors, you find and I'll will provide support for it, but right now I'm not going to alter my sql schemas*.

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
Answer this question...

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