跳到主要内容

CreatePlayer3DTextLabel

描述

创建仅对特定玩家可见的 3D 文本标签,支持实体绑定和视线检测功能。

参数名说明
playerid可见该标签的目标玩家 ID
const text[]显示文本内容(支持格式符)
colour颜色值(使用整数或 RGBA 十六进制格式)
Float:xX 轴坐标(若绑定实体则为偏移量)
Float:yY 轴坐标(若绑定实体则为偏移量)
Float:zZ 轴坐标(若绑定实体则为偏移量)
Float:drawDistance可视距离(单位:游戏单位)
attachedplayer绑定玩家实体 ID(不绑定填 INVALID_PLAYER_ID)
attachedvehicle绑定车辆实体 ID(不绑定填 INVALID_VEHICLE_ID)
bool:testLOS视线检测开关(true=穿透物体不可见,false=可穿透显示)
OPEN_MP_TAGS:...扩展参数(支持任意类型参数)

返回值

成功返回私有 3D 文本标签 ID,达到玩家标签上限(MAX_3DTEXT_PLAYER)时返回 INVALID_3DTEXT_ID。

应用示例

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/playerlabel", true))
{
new
PlayerText3D:playerTextId,
name[MAX_PLAYER_NAME],
Float:x, Float:y, Float:z,
string[64];

GetPlayerName(playerid, name, sizeof(name));
GetPlayerPos(playerid, x, y, z);

// 创建带玩家名的动态标签
format(string, sizeof(string), "你好 %s!\n我在你的当前位置", name);
playerTextId = CreatePlayer3DTextLabel(playerid, string, 0x008080FF, x, y, z, 40.0);
return 1;
}
return 0;
}

注意事项

提示

观察模式下有效显示距离会显著缩短

注意

空文本可能导致客户端崩溃(open.mp 版本已修复此问题)

关联函数