public class 0200_Information_Retrieving_Commands extends Object
========================================= |0200.- Information-retrieving commands.| =========================================
| 构造器和说明 |
|---|
0200_Information_Retrieving_Commands() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addspiritball()
addspiritball <count>,<duration>{,<char_id>};
Adds spirit ball to player for 'duration' in milisecond.
|
void |
countspiritball()
countspiritball {<char_id>};
Counts the spirit ball that player has.
|
void |
delspiritball()
delspiritball <count>{,<char_id>};
Deletes the spirit ball(s) from player.
|
void |
getareausers()
getareausers("<map name>",<x1>,<y1>,<x2>,<y2>)
This function will return the count of connected characters which are located
within the specified area - an x1/y1-x2/y2 square on the specified map.
|
void |
getarraysize()
getarraysize(<array name>)
This function returns highest index of the array that is filled.
|
void |
getcharid()
getcharid(<type>{,"<character name>"})
This function will return a unique ID number of the invoking character, or, if a
character name is specified, of that player.
|
void |
getcharip()
getcharip({"<character name>"|<account id>|<char id>})
This function will return the IP address of the invoking character, or, if a player
is specified, of that character.
|
void |
getchildid()
getchildid({<char_id>})
getmotherid({<char_id>})
getfatherid({<char_id>})
These functions return the character ID of the attached player's child,
mother, mother, or father, respectively.
|
void |
getelementofarray()
getelementofarray(<array name>,<index>)
This command retrieves the value of the element of given array at given index.
|
void |
getgmlevel()
getgmlevel({<char_id>})
This function will return the (GM) level associated with the player group to which
the invoking character belongs.
|
void |
getgroupid()
getgroupid({<char_id>})
This function will return the group id to which the invoking player belongs.
|
void |
getlook()
getlook(<type>{,<char_id>})
This function will return the number for the current character look value
specified by type.
|
void |
getmapusers()
getmapusers("<map name>")
This function will return the number of users currently located on the specified
map.
|
void |
getmapxy()
getmapxy("<variable for map name>",<variable for x>,<variable for y>{,<type>,"<search value>"})
This function will locate a character object, NPC object or pet's coordinates
and place their coordinates into the variables specified when calling it.
|
void |
getmobdrops()
getmobdrops(<mob id>)
This command will find all drops of the specified mob and return the item IDs
and drop percentages into arrays of temporary global variables.
|
void |
getmonsterinfo()
getmonsterinfo(<mob ID>,<type>)
This function will look up the monster with the specified ID number in the
mob database and return the info set by TYPE argument.
|
void |
getnpcid()
getnpcid(<type>{,"<npc name>"});
Retrieves IDs of the currently invoked NPC.
|
void |
getpartnerid()
getpartnerid({<char_id>})
This function returns the character ID of the invoking character's marriage
partner, if any.
|
void |
getsavepoint()
getsavepoint(<information type>{,<char_id>})
This function will return information about the invoking character's save point.
|
void |
getscrate()
getscrate(<effect type>,<base rate>{,<GID>})
This function will return the chance of a status effect affecting the invoking
character, in percent, modified by the their current defense against said
status.
|
void |
getskilllist()
getskilllist({<char_id>});
This command sets a bunch of arrays with a complete list of skills the
invoking character has.
|
void |
getskilllv()
getskilllv(<skill id>)
getskilllv("<skill name>")
This function returns the level of the specified skill that the invoking
character has.
|
void |
gettime()
gettime(<type>)
This function will return specified information about the current system time.
|
void |
gettimestr()
gettimestr(<"time format">,<max length>{,<time_tick>})
This function will return a string containing time data as specified by the
time format.
|
void |
gettimetick()
gettimetick(<tick type>)
This function will return a tick depending on <tick type>:
0: The server's tick, a measurement in milliseconds used by the server's timer
system.
|
void |
getunits()
getunits(<type>{,<array_variable>[<first value>]})
getmapunits(<type>,<"map name">{,<array_variable>[<first value>]})
getareaunits(<type>,<"map name">,<x1>,<y1>,<x2>,<y2>{,<array_variable>[<first value>]})
The 'getunits' command will return the number of <type> objects active on the server.
|
void |
getusers()
getusers(<type>)
This function will return a number of users on a map or the whole server.
|
void |
ignoretimeout()
ignoretimeout <flag>{,<char_id>};
Disables the SECURE_NPCTIMEOUT function on the character invoking the script,
or by the given character ID/character name.
|
void |
ispartneron()
ispartneron({<char_id>})
This function returns 1 if the invoking character's marriage partner is
currently online and 0 if they are not or if the character has no partner.
|
void |
mapid2name()
mapid2name(<map ID>)
Returns the map name of the given map ID.
|
void |
readparam()
readparam(<parameter number>{,"<character name>"})
readparam(<parameter number>{,<char_id>})
This function will return the specified stat of the invoking character, or, if a
character name or character id is specified, of that player.
|
void |
skillpointcount()
skillpointcount({<char_id>})
Returns the total amount of skill points a character possesses (SkillPoint+SP's used in skills)
This command can be used to check the currently attached characters total amount of skill points.
|
void |
strcharinfo()
strcharinfo(<type>{,<char_id>})
This function will return either the name, party name or guild name for the
invoking character.
|
void |
strnpcinfo()
strnpcinfo(<type>)
This function will return the various parts of the name of the calling NPC.
|
void |
vip_status()
vip_status(<type>,{"<character name>"})
Returns various information about a player's VIP status.
|
void |
vip_time()
vip_time <time>,{"<character name>"};
Changes a player's VIP time (in minutes).
|
strcharinfo(<type>{,<char_id>})
This function will return either the name, party name or guild name for the
invoking character. Whatever it returns is determined by type.
0 - Character's name.
1 - The name of the party they're in if any.
2 - The name of the guild they're in if any.
3 - The name of the map the character is in.
If a character is not a member of any party or guild, an empty string will be
returned when requesting that information.
strnpcinfo(<type>)
This function will return the various parts of the name of the calling NPC.
Whatever it returns is determined by type.
0 - The NPC's display name (visible#hidden)
1 - The visible part of the NPC's display name
2 - The hidden part of the NPC's display name
3 - The NPC's unique name (::name)
4 - The name of the map the NPC is in.
getarraysize(<array name>)
This function returns highest index of the array that is filled.
Notice that zeros and empty strings at the end of this array are not
counted towards this number.
For example:
setarray @array[0], 100, 200, 300, 400, 500, 600;
set @arraysize,getarraysize(@array);
This will make @arraysize == 6. But if you try this:
setarray @array[0], 100, 200, 300, 400, 500, 600, 0;
set @arraysize,getarraysize(@array);
getelementofarray(<array name>,<index>)
This command retrieves the value of the element of given array at given index.
This is equivalent to using:
<array name>[<index>]
The reason for this is, that this short form is internally converted into a call
to getelementofarray, when the script is loaded.
Also useful when passing arrays to functions or accessing another npc's arrays:
getelementofarray(getarg(0),<index>)
getelementofarray(getvariableofnpc(.var, "testNPC"),<index>)
readparam(<parameter number>{,"<character name>"});
readparam(<parameter number>{,<char_id>});
This function will return the specified stat of the invoking character, or, if a
character name or character id is specified, of that player. The stat can either
be a number or parameter name, defined in 'src/map/script_constants.hpp'.
Some example parameters:
StatusPoint, BaseLevel, SkillPoint, Class, Upper, Zeny, Sex, Weight, MaxWeight,
JobLevel, BaseExp, JobExp, NextBaseExp, NextJobExp, Hp, MaxHp, Sp, MaxSp,
BaseJob, Karma, Manner, bVit, bDex, bAgi, bStr, bInt, bLuk
All of these also behave as variables, but don't expect to be able to just 'set'
them - some will not work for various internal reasons.
Example 1:
// Returns how many status points you haven't spent yet.
mes "Unused status points: " + readparam(9);
Using this particular information as a function call is not required. Typing this
will return the same result:
mes "Unused status points: " + StatusPoint;
Example 2:
You can also use this command to get stat values.
if (readparam(bVit) > 77)
mes "Only people with over 77 Vit are reading this!";
getcharid(<type>{,"<character name>"})
This function will return a unique ID number of the invoking character, or, if a
character name is specified, of that player.
Type is the kind of associated ID number required:
0 - Character ID
1 - Party ID
2 - Guild ID
3 - Account ID
4 - Battle Ground ID
5 - Clan ID
For most purposes other than printing it, a number is better to have than a name
(people do horrifying things to their character names).
If the character is not in a party or not in a guild, the function will return 0
if guild or party number is requested. If a name is specified and the character
is not found, 0 is returned.
If getcharid(0) returns a zero, the script got called not by a character and
doesn't have an attached RID. Note that this will cause the map server to
print "player not attached!" error messages, so it is preferred to use
"playerattached" to check for the character attached to the script.
if (getcharid(2) == 0)
mes "Only members of a guild are allowed here!";
getnpcid(<type>{,"<npc name>"});
Retrieves IDs of the currently invoked NPC. If a unique npc name is
given, IDs of that NPC are retrieved instead. Type specifies what ID
to retrieve and can be one of the following:
0 - NPC Game ID
If an invalid type is given or the NPC does not exist, 0 is returned.
getchildid({<char_id>});
getmotherid({<char_id>});
getfatherid({<char_id>});
These functions return the character ID of the attached player's child,
mother, mother, or father, respectively. It returns 0 if no ID is found.
if (getmotherid()) mes "Your mother's ID is: " + getmotherid();
ispartneron({<char_id>})
This function returns 1 if the invoking character's marriage partner is
currently online and 0 if they are not or if the character has no partner.
getpartnerid({<char_id>})
This function returns the character ID of the invoking character's marriage
partner, if any. If the invoking character is not married, it will return 0,
which is a quick way to see if they are married:
if (getpartnerid()) mes "I'm not going to be your girlfriend!";
if (getpartnerid()) mes "You're married already!";
getlook(<type>{,<char_id>})
This function will return the number for the current character look value
specified by type. See 'setlook' for valid look types.
This can be used to make a certain script behave differently for characters
dressed in black.
getsavepoint(<information type>{,<char_id>})
This function will return information about the invoking character's save point.
You can use it to let a character swap between several recorded save points.
Available information types are:
0 - Map name (a string)
1 - X coordinate
2 - Y coordinate
getcharip({"<character name>"|<account id>|<char id>})
This function will return the IP address of the invoking character, or, if a player
is specified, of that character. A blank string is returned if no player is attached.
Examples:
// Outputs IP address of attached player.
mes "Your IP: " + getcharip();
// Outputs IP address of character "Silver".
mes "Silver's IP: " + getcharip("Silver");
vip_status(<type>,{"<character name>"})
Returns various information about a player's VIP status.
Valid types:
VIP_STATUS_ACTIVE - VIP status: true if the player is a VIP or false if not
VIP_STATUS_EXPIRE - VIP expire timestamp if the player is VIP or 0 if not
VIP_STATUS_REMAINING - VIP time remaining in seconds
NOTE: This command is only available if the VIP System is enabled.
vip_time <time>,{"<character name>"};
Changes a player's VIP time (in minutes). A positive value will increase time, and a
negative value will decrease time.
NOTE: This command is only available if the VIP System is enabled.
addspiritball <count>,<duration>{,<char_id>};
Adds spirit ball to player for 'duration' in milisecond.
delspiritball <count>{,<char_id>};
Deletes the spirit ball(s) from player.
countspiritball {<char_id>};
Counts the spirit ball that player has.
ignoretimeout <flag>{,<char_id>};
Disables the SECURE_NPCTIMEOUT function on the character invoking the script,
or by the given character ID/character name.
Valid flag:
0 - Enabled SECURE_NPCTIMEOUT.
1 - Disable SECURE_NPCTIMEOUT.
Note: SECURE_NPCTIMEOUT must be enabled for this to work.
getmapxy("<variable for map name>",<variable for x>,<variable for y>{,<type>,"<search value>"})
This function will locate a character object, NPC object or pet's coordinates
and place their coordinates into the variables specified when calling it. It
will return 0 if the search was successful, and -1 if the parameters given were
not variables or the search was not successful.
Type is the type of object to search for:
BL_PC - Character object (default)
BL_NPC - NPC object
BL_PET - Pet object
BL_HOM - Homunculus object
BL_MER - Mercenary object
BL_ELEM - Elemental object
The search value is optional. If it is not specified, the location of the
invoking character will always be returned for types BL_PC and BL_PET,
the location of the NPC running this function for type BL_NPC.
If a search value is specified, for types BL_PC and BL_NPC, the
character or NPC with the specified name or GID will be located.
If type is BL_PET/BL_HOM/BL_MER/BL_ELEM, the search
will locate the current object of the character who's name/GID is given in the
search value, it will NOT locate the object by name.
Example:
prontera,164,301,3%TAB%script%TAB%Meh%TAB%730,{
mes "My name is Meh. I'm here so that Nyah can find me.";
close;
}
prontera,164,299,3%TAB%script%TAB%Nyah%TAB%730,{
mes "My name is Nyah.";
mes "I will now search for Meh all across the world!";
if (getmapxy(@mapname$, @mapx, @mapy, BL_NPC, "Meh") != 0) {
mes "I can't seem to find Meh anywhere!";
close;
}
mes "And I found him on map " + @mapname$ + " at X:" + @mapx + " Y:" + @mapy + " !";
close;
}
Notice that NPC objects disabled with 'disablenpc' will still be located.
mapid2name(<map ID>)
Returns the map name of the given map ID. Returns an empty string if given
map ID doesn't exist.
getgmlevel({<char_id>})
This function will return the (GM) level associated with the player group to which
the invoking character belongs. If this is somehow executed from a console command,
99 will be returned, and 0 will be returned if the account has no GM level.
This allows you to make NPC's only accessible for certain GM levels, or behave
specially when talked to by GMs.
if (getgmlevel()) mes "What is your command, your godhood?";
getgroupid({<char_id>})
This function will return the group id to which the invoking player belongs.
gettimetick(<tick type>)
This function will return a tick depending on <tick type>:
0: The server's tick, a measurement in milliseconds used by the server's timer
system. This tick is an unsigned int which loops every ~50 days.
1: The time, in seconds, since the start of the current day.
2: The system time in UNIX epoch time, or the number of seconds elapsed since
January 1st, 1970. Useful for reliably measuring time intervals.
gettime(<type>)
This function will return specified information about the current system time.
DT_SECOND - Seconds (of the current minute)
DT_MINUTE - Minutes (of the current hour)
DT_HOUR - Hour (of the current day)
DT_DAYOFWEEK - Week day (constants for MONDAY to SUNDAY are available)
DT_DAYOFMONTH - Day of the current month
DT_MONTH - Month (constants for JANUARY to DECEMBER are available)
DT_YEAR - Year
DT_DAYOFYEAR - Day of the year
DT_YYYYMMDD - current date in the form YYYYMMDD
It will only return numbers. If another type is supplied -1 will be returned.
if (gettime(DT_DAYOFWEEK) == SATURDAY) mes "It's a Saturday. I don't work on Saturdays.";
gettimestr(<"time format">,<max length>{,<time_tick>})
This function will return a string containing time data as specified by the
time format.
This uses the C function 'strfmtime', which obeys special format characters. For
a full description see, for example, the description of 'strfmtime' at
http://www.delorie.com/gnu/docs/glibc/libc_437.html
All the format characters given in there should properly work.
Max length is the maximum length of a time string to generate.
The example given in rAthena sample scripts works like this:
mes gettimestr("%Y-%m/%d %H:%M:%S",21);
The example above will print the current date and time like 'YYYY-MM/DD HH:MM:SS'.
The following example will print the date and time when the player's VIP status
expires by the given <time_tick>:
mes gettimestr("%Y-%m/%d %H:%M:%S",21,vip_status(VIP_STATUS_EXPIRE));
getusers(<type>)
This function will return a number of users on a map or the whole server. What
it returns is specified by Type.
Type can be one of the following values, which control what will be returned:
0 - Count of all characters on the map of the invoking character.
1 - Count of all characters in the entire server.
8 - Count of all characters on the map of the NPC the script is
running in.
getmapusers("<map name>")
This function will return the number of users currently located on the specified
map.
This is used officially in PVP scripts to check whether a room is filled to capacity.
getareausers("<map name>",<x1>,<y1>,<x2>,<y2>)
This function will return the count of connected characters which are located
within the specified area - an x1/y1-x2/y2 square on the specified map.
This is useful for maps that are split into many buildings, such as all the
"*_in" maps, due to all the shops and houses.
getunits(<type>{,<array_variable>[<first value>]})
getmapunits(<type>,<"map name">{,<array_variable>[<first value>]})
getareaunits(<type>,<"map name">,<x1>,<y1>,<x2>,<y2>{,<array_variable>[<first value>]})
The 'getunits' command will return the number of <type> objects active on the server.
The 'getmapunits' command will return the number of <type> objects active on the
specified <"map name">.
The 'getareaunits' command will return the number of <type> objects actively located
within the specified area where <x1>, <y1>, <x2>, <y2> form the area.
Type is the type of object to search for:
BL_PC - Character objects
BL_MOB - Monster objects
BL_PET - Pet objects
BL_HOM - Homunculus objects
BL_MER - Mercenary objects
BL_NPC - NPC objects
BL_ELEM - Elemental objects
If <array_variable> is provided:
- An int variable will return the list of GID.
- A string variable will return the list of names.
Example 1:
// getting the players count and building a string array of the names.
.@num = getunits(BL_PC,.@array$[0]);
mes "the number of Users Connected to the server is " + .@num + " .";
mes "list of Players names :";
freeloop(1); // for if the list was too big.
for(.@i=0;.@i<getarraysize(.@array$);.@i++)
mes (.@i + 1) + " " + .@array$[.@i];
freeloop(0);
end;
Example 2:
// getting the npc count in Prontera and building a string array of the names.
.@num = getmapunits(BL_NPC,"prontera",.@array$[0]);
mes "the number of NPCs in Prontera is " + .@num + " .";
mes "list of NPCs name :";
freeloop(1); // for if the list was too big.
for(.@i=0;.@i<getarraysize(.@array$);.@i++)
mes (.@i + 1) + " " + .@array$[.@i];
freeloop(0);
end;
Example 3:
// getting the monster count in Prontera with specific coordinates and building a int array of the GIDs.
.@num = getareaunits(BL_MOB,"prontera",154,186,159,182,.@array[0]);
mes "the number of Monsters in Prontera in that Coordinates is " + .@num + " .";
mes "list of Monsters GID :";
freeloop(1); // for if the list was too big.
for(.@i=0;.@i<getarraysize(.@array);.@i++)
mes (.@i + 1) + " " + .@array[.@i];
freeloop(0);
end;
getskilllv(<skill id>);
getskilllv("<skill name>");
This function returns the level of the specified skill that the invoking
character has. If they don't have the skill, 0 will be returned. The full list
of character skills is available in 'db/(pre-)re/skill_db.txt'.
There are two main uses for this function, it can check whether the character
has a skill or not, and it can tell you if the level is high enough.
Example 1:
if (getskilllv(152))
mes "You have got the skill Throw Stone";
else
mes "You don't have Throw Stone";
close;
Example 2:
if (getskilllv(28) >= 5)
mes "Your heal lvl is 5 or more";
else if (getskilllv(28) == 10)
mes "Your heal lvl has been maxed";
else
mes "You heal skill is below lvl 5";
close;
getskilllist({<char_id>});
This command sets a bunch of arrays with a complete list of skills the
invoking character has. Here's what you get:
getmonsterinfo(<mob ID>,<type>)
This function will look up the monster with the specified ID number in the
mob database and return the info set by TYPE argument.
It will return -1 if there is no such monster (or the type value is invalid),
or "null" if you requested the monster's name.
Valid types are:
MOB_NAME - monster's name, if there is no such monster "null" is returned
MOB_LV - monster's level
MOB_MAXHP - monster's maximum hp
MOB_BASEEXP - monster's base experience
MOB_JOBEXP - monster's job experience
MOB_ATK1 - monster's atk
MOB_ATK2 - monster's atk2
MOB_DEF - monster's def
MOB_MDEF - monster's mdef
MOB_STR - monster's str
MOB_AGI - monster's agi
MOB_VIT - monster's vit
MOB_INT - monster's int
MOB_DEX - monster's dex
MOB_LUK - monster's luk
MOB_RANGE - monster's range
MOB_RANGE2 - monster's range2
MOB_RANGE3 - monster's range3
MOB_SIZE - monster's size
MOB_RACE - monster's race
MOB_ELEMENT - monster's element(doesn't return the element level, only the element ID)
MOB_MODE - monster's mode
MOB_MVPEXP - monster's mvp experience
For more details, see the sample in 'doc/sample/getmonsterinfo.txt'.
getmobdrops(<mob id>)
This command will find all drops of the specified mob and return the item IDs
and drop percentages into arrays of temporary global variables.
'getmobdrops' returns 1 if successful and 0 if the mob ID doesn't exist.
Upon executing this,
$@MobDrop_item[] is a global temporary number array which contains the
item IDs of the monster's drops.
$@MobDrop_rate[] is a global temporary number array which contains the
drop percentages of each item. (1 = .01%)
$@MobDrop_count is the number of item drops found.
Be sure to use $@MobDrop_count to go through the arrays, and not
'getarraysize', because the temporary global arrays are not cleared between
runs of 'getmobdrops'. If a mob with 7 item drops is looked up, the arrays would
have 7 elements. But if another mob is looked up and it only has 5 item drops,
the server will not clear the arrays for you, overwriting the values instead. So
in addition to returning the 5 item drops, the 6th and 7th elements from the
last call remain, and you will get 5+2 item drops, of which the last 2 don't
belong to the new mob. $@MobDrop_count will always contain the correct number
(5), unlike 'getarraysize()' which would return 7 in this case.
Example:
// get a Mob ID from the user
input .@mob_id;
if (getmobdrops(.@mob_id)) { // 'getmobdrops' returns 1 on success
// immediately copy global temporary variables into scope variables,
// since we don't know when 'getmobdrops' will get called again for
// another mob, overwriting your global temporary variables
.@count = $@MobDrop_count;
copyarray .@item[0],$@MobDrop_item[0],.@count;
copyarray .@rate[0],$@MobDrop_rate[0],.@count;
mes getmonsterinfo(.@mob_id,MOB_NAME) + " - " + .@count + " drops found:";
for( .@i = 0; .@i < .@count; .@i++ ) {
mes .@item[.@i] + " (" + getitemname(.@item[.@i]) + ") " + .@rate[.@i]/100 + ((.@rate[.@i]%100 < 10) ? ".0":".") + .@rate[.@i]%100 + "%";
}
} else {
mes "Unknown monster ID.";
}
close;
skillpointcount({<char_id>})
Returns the total amount of skill points a character possesses (SkillPoint+SP's used in skills)
This command can be used to check the currently attached characters total amount of skill points.
This means the skill points used in skill are counted, and added to SkillPoints (number of skill points not used).
This command does not count skills which are set as flag 4 (permament granted) (ALL_BUYING_STORE/ALL_INCCARRY)
Example 1:
.@skillPoints = skillpointcount();
mes "You have " + .@skillPoints + " skill points in total!";
Example 2:
if (skillpointcount() > 20)
mes "Wow, you have more then 20 Skill Points in total!";
getscrate(<effect type>,<base rate>{,<GID>})
This function will return the chance of a status effect affecting the invoking
character, in percent, modified by the their current defense against said
status. The 'base rate' is the base chance of the status effect being inflicted,
in percent.
if (rand(100) > getscrate(Eff_Blind, 50)) goto BlindHimNow;
You can see the full list of available effect types you can possibly inflict in
'db/const.txt' under 'Eff_'.
Copyright © 工程的初始时间(可选)–2019. All rights reserved.