Jump to content

meko

Core Developers
  • Content Count

    322
  • Joined

  • Last visited

  • Days Won

    42

meko last won the day on December 17 2019

meko had the most liked content!

About meko

  • Rank
    Advanced Member

Contact Methods

  • IRC Nickname
    meko

Profile Information

  • Gender
    Not Telling
  • Github
    Helianthella

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. instead of using item names in your array you should be using item constants if what you want is item IDs, so something like setarray([email protected]$, "Jellopy", "Large_Jellopy", ...); becomes setarray([email protected], Jellopy, Large_Jellopy, ...); so you use the unquoted AegisName from the item db, which is a constant of its ID but anyway, the getitem() command does work with both the item ID and the AegisName so if you are using the name it should work fine. // all of these are equivalent: getitem(501, 1); getitem(Red_Potion, 1); getitem("Red_Potion", 1); // but this won't work: getitem("Red Potion", 1);
  2. It's IOT_CHAR, not IM_CHAR [email protected] = getcharid(CHAR_ID_CHAR); [email protected] = getcharid(CHAR_ID_ACCOUNT); [email protected]_name$ = "mapname"; // the map you want to instance [email protected]_name$ = sprintf("%[email protected]%i%d", [email protected]_name$, [email protected], gettime(GETTIME_SECOND)); // a unique name for your instance [email protected] = instance_create([email protected]_name$, [email protected], IOT_CHAR); // create the instance and attach it to the char [email protected]_map_name$ = sprintf("%[email protected]%i", [email protected]_name$, [email protected]); // a unique name for the instanced map [email protected]$ = instance_attachmap([email protected]_name$, [email protected], false, [email protected]_map_name$); // attach the instanced map to your instance instance_timeout(600, 1, [email protected]); // alive and idle timeout, in seconds // setup is ready so init the instance and warp the player instance_init([email protected]); warpchar([email protected]$, 20, 20, [email protected]); // the (x,y) starting point
  3. if you want to give an item to every guild member on the current map you can use getunits(), something like [email protected] = getcharid(CHAR_ID_GUILD); [email protected]$ = getmapinfo(MAPINFO_NAME); // check to make sure we're not iterating for nothing if ([email protected] && getmapguildusers([email protected]$, [email protected]) > 1) { // get every player on the current map [email protected] = getunits(BL_PC, [email protected], false, [email protected]$); // iterate over all those players for ([email protected] = 0; [email protected] < [email protected]; [email protected]) { // check if they are in the same guild if ([email protected][[email protected]] != playerattached() && getcharid(CHAR_ID_GUILD, strcharinfo(PC_NAME, "", [email protected][[email protected]])) == [email protected]) { getitem({{item}}, {{amount}}, [email protected][[email protected]]); } } } To give to offline guild members you could use the RoDEX system
  4. the login and guild tables should not be used to store variables, it is better to use variables directly, but if you must then you want a query that spans multiple tables, something like -- give 100 "pontosgwot" to the player that killed it UPDATE `login` SET `pontosgwot`=`pontosgwot`+100 WHERE `account_id`={{GID}}; -- give 50 "pontosgwot" and 1 "baus" to everyone else in the guild UPDATE `login` SET `login`.`pontosgwot`=`login.pontosgwot`+50 WHERE `login`.`account_id`=`char.account_id` AND `char`.`guild_id`={{GUILD}} AND `char`.`char_id`<>{{GID}}; UPDATE `login` SET `login`.`baus`=`login.baus`+1 WHERE `login`.`account_id`=`char.account_id` AND `char`.`guild_id`={{GUILD}} AND `char`.`char_id`<>{{GID}}; Replace {{GID}} with the account id and {{GUILD}} with the guild id This is very slow though so don't do this unless you really need to
  5. meko

    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.
  6. meko

    get npc name

    use strnpcinfo() like strnpcinfo(NPC_NAME_UNIQUE, "", npc id)
  7. // set the unit ID of the target [email protected]_id = XXXXX; // get the location of the target (change TYPE to PC/MOB/...) getmapxy([email protected]$, [email protected], [email protected], UNITTYPE_{{TYPE}}, [email protected]_id); // get all mobs within a 3 cell radius around the target [email protected] = getunits(BL_MOB, [email protected][0], false, [email protected]$, max(0, [email protected] - 3), max(0, [email protected] - 3), [email protected] + 3, [email protected] + 3); // iterate over the mob units for ([email protected] = 0; [email protected] < [email protected]; [email protected]) { [email protected] = [email protected][[email protected]]; // ... do something with your [email protected] }
  8. 10 to the power of 10 is 10,000,000,000 but the scripting engine uses signed 32-bit integers and the maximum value that can be held by such integers is 2,147,483,647 (2^31 − 1). Any value above this will cause the integer to overflow so you have to be aware of this and manually check the boundaries. In your case this would mean checking that getarg(0) is shorter than 10 characters long so if ( [email protected] == 0 || [email protected] >= 10 ** 9 ) return getarg(0); instead of if ( [email protected] == 0 || [email protected] >= 2147483647 ) return getarg(0); to avoid the case where getstrlen is above 10
  9. the exponentiation operator (**) has higher precedence than the addition operator (+) so this means A ** B+C is interpreted as (A ** B) + C because the exponentiation operation has priority over the addition operation also worth noting that exponentiation has higher precedence than multiplication/division so a more complex formula like A + B * C ** D would be interpreted as A + (B * (C ** D)) so you have to manually reorder the operations with explicit parentheses if you want to change the precedence, like (A + (B * C)) ** D
  10. no need for SQL nor a timer: just store the date instead of a true/false boolean // check whether the last reward was given today or another day if (gettime(GETTIME_DAYOFYEAR) == #LAST_REWARD) { mes("you already got a reward today"); } else { mes("here's your reward"); ... // give reward #LAST_REWARD = gettime(GETTIME_DAYOFYEAR); // set it to today }
  11. there's a few different ways: [email protected] = charat("Test3", 4); sscanf("Test3", "Test%d", [email protected]); [email protected] = substr("Test3", 4, 4); pcre_match("Test3", "^[^0-9]*([0-9]+)$"); [email protected] = [email protected]$[1];
  12. map server by itself does not auto-restart, what you are using is a wrapper script (map-server.bat) if you do not want it to restart you should use map-server.exe directly or make your own wrapper script
  13. You do know screenshots are a thing, right? and for text you can use a paste service... Anyway, you'll want to install libmariadb-client-lgpl-dev (on older Ubuntu versions you might also need libmariadbclient-dev-compat) or libmysqlclient-dev
×
×
  • Create New...

Important Information

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