Hello rA, i need help please today i found this script and its looks like what i want but need more feature this is the script
//===== rAthena Script =======================================
//= Quest System - SQL
//===== By ===================================================
//= lllchrislll
//===== Version ==============================================
//= 1.0 - Initial Release
// - Added OnAtcommand (@checkquest) for Quest Progress Display per request
// also an info for the players of the existence of that command
// - Added the "feature" to benefit from joining an party
// - Modified Level Requirement Setting (See 'OnInit:')
// 0 = Off / MAX_LEVEL - Server Max Level (src/map/map.h)
// - Added an setting to define the Array Limit, to make it compatible with
// older revisions, which doesn't have the Script Engine Upgrade (See 'set .array')
// - Fixed @checkquest command, by showing an wrong quantity for Monster Hunting Quests
// Thanks to Azeroth for the bug report
//= 1.1 - Fixed an bug, to go over the required mob quantity
// - Modified the code when an Mob gets killed that the value in the database will be
// updated immediately
// - Removed the variable "MobHunt_"+<MobID>"
// - Modified the code about "MobHunt_"+<MobID>+"_CT" to increase it's value
// in case there is another quest with the same required mob (= Total Mob Counter)
//===== Compatible With ======================================
//= rAthena SQL 11.06.2015 Rev+
//===== Tested With ==========================================
//= rAthena SQL 11.06.2015 Rev
//===== Description ==========================================
//= Every NPC has an unique ID and can hold up .array Quests
// You can put as many as you want Quest NPC's on one map.
//= Quests:
// - Monster Hunting
// - Item Collecting
// - Level Requirement
// - Quest Limit
// (How many times you can repeat the same quest)
// - Quest Delay
// - On Login Progress Display
//===== Comments =============================================
//= None yet...
//===== Modification Requests =============================================
//= Custom @checkquest to display your Quest Progress by Azeroth
//===== SQL Tables ==========================================
/*
CREATE TABLE IF NOT EXISTS `quest_list` (
`npc_id` int(10) unsigned NOT NULL default '1',
`quest_id` int(10) unsigned default '1',
`quest_type` tinyint(3) unsigned default '1',
`mob_id` int(10) unsigned default '0',
`mob_am` int(12) unsigned default '0',
`item_id` int(10) unsigned default '0',
`item_am` int(10) unsigned default '0',
`reward_id` int(10) unsigned default '0',
`reward_am` int(10) unsigned default '0',
`limit` tinyint(3) unsigned default '0',
`level` int(10) unsigned default '0'
) ENGINE=MyISAM;
CREATE TABLE IF NOT EXISTS `quest_npc` (
`npc_id` int(10) unsigned NOT NULL default '1',
`npc_name` varchar(255) default 'NewNPC',
`npc_map` varchar(25) default 'prontera',
`npc_x` tinyint(5) unsigned default '0',
`npc_y` tinyint(5) unsigned default '0',
PRIMARY KEY (`npc_id`)
) ENGINE=MyISAM;
CREATE TABLE IF NOT EXISTS `quest_map` (
`map` varchar(255) NOT NULL default 'prontera',
`npc_count` int(5) unsigned,
PRIMARY KEY (`map`)
) ENGINE=MyISAM;
CREATE TABLE IF NOT EXISTS `quest_player` (
`char_id` int(15) unsigned NOT NULL,
`npc_id` int(10) unsigned NOT NULL,
`quest_id` int(10) unsigned NOT NULL,
`mob_id` int(10) unsigned default '0',
`mob_am` int(12) unsigned default '0'
) ENGINE=MyISAM;
*/
dor_in01,174,233,5 script Quest System 474,{
function QSys_Delete;
mes .n$;
mes "Hello, "+strcharinfo(0)+"!";
if(getgroupid() < .gm) {
mes "Would you like some information about the quest system?";
next;
if(select("- Yes:- No") - 1) close;
mes .n$;
mes "Good to hear!";
mes " ";
mes "[==== Quest Types ====]";
mes "- Monster Hunting";
mes "- Item Collecting";
mes " ";
mes "The following values depends on the quest itself.";
next;
mes "[== Monster Hunting ==]";
mes "The maximum amount of mobs, which can be hunted at once is "+.mob_ct+".";
mes "The maximum amount per mob to be hunted is "+.mob_max+".";
mes "Each quest also has an level requirement.";
next;
mes "[== Item Collecting ==]";
mes "The maximum amount of items, which can be collected at once is "+.item_ct+".";
mes "The maximum amount per item to be collected is "+.item_max+".";
next;
mes "[== Custom @Command ==]";
mes "To help you, to check your quest progresses anytime and anywhere, there is an custom @command, which is \"@checkquest\".";
next;
mes "[== Quest Limit & Delay ==]";
mes "Each quest has an limit how often it can be done in a row.";
mes "This limit resets itself, when the quest was done often enough.";
mes "After that limit, an delay comes active.";
mes " ";
mes "Current Delay Setting:";
switch(.q_del_type) {
case 1: set .@q_t$,"Hour(s)"; break;
case 2: set .@q_t$,"Day(s)"; break;
case 3: set .@q_t$,"Week(s)"; break;
case 4: set .@q_t$,"Month(s)"; break;
}
mes .q_del_multi+"x "+.@q_t$;
next;
mes "[ === Rewards ===]";
mes "- Zeny";
mes " > Maximum Amount: "+.rew_zeny;
mes "- Cash Points";
mes " > Maximum Amount: "+.rew_cash;
mes "- Items";
mes " > Maximum Amount per Item: "+.rew_item;
close;
}
if($@q_tab$[0] == "") {
mes "It seems like the database tables weren't created yet.";
mes "I would recommend you to do that first.";
next;
mes .n$;
}
mes "How can I help you?";
next;
switch(select("- Overview:- Quest Management:- "+( ($@q_tab$[0] == "")?"Create":"Delete")+" SQL Tables:- Nothing")) {
case 1:
mes .n$;
query_sql "SELECT DISTINCT `npc_id` FROM `quest_list` WHERE `npc_id` != '0'",.@n_ids;
for( set .@n,0; .@n < getarraysize(.@n_ids); set .@n,.@n + 1) {
query_sql "SELECT DISTINCT `quest_id` FROM `quest_list` WHERE `npc_id` = '"+.@n_ids[.@n]+"'",.@q_ids;
set .@q_total,.@q_total + getarraysize(.@q_ids);
deletearray .@q_ids[0],getarraysize(.@q_ids);
}
mes "Total Quests: "+.@q_total;
mes "Total NPCs: "+getarraysize(.@n_ids);
mes " ";
mes "[==== Quests per NPC ====]";
for( set .@l,0; .@l < getarraysize(.@n_ids); set .@l,.@l + 1) {
query_sql "SELECT `npc_name` FROM `quest_npc` WHERE `npc_id` = '"+.@n_ids[.@l]+"'",.@n_name$;
query_sql "SELECT DISTINCT `quest_id` FROM `quest_list` WHERE `npc_id` = '"+.@n_ids[.@l]+"'",.@q_ids;
mes "- "+.@n_name$+": "+getarraysize(.@q_ids);
deletearray .@q_ids[0],getarraysize(.@q_ids);
}
break;
case 2:
mes .n$;
mes "===[Quest Management]===";
mes "Please choose from below on which map the npc is located:";
mes "\"()\" is the quantity of NPCs on this map.";
query_sql "SELECT `map` , `npc_count` FROM `quest_map`",.@n_maps$,.@n_ct;
for ( set .@l,0; .@l < getarraysize(.@n_maps$); set .@l,.@l + 1)
set .@m_menu$,.@m_menu$ + "- "+.@n_maps$[.@l] + "("+.@n_ct[.@l]+")" + ((.@n_maps$[.@l+1] != "")?":":"");
next;
set .@map,select(.@m_menu$) - 1;
mes .n$;
mes "You have chosen the following map:";
mes .@n_maps$[.@map];
mes " ";
mes "Is this correct?";
if(select("- Yes:- No") - 1) close;
next;
mes .n$;
mes "Please choose to which NPC you want to edit the Quests:";
query_sql "SELECT `npc_id` , `npc_name` FROM `quest_npc` WHERE `npc_map` = '"+.@n_maps$[.@map]+"'",.@n_id,.@n_name$;
for ( set .@m,0; .@m < getarraysize(.@n_name$); set .@m,.@m + 1)
set .@npc_menu$,.@npc_menu$ + "- "+.@n_name$[.@m]+" (ID#"+.@n_id[.@m]+")"+( (.@n_name$[.@m+1] == "")?"":":");
next;
set .@npc_c,select(.@npc_menu$) - 1;
mes .n$;
mes "What do you like to do?";
next;
switch(select("- Add Quests:- Remove Quests:- Nothing")) {
case 1:
mes .n$;
if(query_sql("SELECT `quest_id` FROM `quest_list` WHERE `npc_id` = '"+.@n_id[.@npc_c]+"'",.@q_list) >= .array) {
mes "I'm sorry, but you can't add anymore quests to this NPC, please try another one.";
close;
}
if(getarraysize(.@q_list) == 0)
set .@que_id,1;
else
set .@que_id,.@q_list[getarraysize(.@q_list) - 1] + 1;
mes "Please choose what type of quest it will be:";
next;
set .@type,select("- Monster Hunting:- Item Collecting");
set .@count,0;
mes .n$;
// Monster Hunting
if(.@type == 1) {
mes "How many mobs should be hunted?";
mes "^FF0000Note: Maximum "+.mob_ct+"^000000";
if(input(.@ct,1,.mob_ct) != 0) {
next;
mes .n$;
mes "Invalid Amount, please try again.";
close;
}
next;
mes .n$;
mes .@ct+" Mobs should be hunted.";
mes " ";
mes "Now choose the level requirement:";
mes "^FF0000Note: '0' is invalid!^000000";
mes "^FF0000Note: You can't go over the maximum level of the server, which is "+.level+"!^000000";
if(input(.@lvl,1,.level) != 0) {
next;
mes .n$;
mes "Invalid Level, please try again.";
close;
}
next;
mes .n$;
mes "Level Requirement: "+.@lvl;
while(.@count < .@ct) {
next;
mes .n$;
mes "Please type the Mob ID for #"+(.@count+1)+", which should be hunted:";
next;
input .@mobid;
mes .n$;
if(strmobinfo(1,.@mobid) == "null" || strmobinfo(1,.@mobid) == "") {
mes "Mob not found, please be sure that you have typed the ID correctly and try again.";
continue;
}
mes "Mob Name: "+strmobinfo(1,.@mobid);
mes " ";
mes "Now type the amount to hunt:";
mes "Minimum: "+.mob_min+", Maximum: "+.mob_max;
next;
if(input(.@mobam,.mob_min,.mob_max) != 0) {
mes .n$;
mes "Invalid Amount, please try again.";
continue;
}
mes .n$;
mes "Mob Name: "+strmobinfo(1,.@mobid)+" ("+.@mobid+")";
mes "Mob Quantity: "+.@mobam;
mes " ";
mes "Is this correct?";
if(select("- Yes:- No") - 1) continue;
query_sql "INSERT INTO `quest_list` ( `npc_id` , `quest_id` , `quest_type` , `mob_id` , `mob_am` ) VALUES ( '"+.@n_id[.@npc_c]+"', '"+.@que_id+"' , '"+.@type+"' , '"+.@mobid+"' , '"+.@mobam+"' )";
set .@count,.@count + 1;
}
query_sql "UPDATE `quest_list` SET `level` = '"+.@lvl+"' WHERE `npc_id` = '"+.@n_id[.@npc_c]+"' AND `quest_id` = '"+.@que_id+"'";
// Item Collecting
} else if(.@type == 2) {
mes "How many items do you want to add?";
mes "^FF0000Note: Maximum "+.item_ct+"^000000";
if(input(.@ct,1,.item_ct) != 0) {
next;
mes .n$;
mes "Invalid Amount, please try again.";
close;
}
next;
mes .n$;
mes .@ct+" Items should be collected.";
mes " ";
while(.@count < .@ct) {
next;
mes .n$;
mes "Type the Item ID for #"+(.@count+1)+":";
next;
input .@itemid;
mes .n$;
if(getitemname(.@itemid) == "null" || getitemname(.@itemid) == "") {
mes "The ID "+.@itemid+" doesn't exist. Please try again.";
continue;
}
mes "Item: "+getitemname(.@itemid);
mes " ";
mes "Type the amount to collect next:";
mes "^FF0000Note: Minimum: "+.item_min+", Maximum: "+.item_max+"^000000";
next;
if(input(.@itemam,.item_min,.item_max) != 0) {
mes .n$;
mes "Invalid Amount, please try again.";
continue;
}
mes .n$;
mes "Item: "+getitemname(.@itemid)+" ("+.@itemid+")";
mes "Amount: "+.@itemam;
mes " ";
mes "Correct?";
if(select("- Yes:- No") - 1) continue;
query_sql "INSERT INTO `quest_list` ( `npc_id` , `quest_id` , `quest_type` , `item_id` , `item_am` ) VALUES ( '"+.@n_id[.@npc_c]+"', '"+.@que_id+"' , '"+.@type+"' , '"+.@itemid+"' , '"+.@itemam+"' )";
set .@count,.@count + 1;
}
}
next;
mes .n$;
mes "Next is the Quest Limit, type the value it should be:";
mes "^FF0000Note: 0 is Unlimited and "+(.q_max_limit+1)+" is Cancel^000000";
if(input(.@limit,0,.q_max_limit) != 0) {
mes .n$;
mes "You have put an Invalid Limit, please try again.";
mes "^FF0000Note: 0 is Unlimited and "+(.q_max_limit+1)+" is Cancel^000000";
next;
if(input(.@limit,0,.q_max_limit) != 0) {
mes .n$;
mes "You have put an Invalid Limit again, aborting quest creation.";
QSys_Delete(.@que_id,.@n_id[.@npc_c]);
close;
}
}
query_sql "UPDATE `quest_list` SET `limit` = '"+.@limit+"' WHERE `npc_id` = '"+.@n_id[.@npc_c]+"' AND `quest_id` = '"+.@que_id+"'";
next;
mes .n$;
mes "Now put the reward:";
mes " > Zeny = 1";
mes " > Cash Points = 2";
mes " > Item = Item ID";
input .@rew_1;
next;
mes .n$;
if(.@rew_1 == 0 || (.@rew_1 > 2 && .@rew_1 < 512)) {
mes "You have put an invalid Reward.";
mes "Aborting Quest creation";
QSys_Delete(.@que_id,.@n_id[.@npc_c]);
close;
}
if(.@rew_1 >= 512 && (getitemname(.@rew_1) == "null" || getitemname(.@rew_1) == "") ) {
mes "You have put an invalid Item ID.";
mes "Aborting Quest creation";
QSys_Delete(.@que_id,.@n_id[.@npc_c]);
close;
}
mes "Chosen Reward: "+( (.@rew_1 == 1)?"Zeny": ( (.@rew_1 == 2)?"Cash Points":"Item: "+getitemname(.@rew_1)));
mes "Now the amount:";
mes " - Maximum Zeny: "+.rew_zeny;
mes " - Maximum Cash Points: "+.rew_cash;
mes " - Maximum Item Amount: "+.rew_item;
input .@rew_2;
next;
mes .n$;
switch(.@rew_1) {
// Zeny Reward
case 1: if(.@rew_2 > .rew_zeny) set .@f,1; break;
// Cash Points Reward
case 2: if(.@rew_2 > .rew_cash) set .@f,1; break;
// Item Reward
default:
if(.@rew_2 > .rew_item)
set .@f,1;
else if(checkweight(.@rew_1,.@rew_2) != 1)
set .@f,2;
break;
}
if(.@f) {
mes "I'm sorry, but the reward amount you have put is higher than the limit.";
if(.@f == 2) mes "To precise - Weight limit of "+.rew_weight+" has been reached. "+.@rew_2+"x "+getitemname(.@rew_1)+" would weight "+(.@rew_2*getiteminfo(.@rew_1,6))+".";
mes "Aborting Quest creation";
QSys_Delete(.@que_id,.@n_id[.@npc_c]);
close;
}
query_sql "UPDATE `quest_list` SET `reward_id` = '"+.@rew_1+"' , `reward_am` = '"+.@rew_2+"' WHERE `npc_id` = '"+.@n_id[.@npc_c]+"' AND `quest_id` = '"+.@que_id+"'";
mes "The Quest ID#"+.@que_id+" has been added successfully.";
break;
// Deleting Quests
case 2:
mes .n$;
query_sql "SELECT `quest_id` FROM `quest_list` WHERE `npc_id` = '"+.@n_id[.@npc_c]+"'",.@q_list;
if(getarraysize(.@q_list) < 1) {
mes "I'm sorry, but you can't remove quests from this NPC, because there are none yet. Please try another one.";
close;
}
mes "Please choose, which Quest you want to remove:";
for ( set .@q,0; .@q < getarraysize(.@q_list); set .@q,.@q + 1) {
if(.@q > 1)
if(.@q_list[.@q] == .@q_list[.@q-1]) {
deletearray .@q_list[.@q],1;
continue;
}
set .@r_menu$,.@r_menu$ + "- ID#"+.@q_list[.@q]+ ( (.@q_list[.@q+1] != 0)?":":"");
}
next;
set .@rem,select(.@r_menu$) - 1;
mes .n$;
mes "Do you really want to remove the Quest with the ID '"+.@q_list[.@rem]+"'?";
if(select("- Yes:- No") - 1) close;
next;
mes .n$;
mes "The Quest with the ID '"+.@q_list[.@rem]+"' has been removed successfully.";
// Deleting Delay Variables from the database
query_sql "DELETE FROM `global_reg_value` WHERE `str` = 'QSys_"+.@n_id[.@npc_c]+"_"+.@q_list[.@rem]+"_Limit'";
query_sql "DELETE FROM `global_reg_value` WHERE `str` = 'QSys_"+.@n_id[.@npc_c]+"_"+.@q_list[.@rem]+"_QDelay'";
QSys_Delete(.@q_list[.@rem],.@n_id[.@npc_c]);
break;
case 3:
break;
}
close;
case 3:
mes .n$;
if($@q_tab$ == "") {
// Quest Table
query_sql "CREATE TABLE IF NOT EXISTS `quest_list` ( `npc_id` int(10) unsigned NOT NULL default '1', `quest_id` int(10) unsigned default '1', `quest_type` tinyint(3) unsigned default '1', `mob_id` int(10) unsigned default '0', `mob_am` int(12) unsigned default '0', `item_id` int(10) unsigned default '0', `item_am` int(10) unsigned default '0', `reward_id` int(10) unsigned default '0', `reward_am` int(10) unsigned default '0', `limit` tinyint(3) unsigned default '0', `level` int(10) unsigned default '0' ) ENGINE=MyISAM";
// NPC Table
query_sql "CREATE TABLE IF NOT EXISTS `quest_npc` ( `npc_id` int(10) unsigned NOT NULL default '1', `npc_name` varchar(255) default 'NewNPC', `npc_map` varchar(25) default 'prontera', `npc_x` tinyint(5) unsigned default '0', `npc_y` tinyint(5) unsigned default '0', PRIMARY KEY (`npc_id`) ) ENGINE=MyISAM";
// Map Table
query_sql "CREATE TABLE IF NOT EXISTS `quest_map` ( `map` varchar(255) NOT NULL default 'prontera', `npc_count` int(5) unsigned, PRIMARY KEY (`map`) ) ENGINE=MyISAM";
// Player Data
query_sql "CREATE TABLE IF NOT EXISTS `quest_player` ( `char_id` int(15) unsigned NOT NULL, `npc_id` int(10) unsigned NOT NULL, `quest_id` int(10) unsigned NOT NULL, `mob_id` int(10) unsigned default '0', `mob_am` int(12) unsigned default '0' ) ENGINE=MyISAM";
mes "The tables have been created.";
} else {
query_sql "DROP TABLE IF EXISTS `quest_list`";
query_sql "DROP TABLE IF EXISTS `quest_npc`";
query_sql "DROP TABLE IF EXISTS `quest_map`";
query_sql "DROP TABLE IF EXISTS `quest_player`";
mes "The tables have been deleted.";
}
break;
case 4:
break;
}
close;
function QSys_Delete {
// getarg(0) = Quest ID
// getarg(1) = NPC ID
query_sql "DELETE FROM `quest_list` WHERE `npc_id` = '"+getarg(1)+"' AND `quest_id` = '"+getarg(0)+"'";
query_sql "DELETE FROM `quest_player` WHERE `npc_id` = '"+getarg(1)+"' AND `quest_id` = '"+getarg(0)+"'";
return;
}
OnInit:
set $@QSys,0; // Quest System not loaded yet
set .n$,"["+strnpcinfo(1)+"]";
set .gm,60; // GM Access Level
// Server Array Limit
// > rAthena since commit 6295c77 (Script Engine Upgrade):
// = 2000000000000 (2 Billion)
// > Others/Default: 128
set .array,128;
// ===== Quest Settings =====
// Minimum and Maximum Mob Amount
set .mob_min,1;
set .mob_max,1000;
// Maximum Mobs you can hunt at the same time
set .mob_ct,100;
// Level Restriction
set .level,150; // 0 = Off / MAX_LEVEL - Server Max Level (src/map/map.h)
// Minimum and Maximum Item Amount
set .item_min,1;
set .item_max,1000;
// Maximum Items you can collect at the same time
set .item_ct,100;
// ==== Quest Delay Settings ======
// * Max Quest Limit:
// (How often an quest can be done till the delay below comes active)
// Note: Don't use 0, that's used in the quest creation
set .q_max_limit,1000;
// * Type:
// - 1: Hour
// - 2: Day
// - 3: Week
// - 4: Month
set .q_del_type,2;
// * Multiplicator
// (How many days, as example)
set .q_del_multi,1;
// * Calculation Values values in seconds
switch(.q_del_type) {
case 1: set .@calc,3600; break;
case 2: set .@calc,86400; break;
case 3: set .@calc,604800; break;
case 4: set .@calc,2592000; break;
}
// Actual Calculation
set .q_delay,.@calc*.q_del_multi;
// ==== Reward Settings per Quest ====
// * Maximum Zeny Amount
set .rew_zeny,10000000; // 10m Zeny
// * Maximum Cash Points Amount
set .rew_cash,1000;
// * Maximum Item Amount
set .rew_item,10000;
// * Maximum Item Weight
// (= Item Weight* Reward Amount)
set .rew_weight,10000;
// ========================
query_sql "SHOW TABLES LIKE 'quest_list'",$@q_tab$;
if($@q_tab$[0] != "")
query_sql "DELETE FROM `quest_map`";
// Custom atcommand: @checkquest
bindatcmd "checkquest","QuestSysEvents::OnPCLoginEvent";
set $@QSys,1; // Quest System loaded
end;
}
- script QuestSysEvents -1,{
OnNPCKillEvent:
if($@q_tab$[0] == "") end;
// Player is in a party
if(getcharid(1) != 0) {
getpartymember(getcharid(1),1);
getpartymember(getcharid(1),2);
for ( set .@p,0; .@p < $@partymembercount; set .@p,.@p + 1) {
if(isloggedin($@partymemberaid[.@p],$@partymembercid[.@p]) == 0) end;
attachrid($@partymemberaid[.@p]);
callsub OnQuestMobKill;
}
end;
}
OnQuestMobKill:
if(getd("MobHunt_"+killedrid+"_CT") == 0) // Checking if the killed monster is wanted
if(getcharid(1) != 0) return; else end;
query_sql "SELECT SUM( `mob_am` ) , `npc_id` , `quest_id` FROM `quest_player` WHERE `char_id` = '"+getcharid(0)+"' AND `mob_id` = '"+killedrid+"'",.@mob_am,.@n_id,.@q_id;
if( (.@mob_am + 1) <= getd("MobHunt_"+killedrid+"_CT"))
for ( set .@m,0; .@m < getarraysize(.@n_id); set .@m,.@m + 1) {
query_sql "SELECT `mob_am` FROM `quest_list` WHERE `mob_id` = '"+killedrid+"' AND `quest_id` = '"+.@q_id[.@m]+"' AND `npc_id` = '"+.@n_id[.@m]+"'",.@req_am;
// Updating SQL Table for Monster Hunting Quests
query_sql "UPDATE `quest_player` SET `mob_am` = `mob_am` + 1 WHERE `char_id` = '"+getcharid(0)+"' AND `mob_id` = '"+killedrid+"' AND `mob_am` < '"+.@req_am+"' LIMIT 1";
query_sql "SELECT `npc_name` , `npc_map` FROM `quest_npc` WHERE `npc_id` = '"+.@n_id[.@m]+"'",.@n_name$,.@n_map$;
dispbottom .@n_name$+"@"+.@n_map$+": Monster Hunting - "+strmobinfo(1,killedrid)+" : "+(.@mob_am + 1)+"/"+getd("MobHunt_"+killedrid+"_CT"),0x00FF00;
}
if(getcharid(1) != 0) return; else end;
OnPCLoginEvent:
if($@q_tab$[0] == "") end;
query_sql "SELECT DISTINCT `quest_id` , `npc_id` FROM `quest_player` WHERE `char_id` = '"+getcharid(0)+"'",.@q_id,.@n_id;
set .@n$,"[Quest System]";
if(getarraysize(.@q_id) < 1) {
dispbottom .@n$+": You don't have any active quests.";
end;
}
dispbottom .@n$+": You have "+getarraysize(.@q_id)+" active Quests.";
dispbottom .@n$+": I will now list them per NPC with the info about the NPC:";
// Displaying Quest Progress
for ( set .@l,0; .@l < getarraysize(.@q_id); set .@l,.@l + 1) {
dispbottom " [* ====== Quest #"+.@q_id[.@l]+" - Progress: ====== *] ";
query_sql "SELECT `quest_type` FROM `quest_list` WHERE `npc_id` = '"+.@n_id[.@l]+"' AND `quest_id` = '"+.@q_id[.@l]+"'",.@q_type;
dispbottom " > Type: "+( (.@q_type == 1)?"Monster Hunting":"Item Collecting");
if(.@q_type == 1)
query_sql "SELECT `mob_id` , `mob_am` FROM `quest_list` WHERE `npc_id` = '"+.@n_id[.@l]+"' AND `quest_id` = '"+.@q_id[.@l]+"'",.@req1,.@req2;
else
query_sql "SELECT `item_id` , `item_am` FROM `quest_list` WHERE `npc_id` = '"+.@n_id[.@l]+"' AND `quest_id` = '"+.@q_id[.@l]+"'",.@req1,.@req2;
for ( set .@p,0; .@p < getarraysize(.@req1); set .@p,.@p + 1)
if(.@q_type == 1) {
query_sql "SELECT `mob_am` FROM `quest_player` WHERE `npc_id` = '"+.@n_id[.@l]+"' AND `quest_id` = '"+.@q_id[.@l]+"' AND `char_id` = '"+getcharid(0)+"' AND `mob_id` = '"+.@req1[.@p]+"'",.@m_got;
dispbottom " > Mob#"+(.@p+1)+": "+strmobinfo(1,.@req1[.@p])+" - "+.@m_got+"/"+.@req2[.@p];
} else
dispbottom " > Item#"+(.@p+1)+": "+getitemname(.@req1[.@p])+" - "+countitem(.@req1[.@p])+"/"+.@req2[.@p];
dispbottom " [* ====== NPC Location: ====== *] ";
query_sql "SELECT `npc_name` , `npc_map` , `npc_x` , `npc_y` FROM `quest_npc` WHERE `npc_id` = '"+.@n_id[.@l]+"'",.@n_name$,.@n_map$,.@n_x,.@n_y;
dispbottom " > Name: "+.@n_name$;
dispbottom " > Map: "+.@n_map$+", X: "+.@n_x+", Y: "+.@n_y;
}
end;
}
// Quest NPC Template
- script QuestNPC::QuestTemp -1,{
set .@n$,"["+strnpcinfo(1)+"]";
query_sql "SELECT DISTINCT `quest_id` , `quest_type` , `level` , `limit` FROM `quest_list` WHERE `npc_id` = '"+strnpcinfo(2)+"'",.@q_id,.@q_type,.@q_lvl,.@limit;
for ( set .@q,0; .@q < getarraysize(.@q_id); set .@q,.@q + 1) {
// Resetting variable
set .@status,0;
query_sql "SELECT `quest_id` FROM `quest_player` WHERE `npc_id` = '"+strnpcinfo(2)+"' AND `quest_id` = '"+.@q_id[.@q]+"' AND `char_id` = '"+getcharid(0)+"' LIMIT 1",.@que_id;
setarray .@que[.@q],.@que_id;
if(getd("QSys_"+strnpcinfo(2)+"_"+.@q_id[.@q]+"_QDelay") <= gettimetick(2))
setd("QSys_"+strnpcinfo(2)+"_"+.@q_id[.@q]+"_QDelay"),0;
set .@q_list$,.@q_list$ + "- #"+.@q_id[.@q]+" ("+ ( (.@q_type[.@q] == 1)?"Monster Hunting":"Item Collecting")+") "+( (.@q_lvl[.@q] != 0)?"("+.@q_lvl[.@q]+") ":"") + "["+( (.@que[.@q] > 0)?"^FF0000Running": ( (getd("QSys_"+strnpcinfo(2)+"_"+.@q_id[.@q]+"_QDelay") == 0)?"^00FFFFNew":"^0000FFQuest Delay active") )+"^000000]" + ( (.@q_id[.@q+1] != 0)?":":"");
}
mes .@n$;
if(getarraysize(.@q_id) < 1) {
mes "I'm sorry, but I currently don't have any quests for you.";
close;
}
mes "Please choose the quest from below you want to accept/abort or look at your progress.";
mes "Format:";
mes "Quest_ID (Quest Type) (Level) [Quest Status]";
next;
set .@q_c,select(.@q_list$) - 1;
mes .@n$;
mes " --- Quest #"+.@q_id[.@q_c]+" - "+ ( (.@que[.@q_c] == 1)?"Progress":"Information")+": ---";
mes "Type: "+( (.@q_type[.@q_c] == 1)?"Monster Hunting":"Item Collecting");
// Quest Details
if(.@q_type[.@q_c] == 1)
query_sql "SELECT `mob_id` , `mob_am` , `reward_id` , `reward_am` FROM `quest_list` WHERE `npc_id` = '"+strnpcinfo(2)+"' AND `quest_id` = '"+.@q_id[.@q_c]+"'",.@req1,.@req2,.@rew_id,.@rew_am;
else
query_sql "SELECT `item_id` , `item_am` , `reward_id` , `reward_am` FROM `quest_list` WHERE `npc_id` = '"+strnpcinfo(2)+"' AND `quest_id` = '"+.@q_id[.@q_c]+"'",.@req1,.@req2,.@rew_id,.@rew_am;
if(.@q_type[.@q_c] == 1) mes "Required Level: "+.@q_lvl[.@q_c];
for ( set .@l,0; .@l < getarraysize(.@req1); set .@l,.@l + 1)
mes "- "+.@req2[.@l]+"x "+ ( (.@q_type[.@q_c] == 1)?strmobinfo(1,.@req1[.@l]):getitemname(.@req1[.@l]) );
mes "Reward:";
mes .@rew_am+"x "+( (.@rew_id == 1)?"Zeny": ( (.@rew_id == 2)?"Cash Points":getitemname(.@rew_id)));
mes "Quest Limit: "+.@limit[.@q_c]+" times";
mes " ";
mes "What do you like to do now?";
next;
if(.@que[.@q_c] == 0) {
select("- Accept:- Nevermind");
if(@menu == 2) set .@s,4; else set .@s,@menu;
} else
set .@s,select("- Abort:- Check Progress/Complete:- Nevermind") + 1;
switch(.@s) {
// Accept Quest
case 1:
mes .@n$;
if(getd("QSys_"+strnpcinfo(2)+"_"+.@q_id[.@q_c]+"_QDelay") <= gettimetick(2))
setd("QSys_"+strnpcinfo(2)+"_"+.@q_id[.@q_c]+"_QDelay"),0;
else {
mes "I'm sorry, but quest delay hasn't passed yet.";
set .@left,getd("QSys_"+strnpcinfo(2)+"_"+.@q_id[.@q_c]+"_QDelay") - gettimetick(2);
if(.@left > 2592000) {
set .@dur$,"Months";
set .@time,.@left/2592000;
} else if(.@left > 604800 && .@left <= 2592000) {
set .@dur$,"Weeks";
set .@time,.@left/604800;
} else if(.@left > 86400 && .@left <= 604800) {
set .@dur$,"Days";
set .@time,.@left/86400;
} else if(.@left > 3600 && .@left <= 86400) {
set .@dur$,"Hours";
set .@time,.@left/3600;
} else {
set .@dur$,"Hour";
set .@time,1;
}
mes .@time+" "+.@dur$+" left!!!";
close;
}
if(BaseLevel < .@q_lvl[.@q_c]) {
mes "You don't meet the level requirement of "+.@q_lvl[.@q_c]+".";
close;
}
mes "You have accepted the quest.";
for ( set .@a,0; .@a < getarraysize(.@req1); set .@a,.@a + 1)
if(.@q_type[.@q_c] == 1) { // Monster Hunting
query_sql "INSERT INTO `quest_player` ( `npc_id` , `char_id` , `quest_id` , `mob_id` ) VALUES ( '"+strnpcinfo(2)+"' , '"+getcharid(0)+"' , '"+.@q_id[.@q_c]+"' , '"+.@req1[.@a]+"' )";
if(getd("MobHunt_"+.@req1[.@a]+"_CT") == 0)
setd("MobHunt_"+.@req1[.@a]+"_CT"),.@req2[.@a];
else
setd("MobHunt_"+.@req1[.@a]+"_CT"),getd("MobHunt_"+.@req1[.@a]+"_CT") + .@req2[.@a];
} else // Item Collecting
query_sql "INSERT INTO `quest_player` ( `npc_id` , `char_id` , `quest_id` ) VALUES ( '"+strnpcinfo(2)+"' , '"+getcharid(0)+"' , '"+.@q_id[.@q_c]+"' )";
break;
// Abort Quest
case 2:
mes .@n$;
mes "Do you really want to abort the quest?";
if(select("- Yes:- No") - 1) close;
next;
mes .@n$;
mes "Quest has been aborted.";
if(.@q_type[.@q_c] == 1) // Monster Hunting
for ( set .@a,0; .@a < getarraysize(.@req1); set .@a,.@a + 1) {
query_sql "SELECT `mob_am` FROM `quest_list` WHERE `npc_id` = '"+strnpcinfo(2)+"' AND `quest_id` = '"+.@q_id[.@q_c]+"'",.@req2;
if(getd("MobHunt_"+.@req1[.@a]+"_CT") > .@req2)
setd("MobHunt_"+.@req1[.@a]+"_CT"),getd("MobHunt_"+.@req1[.@a]+"_CT") - .@req2;
else
setd("MobHunt_"+.@req1[.@a]+"_CT"),0;
}
query_sql "DELETE FROM `quest_player` WHERE `npc_id` = '"+strnpcinfo(2)+"' AND `quest_id` = '"+.@q_id[.@q_c]+"' AND `char_id` = '"+getcharid(0)+"'";
break;
// Check Progress
case 3:
mes .@n$;
mes "Let's see, if you have completed the target....";
if(.@q_type[.@q_c] == 1)
query_sql "SELECT `mob_id` , `mob_am` FROM `quest_list` WHERE `npc_id` = '"+strnpcinfo(2)+"' AND `quest_id` = '"+.@q_id[.@q_c]+"'",.@req1,.@req2;
else
query_sql "SELECT `item_id` , `item_am` FROM `quest_list` WHERE `npc_id` = '"+strnpcinfo(2)+"' AND `quest_id` = '"+.@q_id[.@q_c]+"'",.@req1,.@req2;
for ( set .@p,0; .@p < getarraysize(.@req1); set .@p,.@p + 1) {
if(.@q_type[.@q_c] == 1)
// Selecting the latest value in the database
query_sql "SELECT `mob_am` FROM `quest_player` WHERE `npc_id` = '"+strnpcinfo(2)+"' AND `quest_id` = '"+.@q_id[.@q_c]+"' AND `char_id` = '"+getcharid(0)+"' AND `mob_id` = '"+.@req1[.@p]+"'",.@am;
else
set .@am,countitem(.@req1[.@p]);
if(.@am < .@req2[.@p]) set .@f,.@f + 1;
}
for ( set .@l,0; .@l < getarraysize(.@req1); set .@l,.@l + 1)
mes "- "+ ( (.@q_type[.@q_c] == 1)?strmobinfo(1,.@req1[.@l]):getitemname(.@req1[.@l]) )+": "+.@am+"/"+.@req2[.@l];
mes " ";
if(.@f) {
mes "You didn't finish "+.@f+" target"+( (.@f == 1)?"":"s")+". Please come back, when you have finished those.";
close;
}
next;
mes .@n$;
query_sql "SELECT `reward_id` , `reward_am` FROM `quest_list` WHERE `npc_id` = '"+strnpcinfo(2)+"' AND `quest_id` = '"+.@q_id[.@q_c]+"'",.@rew_id,.@rew_am;
switch(.@rew_id) {
case 1: set Zeny,Zeny + .@rew_am; break;
case 2: set #CASHPOINTS,#CASHPOINTS + .@rew_am; break;
default:
if(checkweight(.@rew_id,.@rew_am) == 1)
getitem .@rew_id,.@rew_am;
else {
mes "It seems like you can't carry more items, than you already do. You have to remove some weight before you can recieve your reward.";
close;
}
break;
}
mes "You have completed the quest, here is your reward!!";
dispbottom "You have recieved "+.@rew_am+"x "+( (.@rew_id == 1)?"Zeny": ( (.@rew_id == 2)?"Cash Points":getitemname(.@rew_id)));
if(.@limit[.@q_c] != 0) { // No Quest Limit
setd("QSys_"+strnpcinfo(2)+"_"+.@q_id[.@q_c]+"_Limit"),getd("QSys_"+strnpcinfo(2)+"_"+.@q_id[.@q_c]+"_Limit") + 1;
if(getd("QSys_"+strnpcinfo(2)+"_"+.@q_id[.@q_c]+"_Limit") == .@limit[.@q_c]) {
setd("QSys_"+strnpcinfo(2)+"_"+.@q_id[.@q_c]+"_QDelay"),gettimetick(2)+getvariableofnpc(.q_delay,"Quest System");
setd("QSys_"+strnpcinfo(2)+"_"+.@q_id[.@q_c]+"_Limit"),0;
}
}
// Deleting Mob ID Variable or removing quest items from inventory
for ( set .@r,0; .@r < getarraysize(.@req1); set .@r,.@r + 1)
if(.@q_type[.@q_c] == 1) {
// Reseting Mob ID Variable and Mob Counter
if(getd("MobHunt_"+.@req1[.@r]+"_CT") > .@req2[.@r])
setd("MobHunt_"+.@req1[.@r]+"_CT"),getd("MobHunt_"+.@req1[.@r]+"_CT") - .@req2;
else
setd("MobHunt_"+.@req1[.@r]+"_CT"),0;
} else
delitem .@req1[.@l],.@req2[.@l];
query_sql "DELETE FROM `quest_player` WHERE `npc_id` = '"+strnpcinfo(2)+"' AND `quest_id` = '"+.@q_id[.@q_c]+"' AND `char_id` = '"+getcharid(0)+"'";
break;
// Nevermind
case 4:
break;
}
close;
OnInit:
while($@QSys == 0) sleep 5000;
if($@q_tab$[0] == "") end;
if(strnpcinfo(3) == "QuestTemp") end;
if(query_sql("SELECT `npc_name` FROM `quest_npc` WHERE `npc_id` = '"+strnpcinfo(2)+"' AND `npc_map` = '"+strnpcinfo(4)+"'",.@npc) == -1) {
getmapxy(.@n_map$,.@n_x,.@n_y,1);
query_sql "INSERT INTO `quest_npc` ( `npc_id` , `npc_name` , `npc_map` , `npc_x` , `npc_y` ) VALUES ( '"+strnpcinfo(2)+"' , '"+escape_sql(strnpcinfo(1))+"' , '"+escape_sql(strnpcinfo(4))+"' , '"+.@n_x+"' , '"+.@n_y+"' )";
}
if(query_sql("SELECT `map` FROM `quest_map` WHERE `map` = '"+strnpcinfo(4)+"'",.@m) != -1)
query_sql "UPDATE `quest_map` SET `npc_count` = `npc_count` + 1 WHERE `map` = '"+strnpcinfo(4)+"'";
else
query_sql "INSERT INTO `quest_map` ( `map` , `npc_count` ) VALUES ( '"+strnpcinfo(4)+"' , '1' )";
end;
}
// Quest NPC Duplicates
// Format:
// map,x,y,0 duplicate(QuestTemp) NPC Name#NPC ID 100
// Example:
// prontera,100,120,0 duplicate(QuestTemp) Quest Guy#1 100
dor_in01,192,214,5 duplicate(QuestTemp) Mission [D]#1 857
i need extra feature 1. Exp reward (base&job)
2. Is it possible to give more than 1 reward? cause i tried it only give 1 reward(item/zeny/cashpoint/etc). If it possible what i need to do?
3. Making level limitation have max level allowed?
Question
chryxt
Hello rA, i need help please
today i found this script and its looks like what i want but need more feature
this is the script
i need extra feature
1. Exp reward (base&job)
2. Is it possible to give more than 1 reward? cause i tried it only give 1 reward(item/zeny/cashpoint/etc). If it possible what i need to do?
3. Making level limitation have max level allowed?
please help me
Edited by chryxtThanks before
Link to comment
Share on other sites
0 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.