Jump to content

Z3R0

Members
  • Posts

    615
  • Joined

  • Last visited

  • Days Won

    11

Community Answers

  1. Z3R0's post in If Count item Script was marked as the answer   
    if ( countitem(#) || countitem(#) ) { // DO STUFF }  
  2. Z3R0's post in string in array key and switch case was marked as the answer   
    1st one can be "simulated"
    setarray( getd( "@array_" + "string"), 0, 1, 2, 3, 4; ); // this will give you @array_string[#] 2nd, I found this out earlier, no, switch does not work with strings..., however what I found is that if you are setting strings for a switch, something is wrong...
    You can usually use a lookup array for the string and determine which index value it is in order to "case" it properly
  3. Z3R0's post in Quest NPC w/ Question & Answer was marked as the answer   
    Little rough, I'm tired... but it works enjoy
     
    //===== Script ========================================================================= //= Quizzer //===== Made by: ======================================================================= //= Z3R0 //===== Current Version: =============================================================== //= Version: 1.0 //===== Description: =================================================================== //= rAthena Script Request //= https://rathena.org/board/topic/112260-quest-npc-w-question-answer //===== Additional Comments: =========================================================== //= version 1.0: Initial Attempt //====================================================================================== prontera,158,173,4 script Quizzer 92,{ doevent "quizzer_core::OnClick"; } - script quizzer_core -1,{ // Function Declarations function MesItem; function ChkItem; function ChkAnswer; OnInit: // --------------------------------- // Configurable Settings // --------------------------------- // NPC Name to Display set(.npc$, "[Quizzer]"); // Fee to Pay to Begin Quiz set(.fee, 5000000); // Show # of Question Player is On and Total number of questions? set(.ShowQuestionProgress, 1); // Number of Answers to Pass Quiz set(.NumRightToPass, 8); // Required Items Array (Pair: Item_ID, Item_Amount) setarray(.required_items[0], 2256, 5); // Here you can setup multiple items in pairs.. (item_id, amount) // Array of Questions (Each question must have a corresponding answer) setarray(.questions$[0], "What is the special source of energy used by ninjas ?", "What is the name of the special eye of the Uchiha clan ?", "What is the name of the secret village of the country of Fire ?", "What is the prefered jutsu of Naruto ?", "How many villages are there in total ?", "What is the name of the 'star looking' weapon of the ninjas ?", "What is the name of the ultimate warrior/ninja in a particular village ?", "What is the name of Kiba's dog ?", "Who is the master of Naruto, Sasuke and Sakura ?", "What is the name of the nine-tailed demon fox ?" ); // Array of Answers (Each Answer must have a corresponding Question) setarray(.answers$[0], "Chakra", "Sharingan", "Konoha", "Kage bunshin no jutsu", "10", "Shuriken", "Kage", "Akamaru", "Kakashi", "Kurama" ); // Array of Reward Item ID's setarray(.rewards[0], 501, 502, 503, 504, 505, 506); setarray(.rewards_effects$[0], "+10 STR HP", "+10 AGI HP", "+10 INT HP", "+10 LUK HP", "+10 VIT HP", "+10 DEX HP"); // STOP!!! DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!!!! // check .ShowQuestionProgress if (.ShowQuestionProgress > 1) set(.ShowQuestionProgress, 1); // Check .required_items if (getarraysize(.required_items) % 2 != 0) { set(.error, 1); announce(strnpcinfo(0) + ": [ERROR] Invalid Number of Items in .required_items", bc_all, C_YELLOW); end(); } if (getarraysize(.questions$) != getarraysize(.answers$)) { set(.error, 1); announce(strnpcinfo(0) + ": [ERROR] Invalid Number of Questions to Answers", bc_all, C_YELLOW); end(); } if (getarraysize(.rewards) != getarraysize(.rewards_effects$)) { set(.error, 1); announce(strnpcinfo(0) + ": [ERROR] Invalid Number of Rewards to Reward Effects", bc_all, C_YELLOW); end(); } set(.error, 0); end(); // Player clicks the initial NPC OnClick: if (.error) { mes("There was an error loading this script. Please contact your server administrator"); close(); } if (quizzer & 8) { mes("You have already completed this trial."); close(); } else if (quizzer & 4) doevent("quizzer_core::OnComplete"); else if (quizzer & 2) doevent("quizzer_core::OnQuiz"); else if (quizzer & 1) doevent("quizzer_core::OnHunt"); else doevent("quizzer_core::OnStart"); end(); OnStart: mes(.npc$); if (.fee) { mes("You will need " + .fee + " zeny to start this trial."); mes("Are you ready to proceed?"); next(); switch(select("Yes:No")) { case 1: if (Zeny < .fee) { mes("You do not have enough zeny to start this trial."); close(); } set(Zeny, Zeny - .fee); set(quizzer, 1); mes("I need you to gather these items:"); for(.@i = 0; .@i < getarraysize(.required_items); .@i+=2) { mes( MesItem(.required_items, .@i) ); } mes("I await your return"); close(); case 2: default: mes("I knew you weren't capable!"); close(); } } OnHunt: mes(.npc$); // Determine if they have completed all the required items... mes("Checking Requirement Status:"); for(.@i = 0; .@i < getarraysize(.required_items); .@i+=2) { mes(MesItem(.required_items, .@i) + " - " + ChkItem(.required_items[.@i], .required_items[.@i+1])); } if (@quizzer_no_items == 1) { mes("You do not have enough items... You fail!"); set(@quizzer_no_items, 0); close(); } // Passed let's remove the items for(.@i = 0; .@i < getarraysize(.required_items); .@i+=2) { delitem .required_items[.@i], .required_items[.@i+1]; } mes("Success! You may now start the quiz!"); next(); set(quizzer, quizzer^2); doevent("quizzer_core::OnQuiz"); end(); OnQuiz: mes(.npc$); .@num_right = 0; for(.@i = 0; .@i < getarraysize(.questions$); .@i++) { if (.ShowQuestionProgress) { mes("Question #" + (.@i+1) + " / " + getarraysize(.questions$)); } mes(.questions$[.@i]); input .player_answers$[.@i]; // Let's compare the answer :D .@num_right += ChkAnswer(.answers$[.@i], .player_answers$[.@i]); mes("Answer Recorded. Next Question"); next(); } if (.@num_right >= .NumRightToPass) { set(quizzer, quizzer^4); mes("You have passed the quiz!"); next(); doevent("quizzer_core::OnComplete"); end(); } mes("You did not pass the quiz!"); close(); OnComplete: mes(.npc$); mes("Well Done Old Chap!"); mes("Please select from the following rewards"); set(.@menu$, ""); for(.@i = 0; .@i < getarraysize(.rewards); .@i++) { set(.@menu$, .@menu$ + getitemname(.rewards[.@i]) + " (" + .rewards_effects$[.@i] + "):"); } getitem .rewards[select(.@menu$) - 1], 1; set(quizzer, quizzer^8); mes("Thank you for participating"); close(); // getarg(0) = Array // getarg(1) = Index function MesItem { .@item_id = getelementofarray(getarg(0), getarg(1)); .@item_amount = getelementofarray(getarg(0), getarg(1) + 1); return .@item_amount + ( .@item_amount > 1 ? "x" : "") + " " + getitemname(.@item_id); } // getarg(0) = item_id // getarg(1) = amount required function ChkItem { .@has = countitem(getarg(0)); if (.@has >= getarg(1)) { return "^000000" + .@has + "^000000/^000000" + getarg(1) + "^000000"; } set(@quizzer_no_items, 1); return "^FF0000" + .@has + "^000000/^000000" + getarg(1) + "^000000"; } // getarg(0) = Answer // getarg(1) = Player Answer function ChkAnswer { if (getarg(0) == getarg(1)) return 1; else if (strtoupper(getarg(0)) == getarg(1)) return 1; else if (strtolower(getarg(0)) == getarg(1)) return 1; else return 0; } }  
  4. Z3R0's post in need help adding maps on nighmare mode script was marked as the answer   
    Follow the same thing for blacklist...
    OnInit: .blacklist$ = "501,502,503,504,505"; .onmaps$ = "prontera,geffen,morocc"; then on...
    OnPCDieEvent: if (countitem(7773) >= 1) end; if (BaseLevel < 40) end; // Will halt the rest of the script if they are not on a map that is allowed if (!compare("," + .onmaps$ + ",", "," + strcharinfo(3) + ",")) end; // ....  
  5. Z3R0's post in R> a NPC with progressbar & those with % to get one of a list of items [Solved] was marked as the answer   
    prontera,158,173,4 script CoinExchanger 88,{ mes("Welcome"); mes("Please give me your coins..."); // Check Inventory for Coins getinventorylist; freeloop(true); .@counter = 0; for(.@coin_index = 0; .@coin_index < getarraysize(.exchange_ids); .@coin_index++) { for(.@i = 0; .@i < @inventorylist_count; .@i++) { if (@inventorylist_id[.@i] == .exchange_ids[.@coin_index]) { if (@inventorylist_amount[.@i] >= .exchange_amount[.@coin_index]) { set(.@menu_coin_index[.@counter], .@coin_index); set(.@menu$, .@menu$ + ( .@menu$ == "" ? "" : ":" ) + getitemname(.exchange_ids[.@coin_index]) + "(" + @inventorylist_amount[.@i] + ")"); .@counter++; } } } } freeloop(false); if (.@menu$ == "") { next; mes("You do not have any coins!"); close; } // Display Option to Show them choices and how many coins they have... set .@choice, select(.@menu$) - 1; // Subtract 1 to get Array Index set .@index, .@menu_coin_index[.@choice]; // dispbottom("You have chosen to use " + getitemname(.exchange_ids[.@index]) ); // dispbottom("Progress bar Duration is: " + .exchange_duration[.@index] + " seconds."); mes("Goodluck"); close2; progressbar("00FF00", .exchange_duration[.@index]); // Start the Progressbar // On Progress Bar Completion... let's see what we do here... delitem(.exchange_ids[.@index], .exchange_amount[.@index]); freeloop(true); for(.@i = 0; .@i < getarraysize(.available_items); .@i++) { .@random = rand(1, 100); if (.@random <= .available_chance[.@i]) { // GET THE ITEM mes "Here you go"; getitem(.available_items[.@i], .available_amount[.@i]); if (.available_chance[.@i] <= .announce_level_chance) { announce(strcharinfo(0) + " just scored " + getitemname(.available_items[.@index]), bc_all, C_YELLOW); } close; } } freeloop(false); mes("You got the default prize..."); getitem(.default_item, .default_amount); close; OnInit: setarray(.exchange_ids, 673, 675, 671, 677); setarray(.exchange_amount, 1, 1, 1, 1); setarray(.exchange_duration, 10, 8, 5, 2); // # of seconds to progressbar... setarray(.available_items, 501, 502, 503, 504); setarray(.available_amount, 1, 1, 1, 1); setarray(.available_chance, 50, 40, 30, 10); // % of 100 set(.announce_level_chance, 10); // Will only display announce if they get item 504... since it's the only one with 10 chance or lower set(.default_item, 501); set(.default_amount, 1); end; } This should work
  6. Z3R0's post in out of area 'OnTouch:' was marked as the answer   
    You need to include a check for getmapxy () and see if the char is still within the area... if not set char var fire to 0
  7. Z3R0's post in Daily Reward was marked as the answer   
    // Check Value Against Stored Value if (gettimestr("%Y-%m/%d") == lastTimeTalked$) { mes "You have already talked to me today"; close; } // Do NPC Dialog // Store as a String (YearMonthDay) set lastTimeTalked$, gettimestr("%Y-%m/%d"); // Do Whatever Else Dialog // You do not need to worry about time changing, because it's already dependent on the year/month/day // when the date changes, the variable changes // If you would like this be a PER ACCOUNT, instead of PER CHAR, simply change the lastTimeTalked$ to #lastTimeTalked$ // Enjoy
  8. Z3R0's post in [Solve]Coin exchange Coin Npc was marked as the answer   
    Untested (because I'm at work)

    prontera,158,173,4 script Coin Exchanger 88,{ mes .npc$; mes "What would you like to do?"; switch(select("Info:Trade for Coin")) { case 1: // Get Info next; mes .npc$; for (set .@a, 0; .@a < getarraysize(.coin_id); set .@a, .@a + 1) { mes "1 " + getitename(.coin_id[.@a]) + " = " + .coin_trade_amount[.@a] + " " + getitemname(.coin_trade_coin[.@a]) + "s"; } close; case 2: // Trade Coin next; mes "Please select which coin you would like..."; // Build Menu for (set .@a, 0; .@a < getarraysize(.coin_id); set .@a, .@a + 1) { set .@menu$, .@menu$ + (.@menu$ == "" ? "" : ":") + getitemname(.coin_id[.@a]); } set .@coin_choice, select(.@menu$) - 1; if (countitem(.coin_trade_coin[.@coin_choice]) < .coin_trade_amount[.@coin_choice]) { mes "You do not have enough items..."; close; } mes "Ok! Let me do a little magic..."; next; mes "and.... Here you go..."; delitem .coin_trade_coin[.@coin_choice], .coin_trade_amount[.@coin_choice]; getitem .coin_id[.@coin_choice], 1; mes "Enjoy!"; close; } OnInit: set .npc$, "[Coin Exchanger]"; setarray .coin_id[0],silver,gold,plat,mithril; setarray .coin_trade_amount[0],5,4,3,2; setarray .coin_trade_coin[0],bronze,silver,gold,plat; end; }
  9. Z3R0's post in How do I limit how many players can connect to my server? was marked as the answer   
    Excluding GM's

    OnPCLoginEvent: // Increase Variable on NON GM Logins and Check Against 10 if (!getgmlvl()) { set .player_count, .player_count + 1; if (.player_count > 10) { set .player_count, 10; // Keep @ 10, to avoid incrementing this further... mes "I'm sorry you cannot enter..."; close2; atcommand "@kick " + strcharinfo(0); } } OnPCLogoutEvent: // Decrease Variable on NON GM Char Logout if (!getgmlevel()) { set .player_count, .player_count - 1; } }
  10. Z3R0's post in Universal Dynamic NPC Item Stock Limit? was marked as the answer   
    set the array OnInit: you are resetting the array on every npc click...

    prontera,153,153,3 script Free Equipments 917,{ setarray .setlimit[0],3,5;
    change to

    prontera,153,153,3 script Free Equipments 917,{
    find the OnInit: section add

    OnInit: setarray .setlimit[0],3,5;
    I'll look into more options later, because you ill also need to the shop dynamic so on each click of the shop, it's updated with the amount of stock, aka, if .setlimit[.@a] == 0, the item should not display... and the index should be skipped...
  11. Z3R0's post in [Request] Quest Npc was marked as the answer   
    ah good find! My bad... I'm in the middle of two projects... (NPC Script Requests + PHP Project) so they tend to blend at times... lol
    thanks for the find
    Updated

    // I Was just talking with Brian about this last night actually... // Create the Category Array setarray .@main_menu$[0],"Sword","Bow","Dagger"; // Item ID's (The Number 0 is the Index of the Category "Sword") setarray .@equip_0[0],1,2,3,4,5,6,7,8,9; // Item ID's (The Number 1 is the Index of the Category "Bow") setarray .@equip_1[0],1,2,3,4,5,6,7,8,9; // Item ID's (The Number 2 is the Index of the Category "Dagger") setarray .@equip_2[0],1,2,3,4,5,6,7,8,9; // Create Item Hunt Group Arrays (By Category) // For adding Zeny, use Item ID 0, and in Amount, use Amount of Zeny setarray .@items_0[0],0,502,503; setarray .@items_amount_0[0],1000,2,3; setarray .@items_1[0],501,502,503; setarray .@items_amount_1[0],1,2,3; setarray .@items_2[0],501,502,503; setarray .@items_amount_2[0],1,2,3; // Display Categories to Player and Store Answer as Index (-1 Stores as Array Index) set .@category, select(.@main_menu$) - 1; // Now Build the Menu Based on This Selection for (set .@a, 0; .@a < getarraysize(getd(".@equip_" + .@category)); set .@a, .@a + 1) { set .@item_name$, getitemname(getd(".@equip_" + .@category + "[" + .@a + "]")); set .@sub_menu$, .@sub_menu$ + (.@sub_menu$ == "" ? .@item_name$ : ":" + .@item_name$); } // Now Offer the New Menu to the Player as Index (-1 Stores as Array Index) set .@item_choice, select(.@sub_menu$) - 1; // Determine If Player Has Required Items for (set .@a, 0; .@a < getarraysize(getd(".@items_" + .@category)); set .@a, .@a + 1) { set .@item_id, getd(".@items_" + .@category + "[" + .@a + "]"); set .@item_requires, getd(".@items_amount_" + .@category + "[" + .@a + "]"); if (.@item_id) { set .@player_has, countitem(.@item_id); set .@item_name$, getitemname(.@item_id); if (.@player_has < .@item_requires) { set .@errors$[getarraysize(.@errors$)], "You Still Need " + (.@item_requires - .@player_has) + " " + .@item_name$ + ((.@item_requires - .@player_has) > 1 ? "'s." : "."); } } else { // Is Zeny if (Zeny < .@item_requires) { set .@errors$[getarraysize(.@errors$)], "You Still Need " + (.@item_requires - Zeny) + " z."; } } } // Determine Errors to Display if (getarraysize(.@errors$)) { for (set .@a, 0; .@a < getarraysize(.@errors$); set .@a, .@a + 1) { mes .@errors$[.@a]; } close; } // Now For Debugging Purposes mes "Item ID Chosen: " + getd(".@equip_" + .@category + "[" + .@item_choice + "]"); mes "Item Name: " + getitemname(getd(".@equip_" + .@category + "[" + .@item_choice + "]")); // Take Items Away for (set .@a, 0; .@a < getarraysize(getd(".@items_" + .@category)); set .@a, .@a + 1) { delitem getd(".@items_" + .@category + "[" + .@a + "]"), getd(".@items_amount_" + .@category + "[" + .@a + "]"); } // Give Item getitem getd(".@equip_" + .@category + "[" + .@item_choice + "]"), 1; close; }
×
×
  • Create New...