Player 表的更多读取函数。通用条件:角色已登录(处于 LOGGED 及以上状态);否则函数按各函数的说明返回 0 / 空字符串 / false。大多数函数只有 aIndex 参数(integer,角色索引);带有额外参数的函数会明确列出。
PK
Player.GetPKCount
返回角色当前的杀人次数(PK 点数)。
Player.GetPKCount(aIndex) -> integer
参数:aIndex。返回:PK 次数;无效时返回 0。简称:GetObjectPKCount。
local pk = Player.GetPKCount(aIndex)
Player.GetPKLevel
返回 PK 等级(英雄 / 普通 / 杀人犯状态)。
Player.GetPKLevel(aIndex) -> integer
参数:aIndex。返回:PK 等级;无效时返回 0。简称:GetObjectPKLevel。
| 值 | 含义 |
|---|---|
0 | 英雄(Hero) |
1 | 2 级英雄 |
2 | 1 级英雄 |
3 | 普通(Commoner) |
4 | 1 级杀人犯 |
5 | 2 级杀人犯 |
6 | 3 级杀人犯 |
local lv = Player.GetPKLevel(aIndex)
Player.GetPKTimer
返回角色的 PK 点数 / PK 计时器(GameServer 中的 PKPoints 值)。
Player.GetPKTimer(aIndex) -> integer
参数:aIndex。返回:计数器值;无效时返回 0。简称:GetObjectPKTimer。
local t = Player.GetPKTimer(aIndex)
Player.GetPKTotalCount
返回角色累计击杀其他玩家的总次数统计。
Player.GetPKTotalCount(aIndex) -> integer
参数:aIndex。返回:总次数;无效时返回 0。
local total = Player.GetPKTotalCount(aIndex)
组队与公会
Player.GetPartyNumber
返回角色的队伍(party)编号。
Player.GetPartyNumber(aIndex) -> integer
参数:aIndex。返回:队伍编号;没有队伍时返回 -1。简称:GetObjectPartyNumber。
local party = Player.GetPartyNumber(aIndex)
if party == -1 then return end
Player.GetGuildNumber
返回角色的公会编号。
Player.GetGuildNumber(aIndex) -> integer
参数:aIndex。返回:公会编号;无效或角色没有公会时返回 0。简称:GetObjectGuildNumber。
local g = Player.GetGuildNumber(aIndex)
Player.GetGuildStatus
返回角色在公会中的职位。
Player.GetGuildStatus(aIndex) -> integer
参数:aIndex。返回:128 会长,64 副会长,32 战斗长,0 成员,-1 没有公会。简称:GetObjectGuildStatus。
if Player.GetGuildStatus(aIndex) == 128 then Message.Send(aIndex, 1, "您是公会会长") end
Player.GetGuildName
返回角色所在公会的名称。
Player.GetGuildName(aIndex) -> string
参数:aIndex。返回:公会名称;没有公会时返回空字符串。简称:GetObjectGuildName。
local gname = Player.GetGuildName(aIndex)
Player.GetGuildRelationship
返回两个角色之间的公会关系。
Player.GetGuildRelationship(aIndex, bIndex) -> integer
| 参数 | 类型 | 说明 |
|---|---|---|
aIndex | integer | 第一个角色的索引 |
bIndex | integer | 第二个角色的索引 |
返回:关系代码;两个角色中任意一个无效时返回 0。简称:GetObjectGuildRelationship。
| 值 | 含义 |
|---|---|
0 | 无关系(或其中一方没有公会) |
1 | 同一联盟(alliance) |
2 | 敌对(被设为对手的公会,包括与对方同盟公会敌对的情况) |
local rel = Player.GetGuildRelationship(aIndex, bIndex)
Player.GetGuildUnionNumber
返回角色所在公会的联盟(alliance)编号。
Player.GetGuildUnionNumber(aIndex) -> integer
参数:aIndex。返回:联盟编号;没有时返回 0。简称:GetObjectGuildUnionNumber。
local union = Player.GetGuildUnionNumber(aIndex)
Player.GetGuildUnionName
返回联盟盟主公会的名称。
Player.GetGuildUnionName(aIndex) -> string
参数:aIndex。返回:联盟盟主公会名称;没有时返回空字符串。简称:GetObjectGuildUnionName。
local un = Player.GetGuildUnionName(aIndex)
Player.GetCastleSiegeSide
返回角色在攻城战中所属的阵营。
Player.GetCastleSiegeSide(aIndex) -> integer
参数:aIndex。返回:攻 / 守阵营代码(见下表);无效或未参战时返回 0。简称:GetObjectCSGuildSide。
| 值 | 含义 |
|---|---|
0 | 未参战 |
1 | 守方 |
2, 3, 4 | 攻方(攻方 1、2、3) |
local side = Player.GetCastleSiegeSide(aIndex)
Gens
Player.GetGensRank
返回角色的 Gens 排名。
Player.GetGensRank(aIndex) -> integer
参数:aIndex。返回:排名;无效时返回 0。简称:GetObjectGensRank。
local r = Player.GetGensRank(aIndex)
Player.GetGensSymbol
返回角色的 Gens 军衔等级(标志)。
Player.GetGensSymbol(aIndex) -> integer
参数:aIndex。返回:Gens 军衔等级;无效时返回 0。简称:GetObjectGensSymbol。
local s = Player.GetGensSymbol(aIndex)
Player.GetGensFamily
返回角色所属的 Gens 阵营。
Player.GetGensFamily(aIndex) -> integer
参数:aIndex。返回:1 Duprian,2 Vanert(服务器存储的值);0 表示没有阵营 / 无效。
GetObjectGensFamily 将两个阵营反过来:Vanert 返回 1,Duprian 返回 2。同一个脚本中请只统一使用其中一种,以免混淆。if Player.GetGensFamily(aIndex) == 1 then Log.Add("Duprian") end
Player.GetGensContribution
返回 Gens 贡献点数。
Player.GetGensContribution(aIndex) -> integer
参数:aIndex。返回:贡献点数;无效时返回 0。简称:GetObjectGensContribution。
local c = Player.GetGensContribution(aIndex)
GM 权限
Player.GetAuthority
返回账号的权限(authority)代码。
Player.GetAuthority(aIndex) -> integer
参数:aIndex。返回:权限代码;无效时返回 0。简称:GetObjectAuthority。
local a = Player.GetAuthority(aIndex)
Player.IsGameMaster
检查角色是否为 GM 且已开启权限(.auth 命令)。
Player.IsGameMaster(aIndex) -> boolean
参数:aIndex。返回:如果是已开启权限的 GM 则返回 true;否则返回 false。简称:CommandCheckGameMasterLevel(aIndex, level) 返回 1 / 0,并且忽略 level 参数。
if not Player.IsGameMaster(aIndex) then return 0 end
Player.HasAdminFlag
检查 GM 是否拥有某个特定的权限标志。
Player.HasAdminFlag(aIndex, flag) -> boolean
| 参数 | 类型 | 说明 |
|---|---|---|
aIndex | integer | 角色索引 |
flag | integer | 权限标志代码(大于 0) |
返回:如果角色是 GM 且拥有该标志则返回 true;否则返回 false。
标志是可叠加的位,存储在角色数据中(游戏数据库里角色的权限标志列)。各标志的值如下:
| 值 | 标志 | 值 | 标志 |
|---|---|---|---|
1 | PARTY | 2048 | TALK |
2 | TRADE | 4096 | MOVE |
4 | GLOBAL | 8192 | RELOAD |
8 | TRACE | 16384 | MONSTER |
16 | KICK | 32768 | ZEN |
32 | EVENTS | 65536 | GUILD_TALK |
64 | MUTE | 131072 | RESTRICTION |
128 | ITEM | 262144 | SHUTDOWN |
256 | ITEM_EVENT | 524288 | PANEL |
512 | BAN | 1048576 | BUFF |
1024 | POST | 2097152 | MASIVE |
该函数使用按位 AND 与您传入的 flag 值进行检查。
if Player.HasAdminFlag(aIndex, 1) then ... end
账号与机器
Player.GetIP
返回玩家的 IP 地址。
Player.GetIP(aIndex) -> string
参数:aIndex。返回:IP 字符串;无效时返回空字符串。简称:GetObjectIpAddress。
local ip = Player.GetIP(aIndex)
Player.GetMac
返回账号发送到服务器的玩家机器 MAC 地址。
Player.GetMac(aIndex) -> string
参数:aIndex。返回:MAC 字符串;无效时返回空字符串。简称:GetPlayerMac。
local mac = Player.GetMac(aIndex)
Player.GetDiskSerial
返回玩家机器的硬盘序列号。
Player.GetDiskSerial(aIndex) -> integer
参数:aIndex。返回:硬盘序列号;无效时返回 0。简称:GetPlayerSerial(返回字符串形式)。
local serial = Player.GetDiskSerial(aIndex)
Player.GetHardwareId
返回机器标识,由 MAC 与硬盘序列号按 MAC-SERIAL 的格式拼接而成(序列号为 8 位十六进制数)。
Player.GetHardwareId(aIndex) -> string
参数:aIndex。返回:机器标识字符串;无效时返回空字符串。简称:GetObjectHardwareId。
local hw = Player.GetHardwareId(aIndex)
Player.GetCodePage
返回账号所保存的代码页(code page)编号。
Player.GetCodePage(aIndex) -> integer
参数:aIndex。返回:代码页编号;无效时返回 0。
local cp = Player.GetCodePage(aIndex)
Player.IsOffline
检查角色是否处于离线模式。
Player.IsOffline(aIndex) -> boolean
参数:aIndex。返回:离线时返回 true;否则返回 false。简称:GetObjectOfflineFlag(返回 1 / 0)。
if Player.IsOffline(aIndex) then return end
状态
Player.GetInterface
返回角色当前打开的界面窗口代码(仓库、交易、商店等)。
Player.GetInterface(aIndex) -> string
参数:aIndex。返回:窗口代码字符串;无效时返回空字符串。简称:GetObjectInterface。
没有打开任何窗口时,函数返回 "interface_none"。其他字符串:interface_shop, interface_warehouse, interface_chaos_machine, interface_blood_castle_entrance, interface_devil_square_entrance, interface_party, interface_trade, interface_guild, interface_guild_request, interface_guild_alliance, interface_duel, interface_duel_gate, interface_pet_trainer, interface_quest_support_giver, interface_quest_evolution_giver, interface_mix_jewel, interface_cash_shop, interface_harmony_refine, interface_harmony_smelt, interface_harmony_restore, interface_lucky, interface_seed_creation, interface_seed_research, interface_chaos_card, interface_castle_siege_lever, interface_lord_mix, interface_land_of_trials_guard, interface_castle_guard, interface_castle_siege_machine, interface_personal_store_open, interface_illusion_temple_entrance, interface_guild_war_request, interface_arca_battle_lesnar, interface_arka_war_sign_register, interface_arka_war_exchange, interface_adniel, interface_mining, interface_chaos_castle_mait, interface_acheron_entrance, interface_cent_town, interface_cent_entrance, interface_eunice_town, interface_eunice_entrance, interface_moss_merchant, interface_mix_recovery。
local ui = Player.GetInterface(aIndex)
Player.GetDeathLocation
返回角色在本次登录期间最近一次死亡的位置。
Player.GetDeathLocation(aIndex) -> map, x, y | nil
参数:aIndex。返回:3 个值 map, x, y;如果角色在本次登录期间一次都没有死亡,则返回 nil。简称:GetObjectDeathMap、GetObjectDeathMapX、GetObjectDeathMapY(没有时返回 -1)。
local map, x, y = Player.GetDeathLocation(aIndex)
if map then Player.MoveTo(aIndex, map, x, y) end
Player.GetAccumulatedDamage
按照 GameServer 的计数器返回角色的累计伤害。
Player.GetAccumulatedDamage(aIndex) -> number
参数:aIndex。返回:累计值;无效时返回 0。
该计数器仅在玩家(或其 Dark Spirit)在攻城战中攻击雕像 / 城门,且没有 Potion of Bless / Potion of Soul 增益时才会增加。每当超过 100,GameServer 就会在攻城战中降低武器耐久度,然后将计数器重置为 0;角色数据被重置(进入 / 退出游戏)时,计数器也会归 0。
local dmg = Player.GetAccumulatedDamage(aIndex)
Player.GetTradeZen
返回角色放在交易窗口中的 zen 数量。
Player.GetTradeZen(aIndex) -> integer
参数:aIndex。返回:交易中的 zen 数量;未交易或无效时返回 0。
local z = Player.GetTradeZen(aIndex)
Player.GetMuteTime
返回禁言指令剩余的秒数。
Player.GetMuteTime(aIndex) -> integer
参数:aIndex。返回:剩余秒数;未被禁言或无效时返回 0。
if Player.GetMuteTime(aIndex) > 0 then Message.Send(aIndex, 1, "您正处于禁言状态") end
Player.IsActionBlocked
检查角色的某个动作当前是否被 Player.BlockAction 阻止。
Player.IsActionBlocked(aIndex, action) -> boolean
| 参数 | 类型 | 说明 |
|---|---|---|
aIndex | integer | 角色索引 |
action | integer | 动作代码,即 System\Constants.lua 中的 ACTION_* 常量(0 到 26) |
返回:动作被阻止时返回 true;未被阻止或参数错误时返回 false。简称:PermissionCheck(aIndex, perm)(参见 Player.BlockAction)。
if Player.IsActionBlocked(aIndex, ACTION_TRADE) then ... end