Search the Community

Showing results for tags 'function'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Bulletin Centre
    • Community News
    • Repository News
    • Ragnarok News
  • Hercules Development Centre
    • Development Discussion
    • Suggestions
    • Development Centre Archives
  • Support & Releases
    • General Server Support
    • Database
    • Scripting
    • Source
    • Plugin
    • Client-Side
    • Graphic Enhancements
    • Other Support & Releases
  • Hercules Community
    • General Discussion
    • Projects
    • Employment
    • Server Advertisement
    • Arts & Writings
    • Off Topic
  • 3CeAM Centre
    • News and Development
    • Community
  • International Communities
    • Filipino Community
    • Portuguese Community
    • Spanish Community
    • Other Communities

Categories

  • Client Resources
  • Graphic Resources
    • Sprites & Palettes
    • Maps & Textures
    • Other Graphics
  • Server Resources
    • Server Managers / Editors Releases
    • Script Releases
    • Source Modifications
    • Plugins
    • Pre-Compiled Server
  • Web Resources

Calendars

  • Community Calendar

Found 13 results

  1. Version v8

    70 downloads

    This script provides various array manipulation functions, and more might be added in the future. All of those functions (except the arithmetic ones) work with both integer and string arrays. The start of the array is always implicitly index 0, unless an index is specified, ie @array[index] array_pad(<array>, <size>, <value>) pads the array left or right with <value> until it reaches <size> size. If <size> is negative it will pad left. > returns the number of added entries setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_pad([email protected], 8, 69); // => 3 // array is now: 1, 2, 3, 4, 5, 69, 69, 69 setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_pad([email protected], -8, 69); // => 3 // array is now: 69, 69, 69, 1, 2, 3, 4, 5 array_replace(<array>, <needle>, <replacement>{, <neq>}) finds every occurrence of <needle> within the array and replaces it with <replacement>. if <neq> is true, finds entries that do not match instead > returns the number of changed entries setarray([email protected], 1, 1, 3, 1, 5); // initialize the array array_replace([email protected], 1, 69); // => 3 // array is now: 69, 69, 3, 69, 5 array_find(<array>, <needle>{, <neq>}) finds the first occurrence of <needle> within the array. if <neq> is true, finds entries that do not match instead > returns the index, or if none is found returns -1 setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_find([email protected], 3); // => 2 array_find([email protected], 1); // => 0 array_find([email protected], 6); // => -1 array_rfind(<array>, <needle>{, <neq>}) like array_find, but finds the last occurrence. if <neq> is true, finds entries that do not match instead > returns the index, or if none is found returns -1 setarray([email protected], 1, 2, 3, 4, 3); // initialize the array array_rfind([email protected], 3); // => 4 array_rfind([email protected], 4); // => 3 array_rfind([email protected], 6); // => -1 array_exists(<array>, <needle>{, <neq>}) very similar to array_find() but it instead just checks if it exists or not. if <neq> is true, finds entries that do not match instead > returns true or false setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_exists([email protected], 3); // => true array_exists([email protected], 6); // => false array_count(<array>, <needle>{, <neq>}) similar to array_find() but iterates through the whole array. if <neq> is true, finds entries that do not match instead > returns the total number of occurrences of <needle> setarray([email protected], 1, 69, 3, 69, 5); // initialize the array array_count([email protected], 69); // => 2 array_entries(<array>) a wrapper around array_count(). behaves similarly to getaraysize() but does not count holes > returns the number of non-empty entries setarray([email protected], 1, 2, 0, 0, 5); // initialize the array getarraysize([email protected]); // => 5 array_entries([email protected]); // => 3 array_remove(<array>, <needle>{, <neq>}) finds and removes every occurrence of <needle> from the array, while shifting left. if <neq> is true, finds entries that do not match instead > returns the number of removed entries setarray([email protected], 1, 69, 3, 69, 5); // initialize the array array_remove([email protected], 69); // => 2 // array is now: 1, 3, 5 array_reverse(<array>) reverses the array > returns true setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_reverse([email protected]); // => true // array is now: 5, 4, 3, 2, 1 array_sum(<array>) iterates through the whole array to perform an arithmetic addition > returns the sum of every entries of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_sum([email protected]); // ((((1 + 2) + 3) + 4) + 5) => 15 array_difference(<array>) iterates through the whole array to perform an arithmetic subtraction > returns the difference of every entries of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_difference([email protected]); // ((((1 - 2) - 3) - 4) - 5) => -13 array_product(<array>) iterates through the whole array to perform an arithmetic multiplication > returns the product of every entries of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_product([email protected]); // ((((1 * 2) * 3) * 4) * 5) => 120 array_quotient(<array>) iterates through the whole array to perform an arithmetic division > returns the quotient of every entries of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_quotient([email protected]); // ((((1 / 2) / 3) / 4) / 5) => 0 array_shift(<array>) removes the first entry of the array, while shifting left > returns the value of the removed entry setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_shift([email protected]); // => 1 // array is now: 2, 3, 4, 5 array_unshift(<array>, <value>) adds <value> to the start of the array, while shifting right > returns the new size of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_unshift([email protected], 69); // => 6 // array is now: 69, 1, 2, 3, 4, 5 array_pop(<array>) removes the last entry of the array > returns the value of the removed entry setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_pop([email protected]); // => 5 // array is now: 1, 2, 3, 4 array_push(<array>, <value>) adds <value> to the end of the array > returns the new size of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_push([email protected], 69); // => 6 // array is now: 1, 2, 3, 4, 5, 69 array_shuffle(<array>) shuffles the array > returns true setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_shuffle([email protected]); // => true // array is now: 1, 4, 2, 3, 5 (example, unpredictable) array_unique(<array>{, <threshold>}) allows array entries to appear up to <threshold> times (1 by default) and removes the extraneous ones. useful to remove duplicate entries > returns the number of removed entries setarray([email protected], 1, 3, 3, 4, 5); // initialize the array array_unique([email protected]); // => 1 // array is now: 1, 3, 4, 5 array_diff(<base array>, <array>{, <array>...}, <result array>) compares the base array against one or more other arrays and fills the result array with the entries in base array that are not present in any of the other arrays > returns the number of entries not found in other arrays setarray([email protected], 1, 2, 3, 4, 5, 6, 7, 8); // initialize the base array // fill the arrays to compare with the base array: setarray([email protected], 2, 3, 4, 5, 6, 7, 8); // missing "1" setarray([email protected], 1, 2, 3, 4, 6, 7, 8); // missing "5" setarray([email protected], 1, 2, 3, 4, 5, 6, 7); // missing "8" // compare foo, bar and baz against base, and fill result: array_diff([email protected], [email protected], [email protected], [email protected], [email protected]); // => 3 // [email protected] is now: 1, 5, 8 Requires Hercules of June 24 2017 or newer version -------------------------------------------------------------------------------------- This script was made by me, for The Mana World + Evol. License: public domain (CC0)
  2. View File Date and Time functions This script provides functions to easily calculate date and time. More functions will be added in the future. now() a shorthand function to get the current time > returns the number of seconds elapsed since the UNIX epoch now() // => 1497119219 (example, increments every second) time_from_ms(<delta>) calculates a UNIX timestamp relative to the current time > returns the number of seconds elapsed since the UNIX epoch, plus or minus <delta> ms time_from_ms(now()) // => 1497119219 (example, increments every second) time_from_ms(+1000) // => 1497119220 time_from_ms(-1000) // => 1497119218 time_from_seconds(<delta>) calculates a UNIX timestamp relative to the current time > returns the number of seconds elapsed since the UNIX epoch, plus or minus <delta> seconds time_from_seconds(now()) // => 1497119219 (example, increments every second) time_from_seconds(+1) // => 1497119220 time_from_seconds(-1) // => 1497119218 time_from_minutes(<delta>) calculates a UNIX timestamp relative to the current time > returns the number of seconds elapsed since the UNIX epoch, plus or minus <delta> minutes time_from_minutes(now()) // => 1497119219 (example, increments every second) time_from_minutes(+1) // => 1497119279 time_from_minutes(-1) // => 1497119159 time_from_hours(<delta>) calculates a UNIX timestamp relative to the current time > returns the number of seconds elapsed since the UNIX epoch, plus or minus <delta> hours time_from_hours(now()) // => 1497119219 (example, increments every second) time_from_hours(+1) // => 1497122819 time_from_hours(-1) // => 1497115619 time_from_days(<delta>) calculates a UNIX timestamp relative to the current time > returns the number of seconds elapsed since the UNIX epoch, plus or minus <delta> days time_from_days(now()) // => 1497119219 (example, increments every second) time_from_days(+1) // => 1497205619 time_from_days(-1) // => 1497032819 FuzzyTime(<unix timestamp>) converts a UNIX timestamp to a human-readable format > returns human-friendly relative time FuzzyTime(0) // => 47 years, 172 days, 18 hours, 52 minutes, and 28 seconds ago FuzzyTime(time_from_hours(+28)) // => in 1 day and 4 hours -------------------------------------------------------------------------------------- This script was made by me, for The Mana World + Evol. License: public domain (CC0) Submitter meko Submitted 06/10/17 Category Quest, Shops, Functions & Algorithms  
  3. Version v1

    17 downloads

    This script provides functions to easily calculate date and time. More functions might be added in the future. now() a shorthand function to get the current time > returns the number of seconds elapsed since the Unix epoch now() // => 1497119219 (example, increments every second) time_from_ms(<delta>) calculates a Unix timestamp relative to the current time > returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> ms time_from_ms(0) // => 1497119219 (example, increments every second) time_from_ms(+1000) // => 1497119220 time_from_ms(-1000) // => 1497119218 time_from_seconds(<delta>) calculates a Unix timestamp relative to the current time > returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> seconds time_from_seconds(0) // => 1497119219 (example, increments every second) time_from_seconds(+1) // => 1497119220 time_from_seconds(-1) // => 1497119218 time_from_minutes(<delta>) calculates a Unix timestamp relative to the current time > returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> minutes time_from_minutes(0) // => 1497119219 (example, increments every second) time_from_minutes(+1) // => 1497119279 time_from_minutes(-1) // => 1497119159 time_from_hours(<delta>) calculates a Unix timestamp relative to the current time > returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> hours time_from_hours(0) // => 1497119219 (example, increments every second) time_from_hours(+1) // => 1497122819 time_from_hours(-1) // => 1497115619 time_from_days(<delta>) calculates a Unix timestamp relative to the current time > returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> days time_from_days(0) // => 1497119219 (example, increments every second) time_from_days(+1) // => 1497205619 time_from_days(-1) // => 1497032819 FuzzyTime(<unix timestamp>) converts a Unix timestamp to a human-readable format > returns human-friendly relative time FuzzyTime(0) // => 47 years, 172 days, 18 hours, 52 minutes, and 28 seconds ago FuzzyTime(time_from_hours(+28)) // => in 1 day and 4 hours -------------------------------------------------------------------------------------- This script was made by me, for The Mana World + Evol. License: public domain (CC0)
  4. Ordinal Suffix Function File Name: Ordinal Suffix File Submitter: Myriad File Submitted: 5 June 2017 File Category: Quests, Shops, Functions & Algorithms Releases Ever been constructing a string and wanted to turn 1 into 1st? Or 2 -> 2nd? Well, there is now an answer! I call it 'Ordinal Suffix'. It adds a suffix to the end of your number using the callfunc() script command. Example below: [email protected] = 1; [email protected] = 2; mes("That's the " + callfunc("Ordinal_Suffix", [email protected]) + " time you told me that!"); // Will return "That's the 1st time you told me that!" mes("That's the " + callfunc("Ordinal_Suffix", [email protected]) + " time you told me that!"); // Will return "That's the 2nd time you told me that!" mes("That's the " + callfunc("Ordinal_Suffix", 11) + " time you told me that!"); // Will return "That's the 11th time you told me that!" → Special cases such as '11th', '12th' and '13th' are accounted for. → Can only be used with integers. → Works for all possible numbers (except 0 will return 0th, not sure what that is supposed to be). Script can be 'downloaded' at this pastebin link: https://pastebin.com/6Z5k1S70
  5. Array manipulation functions View File This script provides various array manipulation functions, and more will be added in the future. All of those functions (except the arithmetic ones) work with both integer and string arrays. array_pad(<array>, <size>, <value>) pads the array left or right with <value> until it reaches <size> size. If <size> is negative it will pad left. setarray([email protected], 1, 2, 3, 4, 5); // initialize the arrayarray_pad([email protected], 8, 69); // array is now: 1, 2, 3, 4, 5, 69, 69, 69 setarray([email protected], 1, 2, 3, 4, 5); // initialize the arrayarray_pad([email protected], -8, 69); // array is now: 69, 69, 69, 1, 2, 3, 4, 5 array_replace(<array>, <needle>, <replacement>) finds every occurrence of <needle> within the array and replaces it with <replacement> setarray([email protected], 1, 1, 3, 1, 5); // initialize the array array_replace([email protected]oo, 1, 69); // array is now: 69, 69, 3, 69, 5 array_find(<array>, <needle>) finds the first occurrence of <needle> within the array and returns its index, or if none is found returns -1 setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_find([email protected], 3); // 2 array_find([email protected], 1); // 0 array_find([email protected], 6); // -1 array_rfind(<array>, <needle>) like array_find, but returns the index of the last occurrence instead setarray([email protected], 1, 2, 3, 4, 3); // initialize the array array_rfind([email protected], 3); // 4 array_rfind([email protected], 4); // 3 array_rfind([email protected], 6); // -1 array_exists(<array>, <needle>) very similar to array_find() but it instead returns true or false if <needle> is found setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_exists([email protected], 3); // true array_exists([email protected], 6); // false array_count(<array>, <needle>) very similar to array_find() but instead returns the total number of occurrences of <needle> setarray([email protected], 1, 69, 3, 69, 5); // initialize the array array_count([email protected], 69); // 2 array_remove(<array>, <needle>) finds and removes every occurrence of <needle> from the array, while shifting left setarray([email protected], 1, 69, 3, 69, 5); // initialize the array array_remove([email protected], 69); // array is now: 1, 3, 5 array_reverse(<array>) reverses the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_reverse([email protected]); // array is now: 5, 4, 3, 2, 1 array_sum(<array>) returns the sum of every element of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_sum([email protected]); // ((((1 + 2) + 3) + 4) + 5) = 15 array_difference(<array>) returns the difference of every element of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_difference([email protected]); // ((((1 - 2) - 3) - 4) - 5) = -13 array_product(<array>) returns the product of every element of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_product([email protected]); // ((((1 * 2) * 3) * 4) * 5) = 120 array_quotient(<array>) returns the quotient of every element of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_quotient([email protected]); // ((((1 / 2) / 3) / 4) / 5) = 0 array_shift(<array>) removes the first element of the array and returns it setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_shift([email protected]); // 1 // array is now: 2, 3, 4, 5 array_unshift(<array>, <value>) adds <value> to the start of the array, while shifting right, and returns the new size of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_unshift([email protected], 69); // 6 // array is now: 69, 1, 2, 3, 4, 5 array_pop(<array>) removes the last element of the array and returns it setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_pop([email protected]); // 5 // array is now: 1, 2, 3, 4 array_push(<array>, <value>) adds <value> to the end of the array and returns the new size of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_push([email protected], 69); // 6 // array is now: 1, 2, 3, 4, 5, 69 Requires Hercules of June 3rd 2017 or newer version I plan to add more in the future: array_sort array_rsort array_shuffle array_slice array_splice array_unique array_from_range -------------------------------------------------------------------------------------- This script was made by me, for The Mana World + Evol. License: public domain (CC0) Submitter meko Submitted 05/29/17 Category Quest, Shops, Functions & Algorithms  
  6. I made an item call a function which have player interaction to choose on a menu but it gets the error npc_scriptcont: failed npc->checknear test. Heres an example of it: Item id of Knife -> 1202 with script on it as: callfunc "getSkill"; and the gist of the function of: function script getSkill { attachrid(getcharid(3)); retryRK: dispbottom "Select a Skill you want."; switch(select("Enchant Blade:Sonic Wave:Death Bound")){ case 1: [email protected] = 1; break; case 2: [email protected] = 2; break; case 3: [email protected] = 3; break; default: goto(retryRK); } close; <More code...> I'm just wondering if there's any fix to this http://herc.ws/board/tracker/issue-3720-failed-npc-checknear-test-on-item-equip-function/ or any work around it. would greatly appreciate it!
  7. File Name: [Function] random item/variable File Submitter: Hirist File Submitted: 09 Sep 2016 File Category: Quest, Shops, Functions & Algorithms Origanal post: http://herc.ws/board/topic/6541-function-random-itemvariable/ Author: Dastgir Just fix some bug and reup. Click here to download this file
  8. Version 1.2

    44 downloads

    Origanal post: http://herc.ws/board/topic/6541-function-random-itemvariable/ Author: Dastgir Just fix some bug and reup.
  9. I have the following script: // Main Script- script L_Test -1,{ // Configuration set .useLastMAC,0; // When player logins into game OnPCLoginEvent: // Load account info setarray @accountInfo$,callfunc("L_GetAccountInfo"); debugmes "[OnPCLoginEvent] account_id = " + @accountInfo$[0]; debugmes "[OnPCLoginEvent] last_ip = " + @accountInfo$[1]; debugmes "[OnPCLoginEvent] last_mac = " + @accountInfo$[2]; end; }// Helper Function: Load Account Info// Returns Array (0 = Account ID | 1 = Last IP | 2 = Last Mac)function script L_GetAccountInfo { setarray .accountInfo$[0],getcharid(3); if (getvariableofnpc(.useLastMAC,"L_Test") == 1) { query_sql("SELECT last_ip, last_mac FROM login WHERE account_id = "+ .accountInfo$[0], .last_ip$, .last_mac$); setarray .accountInfo$[1],.last_ip$,.last_mac$; } else { query_sql("SELECT last_ip FROM login WHERE account_id = "+ .accountInfo$[0], .last_ip$); setarray .accountInfo$[1],.last_ip$,"-"; } debugmes "[L_GetAccountInfo] account_id = " + .accountInfo$[0]; debugmes "[L_GetAccountInfo] last_ip = " + .accountInfo$[1]; debugmes "[L_GetAccountInfo] last_mac = " + .accountInfo$[2]; return .accountInfo$;} With this script enabled, when I login - I get the following output in map server: [Debug]: script debug : 2000000 110034179 : [L_GetAccountInfo] account_id = 2000000[Debug]: script debug : 2000000 110034179 : [L_GetAccountInfo] last_ip = 127.0.0.1[Debug]: script debug : 2000000 110034179 : [L_GetAccountInfo] last_mac = -[Debug]: script debug : 2000000 110034179 : [OnPCLoginEvent] account_id = 2000000[Debug]: script debug : 2000000 110034179 : [OnPCLoginEvent] last_ip =[Debug]: script debug : 2000000 110034179 : [OnPCLoginEvent] last_mac = Basically, within the function L_GetAccountInfo I load account details (account_id, last_ip, last_mac) based on npc config and return it as a array. When I set this function ret val to a array variable, it doesn't seem to be working. Any ideas? Only the first index's value appears to be returned by the function (2nd and 3rd index is empty).
  10. File Name: [Function] random item/variable File Submitter: Dastgir File Submitted: 23 Jul 2014 File Category: Quest, Shops, Functions & Algorithms This Function does something which is useful for some scripts. This function gives you item or adds/substract the variable value. Example: mes "Random between 7227,1 and 502,2 and 7227,2"; callfunc "rand_add",1,7227,1,502,2,7227,2; next; mes "Random between 1 Cash Points and 2 PvP Points"; callfunc "rand_add",2,"#CASHPOINTS","Cash Points",1,"pvp_points","PvP Points",2; next; mes "Random items that are mentioned in function"; callfunc "rand_add",0; close; Setting the value negative for variables will decrease them, while doing so for items, will not delete the item. Click here to download this file
  11. Version 1.0

    112 downloads

    This Function does something which is useful for some scripts. This function gives you item or adds/substract the variable value. Example: mes "Random between 7227,1 and 502,2 and 7227,2"; callfunc "rand_add",1,7227,1,502,2,7227,2; next; mes "Random between 1 Cash Points and 2 PvP Points"; callfunc "rand_add",2,"#CASHPOINTS","Cash Points",1,"pvp_points","PvP Points",2; next; mes "Random items that are mentioned in function"; callfunc "rand_add",0; close; Setting the value negative for variables will decrease them, while doing so for items, will not delete the item.
  12. Function: mumble() Description: Requests input of randomized string from user. Returns true on success and false on failure. Four difficulty levels are available; each level inherits the previous one(s). Example Usage: https://github.com/datmumbles/Scripts/raw/master/sample/mumbletest.txt Download: https://github.com/datmumbles/Scripts/raw/master/func/mumble.txt
  13. Function: getcharname() Description: Return the name belonging to the character ID referenced. Example usage: Utility: Account Remover Download: https://github.com/datmumbles/Scripts/raw/master/func/getcharname.txt