Jump to content

meko

Core Developers
  • Content Count

    363
  • Joined

  • Days Won

    46

Reputation Activity

  1. Like
    meko got a reaction from Hyroshima in Array manipulation functions   
    View File Array manipulation functions
    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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_pad(.@foo, 8, 69); // => 3 // array is now: 1, 2, 3, 4, 5, 69, 69, 69 setarray(.@foo, 1, 2, 3, 4, 5); // initialize the array array_pad(.@foo, -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(.@foo, 1, 1, 3, 1, 5); // initialize the array array_replace(.@foo, 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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_find(.@foo, 3); // => 2 array_find(.@foo, 1); // => 0 array_find(.@foo, 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(.@foo, 1, 2, 3, 4, 3); // initialize the array array_rfind(.@foo, 3); // => 4 array_rfind(.@foo, 4); // => 3 array_rfind(.@foo, 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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_exists(.@foo, 3); // => true array_exists(.@foo, 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(.@foo, 1, 69, 3, 69, 5); // initialize the array array_count(.@foo, 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(.@foo, 1, 2, 0, 0, 5); // initialize the array getarraysize(.@foo); // => 5 array_entries(.@foo); // => 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(.@foo, 1, 69, 3, 69, 5); // initialize the array array_remove(.@foo, 69); // => 2 // array is now: 1, 3, 5


    array_reverse(<array>)
    reverses the array
    > returns true setarray(.@foo, 1, 2, 3, 4, 5); // initialize the array array_reverse(.@foo); // => 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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_sum(.@foo); // ((((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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_difference(.@foo); // ((((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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_product(.@foo); // ((((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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_quotient(.@foo); // ((((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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_shift(.@foo); // => 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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_unshift(.@foo, 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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_pop(.@foo); // => 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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_push(.@foo, 69); // => 6 // array is now: 1, 2, 3, 4, 5, 69


    array_shuffle(<array>)
    shuffles the array
    > returns true setarray(.@foo, 1, 2, 3, 4, 5); // initialize the array array_shuffle(.@foo); // => 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(.@foo, 1, 3, 3, 4, 5); // initialize the array array_unique(.@foo); // => 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(.@base, 1, 2, 3, 4, 5, 6, 7, 8); // initialize the base array // fill the arrays to compare with the base array: setarray(.@foo, 2, 3, 4, 5, 6, 7, 8); // missing "1" setarray(.@bar, 1, 2, 3, 4, 6, 7, 8); // missing "5" setarray(.@baz, 1, 2, 3, 4, 5, 6, 7); // missing "8" // compare foo, bar and baz against base, and fill result: array_diff(.@base, .@foo, .@bar, .@baz, .@result); // => 3 // .@result is now: 1, 5, 8


    array_filter(<array>, "<function>")
    filters the array using a function that is tested against every entries. if the function returns false, the relevant entry is removed and the array is shifted left
    > returns the number of removed entries
    function script is_prime { if (getarg(0) <= 1) return false; for (.@i = 2; .@i <= getarg(0) / 2; ++.@i) if ((getarg(0) % .@i) == 0) return false; return true; } setarray(.@foo, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); array_filter(.@foo, "is_prime"); // => 9 // array is now: 2, 3, 5, 7, 11, 13


    array_sort(<array>)
    sorts the array in ascending order
    > returns true
    setarray(.@foo, 2, 1, 8, 4, 5, 7, 6, 3); // initialize the array array_sort(.@foo); // => true // array is now: 1, 2, 3, 4, 5, 6, 7, 8


    array_rsort(<array>)
    sorts the array in descending order
    > returns true
    setarray(.@foo, 2, 1, 8, 4, 5, 7, 6, 3); // initialize the array array_rsort(.@foo); // => true // array is now: 8, 7, 6, 5, 4, 3, 2, 1



    Requires Hercules of June 24 2017 or newer version


     
    --------------------------------------------------------------------------------------
    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  
  2. Like
    meko got a reaction from jowi in *npctalk but only on one player   
    unittalk(getnpcid(0), "your message", true, SELF, playerattached()); see doc/script_commands.txt for documentation
  3. Like
    meko got a reaction from Eross in Revising rA script to Herc   
    MF_LOADEVENT should be in uppercase. Also it might be faster to use a hash table than looping through the array (imagine having an array with 2k maps and doing a string comparison for each one of them every time someone enters the map)
    - script map_name -1,{ OnInit: .maps = htnew(); // create a new hash table // htput(.maps, "<map name>", "<map nick>"); htput(.maps, "prontera", "Prontera City, The Imperial Capital"); htput(.maps, "morocc", "Morroc Town, The Frontier"); htput(.maps, "geffen", "Geffen, The City of Magic"); htput(.maps, "payon", "Payon Town, The Upland Village"); htput(.maps, "alberta", "Alberta, The Port City"); htput(.maps, "izlude", "Izlude Town, The Satellite City of Prontera"); htput(.maps, "aldebaran", "Al De Baran, The Gate to the New World"); htput(.maps, "xmas", "Lutie, The City of Eternal Christmas"); htput(.maps, "comodo", "Comodo, The City of Fun and Celebrations"); htput(.maps, "yuno", "Juno, The Capital of the Commonwealth and Ancient Lore"); htput(.maps, "amatsu", "Amatsu, The New Land Discovered"); htput(.maps, "gonryun", "Gonryun, The Hermit Land"); htput(.maps, "umbala", "Umbala, The Lost Land"); htput(.maps, "niflheim", "Niffleheim, The Cold Land of Death"); htput(.maps, "louyang", "Louyang, The Fortress of Dragon"); htput(.maps, "new_1-1", "Training Ground"); htput(.maps, "sec_pri", "Valhalla Prison"); htput(.maps, "jawaii", "Jawaii, The Island of Love"); htput(.maps, "ayothaya", "Ayothaya, The Land of Majectic Culture"); htput(.maps, "einbroch", "Einbroch, The Steel City"); htput(.maps, "lighthalzen", "Lighthalzen, The City of Scientific Myths"); htput(.maps, "einbech", "Einbech, The Mining Town"); htput(.maps, "hugel", "Hugel, Between the Icy Moutain and Chilly Blue Sea"); htput(.maps, "rachel", "Rachel, The Capital City of Arunafeltz"); htput(.maps, "veins", "Veins, The Canyon Village"); htput(.maps, "mid_camp", "Rune Midgard Allied Forces Post"); .@it = htiterator(.maps); // create an iterator to loop through the table for (.@map$ = htifirstkey(.@it); hticheck(.@it); .@map$ = htinextkey(.@it)) { // we are only interested in the key so no need to htget() here setmapflag(.@map$, MF_LOADEVENT); } htidelete(.@it); // we're done with the iterator: deallocate it end; OnPCLoadMapEvent: // check whether it's in the hash table: if (.@nick$ = htget(.maps, strcharinfo(PC_MAP), "")) { announce(.@nick$, bc_self); } end; }  
  4. Upvote
    meko got a reaction from Neffletics in Array manipulation functions   
    View File Array manipulation functions
    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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_pad(.@foo, 8, 69); // => 3 // array is now: 1, 2, 3, 4, 5, 69, 69, 69 setarray(.@foo, 1, 2, 3, 4, 5); // initialize the array array_pad(.@foo, -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(.@foo, 1, 1, 3, 1, 5); // initialize the array array_replace(.@foo, 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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_find(.@foo, 3); // => 2 array_find(.@foo, 1); // => 0 array_find(.@foo, 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(.@foo, 1, 2, 3, 4, 3); // initialize the array array_rfind(.@foo, 3); // => 4 array_rfind(.@foo, 4); // => 3 array_rfind(.@foo, 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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_exists(.@foo, 3); // => true array_exists(.@foo, 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(.@foo, 1, 69, 3, 69, 5); // initialize the array array_count(.@foo, 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(.@foo, 1, 2, 0, 0, 5); // initialize the array getarraysize(.@foo); // => 5 array_entries(.@foo); // => 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(.@foo, 1, 69, 3, 69, 5); // initialize the array array_remove(.@foo, 69); // => 2 // array is now: 1, 3, 5


    array_reverse(<array>)
    reverses the array
    > returns true setarray(.@foo, 1, 2, 3, 4, 5); // initialize the array array_reverse(.@foo); // => 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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_sum(.@foo); // ((((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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_difference(.@foo); // ((((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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_product(.@foo); // ((((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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_quotient(.@foo); // ((((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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_shift(.@foo); // => 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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_unshift(.@foo, 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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_pop(.@foo); // => 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(.@foo, 1, 2, 3, 4, 5); // initialize the array array_push(.@foo, 69); // => 6 // array is now: 1, 2, 3, 4, 5, 69


    array_shuffle(<array>)
    shuffles the array
    > returns true setarray(.@foo, 1, 2, 3, 4, 5); // initialize the array array_shuffle(.@foo); // => 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(.@foo, 1, 3, 3, 4, 5); // initialize the array array_unique(.@foo); // => 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(.@base, 1, 2, 3, 4, 5, 6, 7, 8); // initialize the base array // fill the arrays to compare with the base array: setarray(.@foo, 2, 3, 4, 5, 6, 7, 8); // missing "1" setarray(.@bar, 1, 2, 3, 4, 6, 7, 8); // missing "5" setarray(.@baz, 1, 2, 3, 4, 5, 6, 7); // missing "8" // compare foo, bar and baz against base, and fill result: array_diff(.@base, .@foo, .@bar, .@baz, .@result); // => 3 // .@result is now: 1, 5, 8


    array_filter(<array>, "<function>")
    filters the array using a function that is tested against every entries. if the function returns false, the relevant entry is removed and the array is shifted left
    > returns the number of removed entries
    function script is_prime { if (getarg(0) <= 1) return false; for (.@i = 2; .@i <= getarg(0) / 2; ++.@i) if ((getarg(0) % .@i) == 0) return false; return true; } setarray(.@foo, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); array_filter(.@foo, "is_prime"); // => 9 // array is now: 2, 3, 5, 7, 11, 13


    array_sort(<array>)
    sorts the array in ascending order
    > returns true
    setarray(.@foo, 2, 1, 8, 4, 5, 7, 6, 3); // initialize the array array_sort(.@foo); // => true // array is now: 1, 2, 3, 4, 5, 6, 7, 8


    array_rsort(<array>)
    sorts the array in descending order
    > returns true
    setarray(.@foo, 2, 1, 8, 4, 5, 7, 6, 3); // initialize the array array_rsort(.@foo); // => true // array is now: 8, 7, 6, 5, 4, 3, 2, 1



    Requires Hercules of June 24 2017 or newer version


     
    --------------------------------------------------------------------------------------
    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  
  5. Like
    meko got a reaction from AnnieRuru in defpattern: regexp, my old ennemy   
    defpattern is case insentive, but pcre_match (and the regex operator) is not.
    This means you could just use "^(.*)$" with defpattern and then filter a second time (the variable is $@p0$) with pcre_match (or ~=) when the event is invoked.
  6. Like
    meko got a reaction from MikZ in Autopots to hercules   
    for inarray() you can use array_find() from Array manipulation functions, which behaves the same way:
    if (array_find(.blackList[0], .@potion) != -1) { for debugmes you should use consolemes:
    consolemes(CONSOLEMES_DEBUG, "message");  
  7. Like
    meko got a reaction from MikZ in Abracadabra Skill DB location   
    the file is located at db/abra_db.txt
  8. Like
    meko got a reaction from Waken in Please help me while making a new skill   
    the documentation has not been updated yet but you must define the constant CUSTOM_SKILL_RANGES at compile time, with the syntax being:
    {from, to}, {from, to}, ... In your case since you are only adding one skill you would define it as:
    {8443, 8443},  
    this means you would pass a -D compiler option like this:
    -DCUSTOM_SKILL_RANGES="{8443,8443},"  
    ...which will insert it in skill_idx_ranges[]
  9. Like
    meko got a reaction from Chatterboy in Kafra points does not decrease..   
    use @price instead of @points
  10. Like
    meko got a reaction from IndieRO in auto revive   
    OnPCDieEvent: if (!(isequipped(Helm_Of_Sun)) // no helm of sun || agitcheck() // WoE || getmapflag(strcharinfo(PC_MAP), mf_pvp) // map PvP || getunittype(killerrid) == UNITTYPE_PC) // killed by a player end; addtimer(1000, strnpcinfo(NPC_NAME) + "::OnAutoRevive"); end; OnAutoRevive: recovery(getcharid(CHAR_ID_ACCOUNT)); // revive the player end;  
  11. Upvote
    meko reacted to heroji in send item in all players in map   
    *getitembound(<item id>, <amount>, <bound type>{, <account ID>})
    *getitembound("<item name>", <amount>, <bound type>{, <account ID>})
    This command behaves identically to getitem(), but the items created will be bound to the target character as specified by the bound type. All items created in this manner cannot be dropped, sold, vended, auctioned, or mailed, and in some cases cannot be traded or stored.
    Valid bound types are:
    1 - Account Bound
    2 - Guild Bound
    3 - Party Bound
    4 - Character Bound
  12. Upvote
    meko reacted to heroji in send item in all players in map   
  13. Like
    meko got a reaction from heroji in Warning ..will be removed in a future update.   
    Whenever you see a deprecation warning you should look at the script documentation for instructions, which in this case instructs you to use specialeffect(). You can find more details on the Deprecation Notice thread: 
     
     
    In your case you would simply replace it with:
    specialeffect(EF_BEGINASURA, AREA, playerattached());  
  14. Upvote
    meko reacted to Patskie in HOURLY ITEM REWARD SCRIPT for HERCULES   
    Try : 
    - script asdfgh FAKE_NPC,{ OnPCLoginEvent: .players[getarraysize(.players)] = getcharid(CHAR_ID_ACCOUNT); end; OnPCLogoutEvent: .@i = callfunc("array_find", .players, getcharid(CHAR_ID_ACCOUNT)); if (!(.@i < 0)) deletearray .players[.@i], 1; end; OnMinute15: if (!.random_receiver) { .@i = 0; .@s = getarraysize(.players); while (.@i < .@s) { getitem Jellopy, 1, .players[.@i]; .@i++; } } else getitem Jellopy, 1, .players[rand(getarraysize(.players))]; end; OnInit: .random_receiver = 0; // 0 - all online players | 1 = random online player end; } PS : I am using below release so please plug that as well to your server to avoid any issues
     
  15. Upvote
    meko got a reaction from MikZ in Remove Infinity Loop Error   
    freeloop(true); for (...) { ... } freeloop(false); basically you put the freeloop toggle around your for() loop
  16. Upvote
    meko got a reaction from MikZ in inarrary error (help)   
    inarray() is not a script command of Hercules (see the docs in doc/script_commands.txt) and is also not included in the "Array manipulation functions" script
     
    You should either replace it with a for() loop or if you want to use Array manipulation functions you should use array_exists() like so:
    // with Array manipulation functions: if (!array_exists(.@unique_id, get_unique_id())) { ... } // with a for() loop: .@size = getarraysize(.@unique_id); for (.@k = 0; .@k < .@size; ++.@k) { if (.@unique_id[.@k] == get_unique_id()) { break; } ... }  
    Keep in mind that get_unique_id() is also not part of Hercules so if you don't have a plugin that provides it or source mods (not recommended) it will not work
  17. Like
    meko got a reaction from ThyroDree in Some map-server error   
    This is a known issue and will be fixed in today's release
  18. Upvote
    meko got a reaction from heroji in Kafra points does not decrease..   
    use @price instead of @points
  19. Upvote
    meko got a reaction from Fou-lu in Google Translate Plugin   
    You can hook into the chat and whisper-related functions with a HPM plugin and then call the Google Cloud Translation API but this will be very costly because you have to translate every single message into the local language of every listening player so if you have a player speaking English and there's 50 players around them and they all use a different language you end up sending 50 translation requests to the API. You could do the translation client-side but you would have to build your google translate logic directly into the RO client. Keep in mind that this will also increase lag because you wait on API responses before displaying the message.
  20. Upvote
    meko got a reaction from Fou-lu in Google Translate Plugin   
    You'd want to do the translation offline (not on a live server, on-the-fly) using a HPM plugin (such as generate-translations) to generate your po files and then you would use a script (maybe in python, so you could use that python lib you linked) to call the google "cloud translation" api and translate your po file. You could also put both the po generator and translation routine in the same HPM plugin (using generate-translations as base and expanding from there)
  21. Upvote
    meko got a reaction from Tsuuu in Need help about advanced stylist   
    pow() has been replaced by the exponentiation operator (x ** y),
    see here: 
     
     
     
    In your case you would need to do these changes:
    // change this set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$; // to this: .@num$ = .@num % (10 ** (.@i + 1)) / (10 ** .@i) + .@num$;  
  22. Like
    meko got a reaction from Tio Akima in Create instance for just one player   
    It's IOT_CHAR, not IM_CHAR
    .@char = getcharid(CHAR_ID_CHAR); .@account = getcharid(CHAR_ID_ACCOUNT); .@map_name$ = "mapname"; // the map you want to instance .@instance_name$ = sprintf("%s@%i%d", .@map_name$, .@char, gettime(GETTIME_SECOND)); // a unique name for your instance .@instance = instance_create(.@instance_name$, .@account, IOT_CHAR); // create the instance and attach it to the char .@instanced_map_name$ = sprintf("%s@%i", .@map_name$, .@instance); // a unique name for the instanced map .@map$ = instance_attachmap(.@map_name$, .@instance, false, .@instanced_map_name$); // attach the instanced map to your instance instance_timeout(600, 1, .@instance); // alive and idle timeout, in seconds // setup is ready so init the instance and warp the player instance_init(.@instance); warpchar(.@map$, 20, 20, .@char); // the (x,y) starting point
  23. Like
    meko got a reaction from Senos in Functions   
    The documentation resides in the /doc folder of your cloned git repository and the scripting engine documentation is in /doc/script_commands.txt
    The version you have locally may not be the version that is currently on GitHub so always use the documentation in the /doc subfolder of the emulator root folder since its version is always the same as the version of your Hercules emulator (when properly cloning and pulling with git)
     
    Please be aware that some commands have been deprecated over the years and replaced with other commands. The documentation will tell you when a command is deprecated and you can find more details in the Deprecation thread.
  24. Upvote
    meko reacted to Naruto in How to put a skill as a platinum skill   
    its the quest tag in your DB and in the skillinfo.lub
  25. Like
    meko got a reaction from Tio Akima in get npc name   
    use strnpcinfo() like
    strnpcinfo(NPC_NAME_UNIQUE, "", npc id)  
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.