Jump to content

meko

Core Developers
  • Content Count

    363
  • Joined

  • Days Won

    46

Reputation Activity

  1. Upvote
    meko got a reaction from luizragna in Script command execute for all players in the map   
    @luizragna this because mes() and most commands only run for the attached player. If you want to run it for another player you will have to attachrid(.@units[.@i]); or addtimer(0, "MyNPC::MyEvent", .@units[.@i]);
    If you go for the timer approach you might as well just use maptimer()
  2. Upvote
    meko reacted to bWolfie in Script command execute for all players in the map   
    First use getunits() to capture all players on the map in an array.
    Then loop through the array using the for() function.
    Sample:
    .@count = getunits(BL_PC, .@units, false, "prontera"); // Adds all BL_PC on prontera type to the array .@units for (.@i = 0; .@i < .@count; .@i++) debugmes(sprintf("%s", rid2name(.@units[.@i]))); // Prints a debug msg in console of the player name It's returning their Account ID btw.
  3. Upvote
    meko got a reaction from stivinov in Linux refuses to start the emulator   
    chmod u+x ./{login,char,map}-server
     
    If you want to keep the file ownership and permissions intact when copying from linux to windows you should first make a tarball on the source machine and then download this instead of downloading every file one by one (ie via FTP)
  4. Upvote
    meko got a reaction from JulioCF in Deprecated Features   
    As of June 3rd, the specialeffect() command has been upgraded and it now allows to use effects on any kind of unit (player, npc, mob, homunculus, ...) and to show it to any player. This allowed us to deprecate specialeffect2() and misceffect() so now there is a single command for effects instead of 3 different ones, making things simpler for everyone. You can still use specialeffect2() and misceffect() but they will trigger a warning every time, since they will be removed in the future.
     
    Here's how the updated specialeffect() command works:
     
    specialeffect(effect number{, send target{, unit id{, account id ]}})
     
    effect number is the effect to use.
    see effect_list.txt for a list of all effects
     
    send target is to whom the effect should be sent. The most common values are:
    AREA will show the effect to every player in the area
    SELF will show the effect to one player only
    see constants.md for a list of possible send targets
     
    unit id is the unit on which the effect should be centered
    it can be a mob id, an account id, a npc id or the id of any other kind of unit
     
    account id is the player to which the effect should be sent if SELF was specified as send target
     
    To migrate from specialeffect2 to specialeffect:
     
    specialeffect2(effect) ➜ specialeffect(effect, AREA, playerattached())

    specialeffect2(effect, target, "player name") ➜ specialeffect(effect, target, getcharid(CHAR_ID_ACCOUNT, "player name"))
     
    To migrate from misceffect to specialeffect:
    Because the behaviour of this command varies depending on if the npc has a sprite or not, what you want is either one of the two:

    misceffect(effect) ➜ specialeffect(effect)

    misceffect(effect) ➜ specialeffect(effect, AREA, playerattached())
  5. Upvote
    meko got a reaction from AnnieRuru in Array manipulation functions   
    released version 10, which adds array_sort() and array_rsort()
    uses the Lomuto implementation of the Quicksort algorithm
    works with both string arrays (arr$) and integer arrays (arr)
  6. 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  
  7. Upvote
    meko got a reaction from AnnieRuru in Array manipulation functions   
    @AnnieRuru I just released version 9, which adds array_filter() and makes array_shuffle() use the Durstenfeld implementation of the Fisher-Yates algorithm
  8. Upvote
    meko got a reaction from LipESprY in [Solved] How to check if a player is attached? // strcharinfo(0)   
    if (playerattached()) {  getitem(MY_ITEM, 1); }  
  9. Upvote
    meko got a reaction from luizragna in The character stands still when use menu command   
    use close(); instead of end();
    also menu() is deprecated, so please use select()
  10. Upvote
    meko got a reaction from Atomik in Help me understand What is getarg(0)   
    function foobar { .@first_argument$ = getarg(0); // get the value of the first argument passed to foobar() .@output$ = "Hello " + .@first_argument$; // add the value of the first argument to "Hello" return .@output$; // exit the function, while returning the value of .@output$ } mes(foobar("world")); // Hello World  
  11. Upvote
    meko got a reaction from MikZ in SCRIPT ERROR (MULTI CURRENCY SHOP)   
  12. Upvote
    meko got a reaction from MikZ in SCRIPT ERROR (MULTI CURRENCY SHOP)   
    .@num$ = .@num % (10 ** (.@i + 1)) / (10 ** .@i) + .@num$; // x = (y mod (10 ** (z + 1)) / (10 ** z)) // x = y mod 10 // this means it can be simplified to: .@num$ = (.@num % 10) + .@num$; but I believe your original script had an error because it uses both .@num and .@num$
  13. Upvote
    meko got a reaction from Mihael in Deprecated Features   
    As of September 18 2017, the useatcmd() command has been deprecated.


    If you were using useatcmd() for built-in @commands you can simply replace it with atcommand():
    useatcmd("@command") ➜ atcommand("@command")
     
     
    If you were using useatcmd() for custom @commands (registered with bindatcmd()) you can use doevent() instead:
    useatcmd("@custom") ➜ doevent("MyNPC::OnUseCommand");
    MyNPC is the name of the NPC in which you used bindatcmd()
    OnUseCommand is the event you registered with bindatcmd()

     

    Edge cases:
    useatcmd(), unlike atcommand(), uses the group id of the attached player rather than running with admin privileges. If you need to check whether or not a player should be able to use a command, use can_use_command()
    if (can_use_command("@foobar")) { atcommand("@foobar"); } else { dispbottom("You cannot use this command!"); }  
  14. Upvote
    meko got a reaction from IndieRO in [HELP]Item Script in CASHPOINT   
    dispbottom(sprintf("Gained 1 cash point. You now have a total of %i cash points.", ++#CASHPOINTS));  
  15. Upvote
    meko got a reaction from kukayasko in If table = 0, then VIP   
    - script AutoVIP FAKE_NPC,{ OnPCLoginEvent: // save the original group @ACTUAL_GROUP = getgroupid(); // check if the player was never a VIP if (##VIP_UNTIL < 1) { // give the free VIP status ##VIP_UNTIL = gettimetick(2) + .free_vip_length; } // check if the player is currently a VIP if (##VIP_UNTIL > gettimetick(2)) { // move the player to the VIP group until logout setgroupid(.vip_group); // notify the player dispbottom("You are a VIP player."); // schedule a timer to revert the group on expiration addtimer((##VIP_UNTIL - gettimetick(2)) * 1000, strnpcinfo(0) + "::OnExpire"); } // check if the player was a VIP but it expired while away else if (##VIP_UNTIL > 1) { goto OnExpire; } end; OnExpire: if (##VIP_UNTIL <= gettimetick(2)) { // revert to the original group setgroupid(@ACTUAL_GROUP); // notify the player dispbottom("Your VIP status expired. You are now a normal player."); // update the variable ##VIP_UNTIL = 1; } end; /////////// Configuration below OnInit: .vip_group = 1; // the ID of your VIP group .free_vip_length = (((60 * 60) * 24) * 5); // the length of the free VIP period (5 days) }  
  16. Upvote
    meko reacted to 4144 in How to Change LV UP Effect?   
    Server can select only levelup effect by id. Actual effect belong to client based on id from server.
     
  17. Upvote
    meko got a reaction from IndieRO in If table = 0, then VIP   
    - script AutoVIP FAKE_NPC,{ OnPCLoginEvent: // save the original group @ACTUAL_GROUP = getgroupid(); // check if the player was never a VIP if (##VIP_UNTIL < 1) { // give the free VIP status ##VIP_UNTIL = gettimetick(2) + .free_vip_length; } // check if the player is currently a VIP if (##VIP_UNTIL > gettimetick(2)) { // move the player to the VIP group until logout setgroupid(.vip_group); // notify the player dispbottom("You are a VIP player."); // schedule a timer to revert the group on expiration addtimer((##VIP_UNTIL - gettimetick(2)) * 1000, strnpcinfo(0) + "::OnExpire"); } // check if the player was a VIP but it expired while away else if (##VIP_UNTIL > 1) { goto OnExpire; } end; OnExpire: if (##VIP_UNTIL <= gettimetick(2)) { // revert to the original group setgroupid(@ACTUAL_GROUP); // notify the player dispbottom("Your VIP status expired. You are now a normal player."); // update the variable ##VIP_UNTIL = 1; } end; /////////// Configuration below OnInit: .vip_group = 1; // the ID of your VIP group .free_vip_length = (((60 * 60) * 24) * 5); // the length of the free VIP period (5 days) }  
  18. Upvote
    meko got a reaction from Slowpoker in lack of data on inter-server.conf   
    The SQL configuration is now in conf/global/sql_connection.conf
  19. Upvote
    meko got a reaction from Promeister in Easiest way to get offline hercs emu ragnarok?   
    Sorry, Hercules does not offer pre-built binaries. However, surely someone can hook you up if you ask nicely: https://discord.gg/ZUzbRSp
  20. Upvote
    meko reacted to Dian in Ragnarok S   
    Hi guys,
    I present to you the newest Ragnarok S, Developed for Mobile using AR.

  21. Upvote
    meko reacted to Asheraf in New in item_db   
    Hello there, the last changes were just switch from numbers to constants you can change them for your custom items using any find and replace tool available for your OS. 
  22. Upvote
    meko got a reaction from Mystery in Deprecated Features   
    As of September 18 2017, the useatcmd() command has been deprecated.


    If you were using useatcmd() for built-in @commands you can simply replace it with atcommand():
    useatcmd("@command") ➜ atcommand("@command")
     
     
    If you were using useatcmd() for custom @commands (registered with bindatcmd()) you can use doevent() instead:
    useatcmd("@custom") ➜ doevent("MyNPC::OnUseCommand");
    MyNPC is the name of the NPC in which you used bindatcmd()
    OnUseCommand is the event you registered with bindatcmd()

     

    Edge cases:
    useatcmd(), unlike atcommand(), uses the group id of the attached player rather than running with admin privileges. If you need to check whether or not a player should be able to use a command, use can_use_command()
    if (can_use_command("@foobar")) { atcommand("@foobar"); } else { dispbottom("You cannot use this command!"); }  
  23. Upvote
    meko got a reaction from aapedhep in Host Issue   
    https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-centos-quickstart
    https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-users-add.html
  24. Upvote
    meko got a reaction from KirieZ in Recent changes to the Hercules engine   
    Update: September 19 2017
     
    Projects merged:
    RoDEX Contributors: @KirieZ @hemagx @Asheraf @Dastgir @Smoke @4144 @Haru
      Item DB enhancements Contributors: @Haru @Ragno  
    New script commands:
    getdatatype getcalendartime rodex_sendmail rodex_sendmail2 rodex_sendmail_acc rodex_sendmail_acc2  
    Modified script commands:
    getgroupid recovery  
    Deprecated script commands:
    useatcmd superseded by atcommand
  25. Upvote
    meko got a reaction from Easycore in Recent changes to the Hercules engine   
    Update: September 19 2017
     
    Projects merged:
    RoDEX Contributors: @KirieZ @hemagx @Asheraf @Dastgir @Smoke @4144 @Haru
      Item DB enhancements Contributors: @Haru @Ragno  
    New script commands:
    getdatatype getcalendartime rodex_sendmail rodex_sendmail2 rodex_sendmail_acc rodex_sendmail_acc2  
    Modified script commands:
    getgroupid recovery  
    Deprecated script commands:
    useatcmd superseded by atcommand
×
×
  • Create New...

Important Information

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