The functions on this page only read character data. General condition: the character must be logged in (state LOGGED or higher). If aIndex is not a valid character, the function returns 0 (number), an empty string (string) or nil (table). The functions that read PK, guild, Gens, lives and state are on the page Player: PK, guild, account, state (Player: PK, guild, account, state).
For every function on this page whose only parameter is aIndex:
| Parameter | Type | Description |
|---|---|---|
aIndex | integer | Character index |
Identification
Player.IsOnline
Checks whether the index is a character currently playing in game (state PLAYING).
Player.IsOnline(aIndex) -> boolean
Returns: true if it is a player in game; otherwise false. This function does not require the character to be logged in, so it can be used to check before calling other functions.
if Player.IsOnline(aIndex) then Message.Send(aIndex, 1, "Hi") end
Player.GetName
Returns the character name.
Player.GetName(aIndex) -> string
Parameter: aIndex (integer). Returns: the character name; an empty string if invalid. Short name: none (use GetObjectName for any object).
Log.Add(Player.GetName(aIndex))
Player.GetAccount
Returns the account name of the character.
Player.GetAccount(aIndex) -> string
Parameter: aIndex (integer). Returns: the account name; an empty string if invalid. Short name: GetObjectAccount.
local acc = Player.GetAccount(aIndex)
Player.GetIndexByName
Finds the index of a character currently playing by name (case-insensitive).
Player.GetIndexByName(name) -> integer
| Parameter | Type | Description |
|---|---|---|
name | string | Character name |
Returns: the character index; -1 if no character with that name is in game. Short name: GetObjectIndexByName.
local idx = Player.GetIndexByName("Admin")
if idx ~= -1 then Message.Send(idx, 1, "You have been called") end
Player.GetAccountID
Returns the account's ID number in the database.
Player.GetAccountID(aIndex) -> integer
Parameter: aIndex. Returns: the account ID; 0 if invalid. Short name: GetObjectAccountID.
local id = Player.GetAccountID(aIndex)
Player.GetCharacterID
Returns the character's ID number in the database.
Player.GetCharacterID(aIndex) -> integer
Parameter: aIndex. Returns: the character ID; 0 if invalid. Short name: GetObjectPlayerID. This ID is more stable than aIndex (an index can be reused by someone else after logout), so it is often used to re-check when receiving the result of an asynchronous DB query.
local cid = Player.GetCharacterID(aIndex)
Player.GetClass
Returns the character class.
Player.GetClass(aIndex) -> integer
Parameter: aIndex. Returns: the class code (CLASS_* constants); 0 if invalid. Short name: GetObjectClass (works for any object, returns -1 if there is none).
if Player.GetClass(aIndex) == CLASS_DK then ... end
Player.GetDBClass
Returns the character class code in the form stored in the database.
Player.GetDBClass(aIndex) -> integer
Parameter: aIndex. Returns: the class code in DB form; 0 if invalid.
This code combines the class and the class changes: DBClass = (class * 16) + evolution flags. The class (the Player.GetClass value) is in the high bits (DBClass >> 4); the three low bits are the flags for the 1st class change (bit 0, value 1), the 2nd (bit 1, value 2), and the 3rd (bit 2, value 4). For example DBClass = 0x13 is class 1 that has completed the 1st and 2nd class changes.
local dbclass = Player.GetDBClass(aIndex)
Player.GetEvolution
Returns the number of times the character has changed class (evolved).
Player.GetEvolution(aIndex) -> integer
Parameter: aIndex. Returns: from 0 to 3. Short name: GetObjectChangeUp.
if Player.GetEvolution(aIndex) < 3 then ... end
Player.GetSkin
Returns the monster code that the character is transformed into.
Player.GetSkin(aIndex) -> integer
Parameter: aIndex. Returns: the monster code being transformed into; -1 if not transformed; 0 if the character is invalid. Short name: GetObjectChange.
if Player.GetSkin(aIndex) ~= -1 then Player.SetSkin(aIndex, -1) end
Player.GetVIP
Returns the VIP level of the account.
Player.GetVIP(aIndex) -> integer
Parameter: aIndex. Returns: the VIP level (-1 or 0 and above depending on the server's VIP configuration); 0 if the character is invalid. Short name: GetObjectAccountLevel.
if Player.GetVIP(aIndex) >= 1 then ... end
Player.GetVIPExpire
Returns the VIP expiration time of the account.
Player.GetVIPExpire(aIndex) -> integer
Parameter: aIndex. Returns: the expiration timestamp; 0 if invalid or none. Short name: GetObjectAccountExpireDate.
local left = Player.GetVIPExpire(aIndex) - os.time()
Levels and points
Player.GetLevel
Returns the character's normal level.
Player.GetLevel(aIndex) -> integer
Parameter: aIndex. Returns: the level; 0 if invalid. Short name: GetObjectLevel.
if Player.GetLevel(aIndex) < 400 then return end
Player.GetMasterLevel
Returns the Master level.
Player.GetMasterLevel(aIndex) -> integer
Parameter: aIndex. Returns: the Master level; 0 if invalid. Short name: GetObjectMasterLevel.
local ml = Player.GetMasterLevel(aIndex)
Player.GetMajesticLevel
Returns the Majestic level.
Player.GetMajesticLevel(aIndex) -> integer
Parameter: aIndex. Returns: the Majestic level; 0 if invalid. Short name: GetObjectMajesticLevel.
local mj = Player.GetMajesticLevel(aIndex)
Player.GetTotalLevel
Returns the character's total level as GameServer calculates it.
Player.GetTotalLevel(aIndex) -> integer
Parameter: aIndex. Returns: the total level; 0 if invalid. Short name: GetObjectToTalLevel.
Formula: if the normal level has not reached the maximum level, total level = normal level. When the normal level is at the maximum, total level = normal level + Master level (if the character has entered Master) + Majestic level (if the character has entered Majestic).
local total = Player.GetTotalLevel(aIndex)
Player.GetLevelUpPoint
Returns the number of unused bonus points of the normal level.
Player.GetLevelUpPoint(aIndex) -> integer
Parameter: aIndex. Returns: the number of points; 0 if invalid. Short name: GetObjectLevelUpPoint.
local pts = Player.GetLevelUpPoint(aIndex)
Player.GetMasterPoint
Returns the number of unused Master points.
Player.GetMasterPoint(aIndex) -> integer
Parameter: aIndex. Returns: the number of points; 0 if invalid. Short name: GetObjectMasterPoint.
local pts = Player.GetMasterPoint(aIndex)
Player.GetMajesticPoint
Returns the number of unused Majestic points.
Player.GetMajesticPoint(aIndex) -> integer
Parameter: aIndex. Returns: the number of points; 0 if invalid. Short name: GetObjectMajesticPoint.
local pts = Player.GetMajesticPoint(aIndex)
Player.GetUsedMasterPoints
Returns the total levels invested in the Master skill tree (the number of Master points used).
Player.GetUsedMasterPoints(aIndex) -> integer
Parameter: aIndex. Returns: the total skill levels in the Master tree; 0 if invalid.
local used = Player.GetUsedMasterPoints(aIndex)
Player.GetExperience
Returns the current experience (EXP) of one level type.
Player.GetExperience(aIndex, levelType) -> number
| Parameter | Type | Description |
|---|---|---|
aIndex | integer | Character index |
levelType | integer | 0 normal level, 1 Master, 2 Majestic |
Returns: the current EXP; 0 if the parameters are wrong.
local exp = Player.GetExperience(aIndex, 0)
Player.GetNextExperience
Returns the EXP threshold needed to reach the next level of one level type.
Player.GetNextExperience(aIndex, levelType) -> number
| Parameter | Type | Description |
|---|---|---|
aIndex | integer | Character index |
levelType | integer | 0 normal level, 1 Master, 2 Majestic |
Returns: the EXP needed for the next level; 0 if the parameters are wrong.
local need = Player.GetNextExperience(aIndex, 0) - Player.GetExperience(aIndex, 0)
Player.GetLastGainedExp
Returns the amount of EXP the character received in the most recent EXP gain.
Player.GetLastGainedExp(aIndex) -> number
Parameter: aIndex. Returns: the EXP of the last gain; 0 if there has been none. Short name: GetObjectLastGainedExp.
local gained = Player.GetLastGainedExp(aIndex)
Currency
Player.GetMoney
Returns the amount of zen the character has.
Player.GetMoney(aIndex) -> integer
Parameter: aIndex. Returns: the amount of zen; 0 if invalid. Short name: GetObjectMoney.
if Player.GetMoney(aIndex) < 1000000 then return end
Player.GetRuud
Returns the amount of Ruud the character has.
Player.GetRuud(aIndex) -> integer
Parameter: aIndex. Returns: the amount of Ruud; 0 if invalid. Short name: GetObjectRuud.
local ruud = Player.GetRuud(aIndex)
Player.GetReset
Returns the character's number of Resets.
Player.GetReset(aIndex) -> integer
Parameter: aIndex. Returns: the number of Resets; 0 if invalid. Short name: GetObjectReset.
local rs = Player.GetReset(aIndex)
Player.GetConsumePoint
Returns the total points the character has received from the configuration Data\Plugin\ConsumeItem.xml (these points are refunded when stats are cleared through the Reset interface).
Player.GetConsumePoint(aIndex) -> integer
Parameter: aIndex. Returns: the total points; 0 if invalid.
local pts = Player.GetConsumePoint(aIndex)
Character stats
The stat parameter selects the stat type: 0 Strength (STAT_STRENGTH), 1 Agility (STAT_AGILITY), 2 Vitality (STAT_VITALITY), 3 Energy (STAT_ENERGY), 4 Command (STAT_LEADERSHIP).
Player.GetStat
Returns the base points of a stat.
Player.GetStat(aIndex, stat) -> integer
| Parameter | Type | Description |
|---|---|---|
aIndex | integer | Character index |
stat | integer | 0 to 4 (see above) |
Returns: the base points; 0 if the parameters are wrong. Short names: GetObjectStrength, GetObjectDexterity, GetObjectVitality, GetObjectEnergy, GetObjectLeadership.
local str = Player.GetStat(aIndex, STAT_STRENGTH)
Player.GetTotalStat
Returns the total stat: base points plus the added part from items, buffs...
Player.GetTotalStat(aIndex, stat) -> integer
| Parameter | Type | Description |
|---|---|---|
aIndex | integer | Character index |
stat | integer | 0 to 4 |
Returns: the total stat; 0 if the parameters are wrong. Short names: GetObjectTotalStrength, GetObjectTotalDexterity, GetObjectTotalVitality, GetObjectTotalEnergy, GetObjectTotalLeadership.
local total = Player.GetTotalStat(aIndex, STAT_ENERGY)
Player.GetAddStat
Returns the added part of a stat (from items, buffs...) calculated at the most recent stat calculation.
Player.GetAddStat(aIndex, stat) -> integer
| Parameter | Type | Description |
|---|---|---|
aIndex | integer | Character index |
stat | integer | 0 to 4 |
Returns: the added part; 0 if the parameters are wrong. Short names: GetObjectExtraStrength, GetObjectExtraDexterity, GetObjectExtraVitality, GetObjectExtraEnergy, GetObjectExtraLeadership.
local bonus = Player.GetAddStat(aIndex, STAT_STRENGTH)
Player.GetDefaultStat
Returns the starting stat of the character's class (when a new character is created).
Player.GetDefaultStat(aIndex, stat) -> integer
| Parameter | Type | Description |
|---|---|---|
aIndex | integer | Character index |
stat | integer | 0 to 4 |
Returns: the starting stat; 0 if the parameters are wrong. Short names: GetObjectDefaultStrength, GetObjectDefaultDexterity, GetObjectDefaultVitality, GetObjectDefaultEnergy, GetObjectDefaultLeadership.
local base = Player.GetDefaultStat(aIndex, STAT_STRENGTH)
Items, quests, script stats
Player.GetItem
Returns information about the item in a slot of the main inventory (including equipment slots).
Player.GetItem(aIndex, slot) -> table | nil
| Parameter | Type | Description |
|---|---|---|
aIndex | integer | Character index |
slot | integer | Slot number, counted from 0. Use Inventory.GetSizes() to know the number of slots |
Returns: an item table (fields Index, Serial, Level, Durability, Skill, Luck, Option, Exc, Ancient, Harmony, Option380, SocketBonus, ExpireDate, Sockets; see the page Item: create, drop, random bags, Gremory box); nil if the slot is empty or the parameters are wrong. Short names: InventoryGetItemTable(aIndex, slot) (the table also has old-style field names such as Option1, NewOption) and InventoryGetItemIndex(aIndex, slot) (returns only the item code, -1 if empty).
local item = Player.GetItem(aIndex, 0) -- the first equipment slot
if item then Log.Add("Item " .. item.Index .. " +" .. item.Level) end
Player.GetQuestState
Returns the state of a class-change quest (evolution quest).
Player.GetQuestState(aIndex, quest) -> integer
| Parameter | Type | Description |
|---|---|---|
aIndex | integer | Character index |
quest | integer | Quest number (0 to 255) |
Returns: the quest state code; 0 if the parameters are wrong or the quest does not exist. Short name: QuestStateCheck.
| Value | Meaning |
|---|---|
0 | Quest not accepted |
1 | Accepted (in progress) |
2 | Conditions completed, quest not yet turned in |
3 | Quest turned in (fully done) |
local st = Player.GetQuestState(aIndex, 0)
Player.GetOptionTable
Returns the table of 45 extra stats that scripts have set for the character (using Player.SetOptionTable). The default value is 0.
Player.GetOptionTable(aIndex) -> table
Parameter: aIndex. Returns: a table with the following fields (all numeric):
- Additions (Add...):
AddDamage,AddPhysiDamage,AddMagicDamage,AddCurseDamage,AddDefense,AddDefenseRate,AddElementalDamage,AddElementalDefense,AddSpeed,AddMaxHP,AddMaxMP,AddMaxBP,AddMaxSD,AddHPRecoveryRate,AddMPRecoveryRate,AddBPRecoveryRate,AddSDRecoveryRate,AddDamageReduction,AddDamageDecrease,AddDamageReflect,AddCriticalDamage,AddExcellentDamage,AddCriticalDamageRate,AddExcellentDamageRate,AddIgnoreDefenseRate,AddDoubleDamageRate,AddTripleDamageRate,AddFullDamageReflectRate,AddDefensiveFullHPRestoreRate,AddDefensiveFullSDRestoreRate,AddOffensiveFullHPRestoreRate,AddOffensiveFullSDRestoreRate - Percentage multipliers (Mul...):
MulDamage,MulPhysiDamage,MulMagicDamage,MulCurseDamage,MulDefense,MulElementalDamage,MulElementalDefense,MulMaxHP,MulMaxMP,MulMaxBP,MulMaxSD - Other:
CombatPower(only stored for scripts to read back, GameServer does not use it),ExpRate(added to the EXP rate)
Short name: UserGetOptionTable. The values only take effect on the character after GameServer recalculates stats (see Player.SetOptionTable and Player.ReCalc).
local opt = Player.GetOptionTable(aIndex)
Log.Add("AddDamage = " .. opt.AddDamage)