Nyaniverse Posted yesterday at 01:13 AM Group: Members Topic Count: 13 Topics Per Day: 0.02 Content Count: 49 Reputation: 31 Joined: 09/09/23 Last Seen: 39 minutes ago Share Posted yesterday at 01:13 AM (edited) 1. Unlimited Chain Quest - Monster Hunting / Item Collection in 1 NPC Spoiler /* !!! SQL TABLE DEFINITIONS !!! !!! Run in your MySQL tool before using the NPC !!! -- Monthly leaderboard (resets monthly) CREATE TABLE IF NOT EXISTS `quest_monthly_ranking` ( `account_id` INT NOT NULL, `char_name` VARCHAR(30) NOT NULL, `completed` INT DEFAULT 0, PRIMARY KEY (`account_id`) ); -- Overall leaderboard (never resets) CREATE TABLE IF NOT EXISTS `quest_overall_ranking` ( `account_id` INT NOT NULL, `char_name` VARCHAR(30) NOT NULL, `completed` INT DEFAULT 0, PRIMARY KEY (`account_id`) ); -- Reward claim storage CREATE TABLE IF NOT EXISTS `quest_monthly_rewards` ( `account_id` INT NOT NULL, `char_name` VARCHAR(30) NOT NULL, `claim_flag` TINYINT(1) DEFAULT 0, `rewards` TEXT NOT NULL, PRIMARY KEY (`account_id`) ); */ /* Author: Nyani Version 1.0 ---------------------------------------------- Features - Unlimited Chain Quest (Randomized Kill/Collection Quest) - Automatic Quest submission - unless Collection Quest (Must turn in) - Automatic Quest Acquisition - Does not repeat previous quest (shuffles the quest provided) - Cancel Current Quest (Must talk to NPC) - Monthly Ranking - Automated Monthly Reward distribution - Chance to obtain rewards for quest submissions - Milestone Rewards every 100 quests finished ---------------------------------------------- Changelogs v1.0 - Initial Release Notice: No support will be provided - unless it is a bug on the current script */ // ========================== // NPC SCRIPT START // ========================== prontera,155,180,5 script Quest Board 857,{ function AddProgress; function displayQuestProgress; function AssignNewQuest; //============================= // MAIN INTERACTION //============================= if (BaseLevel < 99) { message strcharinfo(0), "You must be at least level 99 to take a quest."; end; } // Auto-complete gather quests if ready if (#DailyQuestType == 2 && countitem(#DailyQuestTarget) >= #DailyQuestAmount) { callsub OnComplete; end; } // Auto-assign new quest if none exists if (#DailyQuestType == 0) { callsub OnQuest; end; } displayQuestProgress(); .@menu$ = "Abandon Current Quest"; if (.reward_mode == 0) { .@menu$ += ":Claim Monthly Rewards"; } if (getgmlevel() >= 99) { .@menu$ += ":[GM] Trigger Rewards"; } .@menu$ += ":Close"; switch(select(.@menu$)) { case 1: callsub OnReset; end; case 2: if (.reward_mode == 0) callsub OnClaimReward; else if (getgmlevel() >= 99) callsub OnGMDistribute; end; case 3: if (.reward_mode == 0 && getgmlevel() >= 99) { callsub OnGMDistribute; } end; default: end; } end; OnClaimReward: .@aid = getcharid(3); .@name$ = strcharinfo(0); query_sql("SELECT 1 FROM quest_monthly_rewards WHERE account_id = " + .@aid, .@found); if (!.@found) { message strcharinfo(0),"You have no unclaimed rewards."; end; } for (.@i = 0; .@i < getarraysize(.MonthlyReward); .@i++) { getitem .MonthlyReward[.@i], .MonthlyRewardAmount[.@i]; } query_sql("DELETE FROM quest_monthly_rewards WHERE account_id = " + .@aid); message strcharinfo(0),"Your monthly rewards have been claimed successfully!"; end; OnQuest: if (#DailyQuestType > 0) { displayQuestProgress(); menu "Complete Quest", OnComplete, "Abandon Quest", OnReset, "Close", -; end; } .@roll = rand(2); // 0 = kill, 1 = gather if (.@roll == 0) { .@index = rand(getarraysize(.MobList)); #DailyQuestType = 1; #DailyQuestTarget = .MobList[.@index]; #DailyQuestAmount = .MobAmount[.@index]; #DailyQuestProgress = 0; } else { .@index = rand(getarraysize(.ItemList)); #DailyQuestType = 2; #DailyQuestTarget = .ItemList[.@index]; #DailyQuestAmount = .ItemAmount[.@index]; #DailyQuestProgress = 0; } message strcharinfo(0),"A new quest has been assigned to you!"; displayQuestProgress(); end; OnComplete: if (#DailyQuestType == 1) { message strcharinfo(0),"This quest will be completed once you've killed enough mobs."; end; } else if (#DailyQuestType == 2) { if (countitem(#DailyQuestTarget) >= #DailyQuestAmount) { delitem #DailyQuestTarget, #DailyQuestAmount; // Begin quest completion logic (normally inside AddProgress) #DailyQuestProgress = 0; #DailyQuestTarget = 0; #DailyQuestAmount = 0; #DailyQuestType = 0; #DailyQuestCompleted++; message strcharinfo(0), "You have completed a quest!"; if (rand(1, 10000) <= .RewardChance) { .@r = rand(getarraysize(.RewardList)); getitem .RewardList[.@r], .RewardAmount[.@r]; } if (#DailyQuestCompleted % 100 == 0) { if (rand(1, 10000) <= .SpecialRewardChance) { .@s = rand(getarraysize(.SpecialRewardList)); getitem .SpecialRewardList[.@s], .SpecialRewardAmount[.@s]; } } query_sql("INSERT INTO quest_monthly_ranking (account_id, char_name, completed) VALUES (" + getcharid(3) + ", '" + escape_sql(strcharinfo(0)) + "', 1) ON DUPLICATE KEY UPDATE completed = completed + 1"); query_sql("INSERT INTO quest_overall_ranking (account_id, char_name, completed) VALUES (" + getcharid(3) + ", '" + escape_sql(strcharinfo(0)) + "', 1) ON DUPLICATE KEY UPDATE completed = completed + 1"); message strcharinfo(0), "Quest Completed!"; message strcharinfo(0), "You have now completed " + #DailyQuestCompleted + " quests."; AssignNewQuest(); end; } else { message strcharinfo(0),"You haven't collected all required items yet."; end; } } end; end; OnReset: mes "Are you sure you want to abandon the current quest?"; menu "Yes", OnResetConfirm, "No", -; close; OnResetConfirm: #DailyQuestTarget = 0; #DailyQuestAmount = 0; #DailyQuestProgress = 0; #DailyQuestType = 0; message strcharinfo(0),"Quest abandoned."; end; OnNPCKillEvent: if (#DailyQuestType == 1 && killedrid == #DailyQuestTarget) AddProgress(); end; function AddProgress { #DailyQuestProgress++; // Kill count message strcharinfo(0), "[Kill Quest] " + strmobinfo(1, #DailyQuestTarget) + ": " + #DailyQuestProgress + "/" + #DailyQuestAmount; if (#DailyQuestProgress >= #DailyQuestAmount) { #DailyQuestProgress = 0; #DailyQuestTarget = 0; #DailyQuestAmount = 0; #DailyQuestType = 0; #DailyQuestCompleted++; // Roll for reward chance if (rand(1, 10000) <= .RewardChance) { .@r = rand(getarraysize(.RewardList)); getitem .RewardList[.@r], .RewardAmount[.@r]; } if (#DailyQuestCompleted % 100 == 0) { if (rand(1, 10000) <= .SpecialRewardChance) { .@s = rand(getarraysize(.SpecialRewardList)); getitem .SpecialRewardList[.@s], .SpecialRewardAmount[.@s]; } } query_sql("INSERT INTO quest_monthly_ranking (account_id, char_name, completed) VALUES (" + getcharid(3) + ", '" + escape_sql(strcharinfo(0)) + "', 1) ON DUPLICATE KEY UPDATE completed = completed + 1"); query_sql("INSERT INTO quest_overall_ranking (account_id, char_name, completed) VALUES (" + getcharid(3) + ", '" + escape_sql(strcharinfo(0)) + "', 1) ON DUPLICATE KEY UPDATE completed = completed + 1"); message strcharinfo(0), "Quest Completed!"; message strcharinfo(0), "You have now completed " + #DailyQuestCompleted + " quests."; AssignNewQuest(); return; } return; } function AssignNewQuest { .@roll = rand(2); // 0 = kill, 1 = gather if (.@roll == 0) { .@tries = 0; .@last_target = #DailyQuestTarget; // store previous target do { .@index = rand(getarraysize(.MobList)); } while (.MobList[.@index] == .@last_target && .@tries++ < 5); // retry if same mob #DailyQuestType = 1; #DailyQuestTarget = .MobList[.@index]; #DailyQuestAmount = .MobAmount[.@index]; message strcharinfo(0), "[Kill Quest] Target: " + strmobinfo(1, #DailyQuestTarget) + " | Progress: 0/" + #DailyQuestAmount; } else { .@tries = 0; .@last_target = #DailyQuestTarget; // store previous target do { .@index = rand(getarraysize(.ItemList)); } while (.ItemList[.@index] == .@last_target && .@tries++ < 5); // retry if same item #DailyQuestType = 2; #DailyQuestTarget = .ItemList[.@index]; #DailyQuestAmount = .ItemAmount[.@index]; message strcharinfo(0), "[Gather Quest] Item: " + getitemname(#DailyQuestTarget) + " | Required: " + #DailyQuestAmount; } #DailyQuestProgress = 0; return; } function displayQuestProgress { if (#DailyQuestType == 1) { message strcharinfo(0), "[Kill Quest] Target: " + strmobinfo(1,#DailyQuestTarget) + " | Progress: " + #DailyQuestProgress + "/" + #DailyQuestAmount; } else if (#DailyQuestType == 2) { message strcharinfo(0), "[Gather Quest] Item: " + getitemname(#DailyQuestTarget) + " | Progress: " + countitem(#DailyQuestTarget) + "/" + #DailyQuestAmount; } else { message strcharinfo(0), "You currently have no active quest."; } return; } OnGMDistribute: if (getgmlevel() < 99) end; callsub OnMonthlyDistribute; message strcharinfo(0),"GM distribution manually triggered."; end; OnDay0101: callsub OnMonthlyDistribute; end; OnMonthlyDistribute: // Configure Rerward Message - Applicable for RoDEX only .@title$ = "Quest Monthly Rewards"; .@body$ = "Congrats on ranking in the Top 10! This mail will be deleted in 14 days."; .@sender$ = "Quest Board"; .@reward_count = getarraysize(.MonthlyReward); //Ensures that if rewards are more than 5 items, switches to manual distribution (talk to npc) if (.@reward_count > 5) set .reward_mode, 0; query_sql("TRUNCATE TABLE quest_monthly_rewards"); query_sql("SELECT account_id, char_name FROM quest_monthly_ranking ORDER BY completed DESC LIMIT 10", .@aid, .@name$); for (.@i = 0; .@i < getarraysize(.@aid); .@i++) { if (.reward_mode == 0) { .@reward_string$ = ""; for (.@j = 0; .@j < .@reward_count; .@j++) { .@reward_string$ += .MonthlyReward[.@j]+":"+.MonthlyRewardAmount[.@j]; if (.@j < .@reward_count - 1) .@reward_string$ += ","; } query_sql("INSERT INTO quest_monthly_rewards (account_id, char_name, rewards) VALUES (" + .@aid[.@i] + ", '" + escape_sql(.@name$[.@i]) + "', '" + escape_sql(.@reward_string$) + "')"); } else { for (.@j = 0; .@j < 5; .@j++) { .@item_id[.@j] = .MonthlyReward[.@j]; .@amount[.@j] = .MonthlyRewardAmount[.@j]; } .@title$ = "Quest Monthly Rewards"; .@body$ = "Congrats on ranking in the Top 10! This mail will be deleted in 14 days."; .@sender$ = "Quest Board"; .@cid = getcharid(0, .@name$[.@i]); if (.@cid) { mail .@cid, .@sender$, .@title$, .@body$, 0, .@item_id, .@amount; } else { debugmes "Mail failed: Char ID not found for " + .@name$[.@i]; } } } query_sql("TRUNCATE TABLE quest_monthly_ranking"); announce "Monthly Quest Leaderboard has been reset! Take on new quests and rise to the top!", bc_all; end; OnInit: // ========================== // CONFIGURATION // ========================== // 0 = NPC Claim Mode, 1 = RoDEX Mode .reward_mode = 1; // Mob and kill amounts setarray .MobList[0], 1002,1004,1010; setarray .MobAmount[0], 30,40,50; setarray .ItemList[0], 705, // Orcish Voucher 1015, // Garlet 1021, // Tooth of Bat 719, // Bear’s Footskin 729, // Coal 744, // Witherless Rose 746, // Evil Horn 728, // Cyfar 938, // Golem Fragment 1058, // Cactus Needle 1009, // Claw of Desert Wolf 1038, // Emveretarcon 1042, // Worm Peelings 1044, // Flame Heart 1046, // Mystic Frozen 1047, // Great Nature 1049; // Red Blood setarray .ItemAmount[0], 5,5,5,5,5,5,5,5,5,5, 5,5,5,5,5,5,5; // Completion reward pool setarray .RewardList[0], 607, 608, 609; setarray .RewardAmount[0], 1, 2, 1; // 100-completion reward pool setarray .SpecialRewardList[0], 7711, 7712; setarray .SpecialRewardAmount[0], 1, 1; // Monthly rewards for top 10 setarray .MonthlyReward[0], 607, 501, 504, 505, 506,909,910; setarray .MonthlyRewardAmount[0], 5, 2, 1, 3, 2,5,10; // Reward chance settings (1-10000 scale) .RewardChance = 10000; // 100% chance by default .SpecialRewardChance = 10000; // 100% for 100-completion } 2. Music Player - Just for fun Spoiler /* Author: Nyani Version 1.0 ---------------------------------------------- Autoplay System ---------------------------------------------- Changelogs 1.0 - Initial Release Note: !!! Make sure you have your BGMs ready in your BGM folder !!! BGM files must be 128kbps, client will not play unless it is not 128kbps Website: https://www.xconvert.com/unit-converter/milliseconds-to-minutes */ - script BGM_Playlist -1,{ end; function isPlaylistMap; OnInit: setarray .bgmList$[0], "714", "716", "712", "808"; setarray .bgmDuration[0], 336000, 251000, 252000, 246000; .bgmsize = getarraysize(.bgmList$); setarray .playlistMap$[0], "hakurei", "izlude", "alberta"; end; OnPCLoginEvent: if (isPlaylistMap(strcharinfo(3))) { callsub OnStartPlaylist; } end; OnStartPlaylist: .@count = .bgmsize; for (.@i = 0; .@i < .@count; .@i++) { .@tempOrder[.@i] = .@i; } for (.@i = .@count - 1; .@i > 0; .@i--) { .@j = rand(.@i + 1); .@swap = .@tempOrder[.@i]; .@tempOrder[.@i] = .@tempOrder[.@j]; .@tempOrder[.@j] = .@swap; } copyarray @BGM_Order[0], .@tempOrder[0], .bgmsize; @BGM_Size = .bgmsize; @BGM_Index = 0; doevent strnpcinfo(3)+"::OnPlayNextBGM"; end; OnPlayNextBGM: if (!isPlaylistMap(strcharinfo(3))) { stopnpctimer; end; } if (@BGM_Index >= @BGM_Size) { @BGM_Index = 0; } .@track_id = @BGM_Order[@BGM_Index]; .@bgm$ = .bgmList$[.@track_id]; .@duration = .bgmDuration[.@track_id]; playBGM .@bgm$; @BGM_Index++; addtimer .@duration, strnpcinfo(3)+"::OnPlayNextBGM"; end; function isPlaylistMap { .@map$ = getarg(0); for (.@i = 0; .@i < getarraysize(.playlistMap$); .@i++) { if (.playlistMap$[.@i] == .@map$) return 1; } return 0; } } hakurei mapflag loadevent 3. Race to Max Level - Perfect for single-time race events! Spoiler /* Make sure you implement this table in your database If you dont, this script will not work CREATE TABLE IF NOT EXISTS `race_to_99` ( `aid` INT(11) UNSIGNED NOT NULL, `name` VARCHAR(30) NOT NULL, `class` INT(11) UNSIGNED NOT NULL, `time` VARCHAR(30) NOT NULL, PRIMARY KEY (`aid`) ) ENGINE=MyISAM; */ /* Author: Nyani Version 2.9 Changelogs v1.0 - Initial Release v1.1 - Added dynamic settings for easier configuration v1.2 - Slightly improved stylistic look for npc dialogue v1.3 - Added dynamic reward list v1.4 - Added support for time stamp v1.5 - Added class selection for checking race v1.6 - Fixed time stamp issue v1.7 - Fixed rewards bug v1.8 - Added proper spacing to winners list v1.9 - Added proper message when no winners to display v2.0 - Optimized script algorithm v2.1 - Added Registration Requirement v2.2 - Removed usage of global map variable v2.3 - Added color indication for available/contested/filled slots v2.4 - Optimized check for classes in the race v2.5 - Automated the checking of who got to max level first v2.6 - Added GM Options v2.7 - Fixed a bug with showscript remaining even if npc is hidden v2.8 - Fixed an exploit with registration NPC v2.9 - Fixed some bugs and added fall backs and clean up */ new_1-1,64,122,3 script Race Event#main 864,{ if(getgmlevel() > 10) .@gm = 1; .@menu$ = "> ^83B939View Slots^000000:> ^83B939Claim Reward^000000"; if(.@gm) .@menu$ += ":>[ ^ff0000GM^000000 ] ^D8A0FFStart new Race^000000:>[ ^ff0000GM^000000 ] ^D8A0FFCancel Race^000000"; switch(select(.@menu$)){ case 1: for(.@i = 1; .@i < getarraysize(.class); .@i++){ query_sql( "SELECT COUNT(`Class`) FROM `race_to_99` WHERE `class` = "+.class[.@i],.@job); if(.@job >= 2) .@j_menu$ += "> ^B9396B"+jobname(.class[.@i])+"^000000:"; else if(.@job == 1) .@j_menu$ += "> ^FA8415"+jobname(.class[.@i])+"^000000:"; else .@j_menu$ += "> ^83B939"+jobname(.class[.@i])+"^000000:"; } .@s = select(.@j_menu$); .@selection = .class[.@s]; mes "[ ^9d3ad3Race to Max Event^000000 ]"; query_sql( "SELECT `name`,`class`,`time` FROM `race_to_99` WHERE `class` = '"+.@selection+"' ORDER BY `time` DESC LIMIT 25",.@name$,.@class,.@date$); if(.@name$[0] == ""){ mes "No winners yet for ^876A3B"+jobname(.@selection)+"^000000."; close; } for(.@i = 0; .@i < getarraysize(.@name$); .@i++){ mes "- ^876A3B"+jobname(.@class[.@i])+"^000000 -"; mes .@name$[.@i]+" - "+.@date$[.@i]; mes "******************************"; } close; case 2: if(.active == 0){ mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "Sorry, there's no on-going race at the moment."; close; } if(inarray(.class[0],Class) == -1){ mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "I'm sorry, but "+jobname(Class)+" Class is not included in the race."; close; } query_sql( "SELECT `class`,`aid` FROM `race_to_99` WHERE `aid` = "+getcharid(3),.@class,.@aid); if(.@aid != 0 && #race_claim == 2){ mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "It seems your account already won before."; mes "You are unable to participate further."; if(#register == 1) #register = 0; //removing registered status close; } if(#race_claim == 1){ .@s = select(.menu$); for(.@i = 0; .@i < getarraysize(getd(".rewards"+.@s)); .@i++){ if(.bound) getitembound getd(".rewards"+.@s+"["+.@i+"]"),getd(".rwd_amt"+.@s+"["+.@i+"]"),.bound; else getitem getd(".rewards"+.@s+"["+.@i+"]"),getd(".rwd_amt"+.@s+"["+.@i+"]"); } #race_claim = 2; } else{ mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "I'm sorry, but it seems that you do not have any pending rewards."; close; } break; case 3: mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "Hello "+strcharinfo(0)+"."; mes "Would you like to remove current race data?"; menu "Yes, remove data",-; clear; query_sql("TRUNCATE `race_to_99`",.@aid); mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "Race records have been removed."; mes "Would you like start a new race?"; menu "Yes, start a new one",-; clear; .active = 1; mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "Alright, I've arranged the race event for you."; hideoffnpc "Race Event Registration#reg"; announce "[ Race to Max ]: "+strcharinfo(0)+" has started a new race. All older race data have been removed! Please talk to the Race Event Registration NPC!",0; close2; addrid(1); if(!#register) end; #register = 0; detachrid; query_sql("UPDATE `acc_reg_num` SET `value`='0' WHERE `value` >= '1' AND `key` = '#register'"); donpcevent "Race Event Registration#reg::OnHideOff"; break; case 4: if(!.active){ mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "There is currently no active event as of right now."; close; } mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "Hello "+strcharinfo(0)+"."; mes "Would you like to cancel the current race?"; menu "Yes, please cancel.",-; .active = 0; hideonnpc "Race Event Registration#reg"; clear; mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "Alright, it's been canceled."; announce "[ Race to Max ]: "+strcharinfo(0)+" has stopped the race. Please wait for a new one to start.",0; close2; addrid(1); if(!#register) end; #register = 0; detachrid; query_sql("TRUNCATE `race_to_99`",.@aid); query_sql("UPDATE `acc_reg_num` SET `value`='0' WHERE `value` >= '1' AND `key` = '#register'"); donpcevent "Race Event Registration#reg::OnHideOff"; break; } end; OnPCBaseLvUpEvent: if(!#register) end; if(!.active) end; if(BaseLevel < .base_level) end; if(query_sql("SELECT COUNT(*) FROM `race_to_99` WHERE `aid` = "+getcharid(3)); if (.@exists > 0) end; query_sql( "SELECT COUNT(`Class`) FROM `race_to_99` WHERE `class` = "+Class,.@job); if(.@job >= .class_limit) end; if(BaseLevel >= .base_level && JobLevel >= .job_level){ query_sql( "INSERT INTO `race_to_99` ( `aid`,`name`,`class`,`time`) VALUES ( "+getcharid(3)+",'"+escape_sql( strcharinfo(0))+"',"+Class+", '"+gettimestr("%m/%d %H:%M:%S",21)+"' )" ); announce "Congratulations to [ "+strcharinfo(0)+" ] for being one of the first [ "+jobname(Class)+" ] to reach max level!",1; message strcharinfo(0),"Please talk to the Race Event NPC for your reward."; #race_claim = 1; if(#register == 1) #register = 0; //removing registered status } end; OnPCJobLvUpEvent: if(!#register) end; if(!.active) end; if(JobLevel < .job_level && BaseLevel < .base_level) end; if(query_sql("SELECT COUNT(*) FROM `race_to_99` WHERE `aid` = "+getcharid(3)); if (.@exists > 0) end; query_sql( "SELECT COUNT(`Class`) FROM `race_to_99` WHERE `class` = "+Class,.@job); if(.@job >= .class_limit) end; if(BaseLevel >= .base_level && JobLevel >= .job_level){ query_sql( "INSERT INTO `race_to_99` ( `aid`,`name`,`class`,`time`) VALUES ( "+getcharid(3)+",'"+escape_sql( strcharinfo(0))+"',"+Class+", '"+gettimestr("%m/%d %H:%M:%S",21)+"' )" ); announce "Congratulations to [ "+strcharinfo(0)+" ] for being one of the first [ "+jobname(Class)+" ] to reach max level!",1; message strcharinfo(0),"Please talk to the Race Event NPC for your reward."; #race_claim = 1; if(#register == 1) #register = 0; //removing registered status } end; OnInit: .active = 1; .class_limit = 2; //how many players can claim for that particular class .base_level = 99; //max base level .job_level = 70; //max job level .bound = 1; //1 = account, 2 = guild, 3 = party, 4 = character, 0 = not bound //class number, check using @job in-game / these are the jobs/classes who can win prizes setarray .class[1], 4008, 4009, 4010, 4011, 4012, 4013, 4015, 4016, 4017, 4018, 4019, 4020, 4021, 23; //name of your reward set .menu$ = "Reward Set 1:Reward Set 2:Reward Set 3"; //reward id,quantity,reward id,quantity setarray .rewards1, 501,502,503; setarray .rwd_amt1, 1 ,1 ,1; setarray .rewards2, 504,505,506; setarray .rwd_amt2, 1 ,1 ,1; setarray .rewards3, 507,508,509; setarray .rwd_amt3, 1 ,1 ,1; while(1){ sleep 1000; showscript "Race to MAX!"; } end; } new_1-1,64,118,3 script Race Event Registration#reg 864,{ .@i = getvariableofnpc(.active,"Race Event#main"); if(!.@i){ mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "There is currently no active event as of right now."; close; } if(#race_claim == 2){ mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "Your account can only win once per race."; } if(Class != 0 || BaseLevel > 5){ mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "I'm sorry, but I can only speak with Level 1 Novices."; close; } query_sql( "SELECT `aid` FROM `race_to_99` WHERE `aid` = "+getcharid(3),.@aid); if(.@aid != 0){ mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "It seems your account already won before."; mes "You are unable to participate further."; if(#register == 1) #register = 0; //removing registered status close; } if(#register == 1){ mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "You are already registered."; close; } mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "Hello "+strcharinfo(0)+"!"; mes "We have an on-going ^ff0000Race Event^000000 that is on-going right now."; mes "Would you like to join?"; menu "Yes, sign me up.",-; clear; mes "[ ^9d3ad3Race to Max Event^000000 ]"; mes "Alright, I have "+strcharinfo(0)+" in my records now!"; mes "Good luck on the race!"; close2; announce "[ Race to 99 ]: "+strcharinfo(0)+" has joined the race! We wish everyone the best of luck!",0; #register = 1; end; OnHideOff: OnInit: sleep 5000; .@i = getvariableofnpc(.active,"Race Event#main"); if(!.@i) hideonnpc strnpcinfo(0); while(.@i == 1){ sleep 1000; showscript "Race Registration"; .@i = getvariableofnpc(.active,"Race Event#main"); } end; } 4. Beta Registration NPC - Easy handing out rewards Spoiler /* Make sure you implement this table on your database If you do not implement this, this will not function CREATE TABLE IF NOT EXISTS `beta_registration` ( `aid` INT(11) UNSIGNED NOT NULL DEFAULT '0', `claimed` INT(11) NOT NULL DEFAULT '0', PRIMARY KEY (`aid`) ) ENGINE=MyISAM; */ /* Author: Nyani Version 2.8 Changelogs v1.0 - Initial Release */ prontera,166,88,3 script Beta Registration 10146,{ query_sql( "SELECT `aid` FROM `beta_registration` WHERE `aid` = "+getcharid(3),.@aid); if(.@aid == 0){ mes "[ Beta Registration ]"; mes "Thank you for participating in our Beta!"; mes "You can claim your rewards on our official release~"; close2; query_sql( "INSERT INTO `beta_registration` ( `aid`) VALUES ( "+getcharid(3)+" )" ); debugmes "Successfully registered: "+getcharid(3); end; } mes "[ Beta Registration ]"; mes "Thank you for registering~"; close; OnInit: set .message$, " Beta Registration"; freeloop(1); while (1) { set .message$, delchar(.message$+charat(.message$,0),0); delwaitingroom; waitingroom .message$, 0; sleep 300; } freeloop(0); end; } prontera,166,90,3 script Beta Claim 831,{ query_sql( "SELECT `aid` FROM `beta_registration` WHERE `aid` = "+getcharid(3),.@aid); query_sql( "SELECT `claimed` FROM `beta_registration` WHERE `aid` = "+getcharid(3),.@claim); if(.@aid == getcharid(3)){ if(.@claim == 0){ mes "[ Beta Claim ]"; mes "Thank you for participating in our beta test!"; close2; getitembound 49000,1,1; query_sql( "UPDATE `beta_registration` SET `claimed` = 1 WHERE `aid` = "+getcharid(3)); end; } mes "[ Beta Claim ]"; mes "You have already claimed your reward."; close; } mes "[ Beta Claim ]"; mes "I'm sorry but I could not find records of you."; mes "Please check with an administrator if you did participate in the beta"; close; OnInit: set .message$, " Beta Rewards"; freeloop(1); while (1) { set .message$, delchar(.message$+charat(.message$,0),0); delwaitingroom; waitingroom .message$, 0; sleep 300; } freeloop(0); end; } NOTE: No support will be provided - unless it's a bug in the script itself Bugs? Reply to this thread and I'll fix it right up. Edited yesterday at 01:14 AM by Nyaniverse 2 Quote Link to comment Share on other sites More sharing options...
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.