脚本进阶教程 位置导航:首页 > 资料中心 > 脚本进阶教程
   API说明—人物属性

● 取得触发脚本的用户的id 
● 获得指定用户的所有自定义属性名和属性值 
● 获得指定用户指定自定义属性名称的自定义属性值 
● 获得指定用户的用户名 
● 获得触发脚本的用户的朝向 
● 获得指定用户的朝向 
● 获得触发脚本的用户的坐标 
● 获得指定用户的坐标 
● 获得指定物体的所有者id 
● 获得指定用户的速率 
● 获得触发脚本的用户的速率 
● 获得指定用户的速度方向 
● 获得触发脚本用户的速率方向 
● 获得指定位置土地所有者 
● 获得指定用户角色名的角色id 
● 检查用户所在土地是否为脚本所有者土地 
● 检查用户身上是否有指定物体 
● 获得指定用户当前选定的目标id 
● 获得指定用户当前选定的目标类型 

取得触发脚本的用户的id
函数:

string uGetToucherId();

返回值:
触发脚本的用户的id。

Eg:
local Playerid= uGetToucherId(); 
uPrintf(Playerid);
--获得触发脚本的用户的id,然后输出。

获得指定用户的所有自定义属性名和属性值
函数:
table uGetPlayerDefine(playerId);

参数:
playerId:字符串,指定用户的Id。当playerId不填时,默认为触发脚本用户。

返回值:
自定义属性。为一个表: {num; name{} ; value{} }。如果将返回值赋给变量User,User= uGetPlayerDefine(playerId);则User.num为自定义属性数量,User.name[num-1]为第num个属性名,User.value[num-1]为第num个属性值。

Eg:
User=uGetPlayerDefine();
uPrintf(User.num.. User. name[0].. User.value [0]);
--获得触发脚本的用户的自定义属性数量、第一个自定义属性名、第一个自定义属性值,然后输出。

获得指定用户指定自定义属性名称的自定义属性值
函数:
string uGetPlayerDefineValue(defineName,playerId);

参数:
(1) defineName:字符串,自定义属性名称。
(2) playerId:字符串,指定用户的Id。

返回值:
自定义属性值。

备注:
如用户或自定义属性值不存在,或超出脚本api作用范围时,返回值为一个空的字符串:""。

Eg:
Value= uGetPlayerDefineValue("ab", uGetToucherId());
uPrintf(Value);
--获得触发脚本的用户的自定义属性名为“ab”的自定义属性值,然后输出。

获得指定用户的用户名
函数:
string uGetPlayerName(playerId)

参数:
playerId:字符串,指定用户的Id。

返回值:
用户名。

备注:
如用户不存在,或超出脚本api作用范围时,返回值为一个空的字符串:""。

Eg:
name = uGetPlayerName(uGetToucherId());
uPrintf(name);
--获得触发脚本的用户的用户名,然后输出。

获得触发脚本的用户的朝向
函数:
float uGetOperatorOrient();

返回值:
指定用户的朝向角度,从0到360,注意360时显示为0,单位:度。

Eg:
orient = uGetOperatorOrient();
uPrintf(orient);
--获得触发脚本的用户的朝向,然后输出。

获得指定用户的朝向
函数:
float uGetPlayerOrient(playerId);

参数:
playerId:字符串,指定用户的Id。

返回值:
指定用户的朝向角度,从0到360,注意360时显示为0,单位:度。

备注:
如用户不存在,或超出脚本api作用范围时,返回值为0。

Eg:
orient = uGetPlayerOrient(uGetToucherId());
uPrintf(orient);
--获得触发脚本的用户的朝向,然后输出。

获得触发脚本的用户的坐标
函数:
G3D::Vector3 uGetOperatorPos();

返回值:
触发脚本的用户的坐标,为一个三维向量。

Eg:
pos = uGetOperatorPos();
uPrintf(pos.x..pos.y..pos.z);
--获得触发脚本的用户的坐标,然后将坐标以xyz的形式输出。

获得指定用户的坐标
函数:
G3D::Vector3 uGetPlayerPos(playerId);

参数:
playerId:字符串,指定用户的Id。

返回值:
指定用户的位置,为一个三维向量。

备注:
如用户不存在,或超出脚本api作用范围时,返回值为(0,0,0)。

Eg:
pos = uGetPlayerPos (uGetToucherId());
uPrintf(pos.x..pos.y..pos.z);
--获得触发脚本的用户的位置,然后以xyz的形式输出。

获得指定物体的所有者id
函数:
string uGetItemOwnerId(itemId);

参数:
itemId:字符串,指定物体的Id。

返回值:
所有者的id。

备注:
如物体不存在,或超出脚本api作用范围时,返回值为一个空的字符串:""。

Eg:
(1) ID= uGetItemOwnerId (uGetItemId());
uPrintf(ID);
--获得绑定该脚本的物体的所有者ID,然后输出。

获得指定用户的速率
函数:
float uGetPlayerSpeed(playerId, type);

参数:
(1) playerid:字符串,指定用户的Id。
(2) type:整型,速度类型,详见5.3移动类型

返回值:
指定用户的速率,单位:米/秒。

备注:
如用户不存在,或超出脚本api作用范围时,返回值为0。

Eg:
local speed = uGetPlayerSpeed(uGetToucherId(),PLAYER_RUN);
uPrintf(speed);
--获得触发脚本的用户的跑步速率,然后输出。

获得触发脚本的用户的速率
函数:
float uGetOperatorSpeed(type);

参数:
type:整型,速度类型,详见5.3移动类型

返回值:
触发脚本的用户的速率,单位:米/秒。

Eg:
local speed = uGetOperatorSpeed(PLAYER_RUN);
uPrintf(speed);
--获得触发脚本的用户的跑步速率,然后输出。

获得指定用户的速度方向
函数:
float uGetPlayerSpeedOrient(playerId);

参数:
playerid:字符串,指定用户的Id。

返回值:
指定用户的速度方向,从0到360,注意360时显示为0,单位:度。

备注:
如用户不存在,或超出脚本api作用范围时,返回值为0。

Eg:
local orient = uGetPlayerSpeedOrient(uGetToucherId());
uPrintf(orient);
--获得触发脚本的用户的速度方向,然后输出。

获得触发脚本用户的速率方向
函数:
float uGetOperatorSpeedOrient();

返回值:
触发脚本的用户的速度方向,从0到360,注意360时显示为0,单位:度。

Eg:
local orient = uGetOperatorSpeedOrient();
uPrintf(orient);
--获得触发脚本的用户的速度方向,然后输出。

获得指定位置土地所有者
函数:
string uGetLandOwnerId(G3D::Vector3 pos);

参数:
pos:三维向量,指定坐标。

返回值:
土地所有者id。

备注:
如该土地没有所有者或所有者为系统,或超出脚本api作用范围时,返回值为一个空字符串""。

Eg:
local pos = G3D.Vector3:new(250,0,250);
local id = uGetLandOwnerId(pos);
uPrintf(id);
--获得位置为(250,0,250)的土地的所有者id,然后输出。

获得指定用户角色名的角色id
函数:
string uGetPlayerIdByRoleName(roleName);

参数:
roleName:字符串,用户名称。

返回值:
用户id。

备注:
如用户名不存在,或目标用户超出脚本api作用范围时,返回值为一个空字符串”“。

Eg:
local roleName = uGetPlayerIdByRoleName("nailo");
uPrintf(roleName);
--获得用户名为nailo的用户id,然后输出。

检查用户所在土地是否为脚本所有者土地
函数:
int uCheckPlayerPos(playerId);

参数:
playerId:字符串,用户id。

返回值:
0或1,0为用户所在土地不为脚本所有者土地,1为是。

备注:
如用户不存在,或目标用户超出脚本api作用范围时,返回值为0。

Eg:
local result = uCheckPlayerPos(uGetToucherId());
uPrintf(result);
--检查脚本触发者所在土地是否为脚本拥有者土地,然后输出结果。

检查用户身上是否有指定物体
函数:
int uCheckPlayerItem(itemId,playerId);

参数:
(1) itemId:字符串,物体id。
(2) playerId:字符串,用户id。

返回值:
0或3,3为用户背包或已装备物体中不包含指定物体,0为包含。

备注:
如用户或物体不存在,或目标用户或物体超出脚本api作用范围时,返回值为0。

Eg:
local result = uCheckPlayerItem("2251799818210561",uGetToucherId());
uPrintf(result);
--检查脚本触发者背包或已装备物体中是否有id为"2251799818210561"的物体,然后输出结果。

获得指定用户当前选定的目标id
函数:
string uGetPlayerTargetId(playerId);

参数:
playerId:字符串,用户id。如此参数不填,则默认playerid为触发脚本的用户id。

返回值:
目标的id。

备注:
如用户不存在,或目标用户超出脚本api作用范围,或目标用户未选中目标时,返回值为0。

Eg:
(1) local result = uGetPlayerTargetId (uGetToucherId());
uPrintf(result);
--获得脚本触发者当前选定的目标id。
(2) local result = uGetPlayerTargetId();
uPrintf(result);
--获得脚本触发者当前选定的目标id。

获得指定用户当前选定的目标类型
函数:
string uGetPlayerTargetType(playerId);

参数:
playerId:字符串,用户id。如此参数不填,则默认playerid为触发脚本的用户id。

返回值:
目标类型,详见5.2对象类型。

备注:
如用户不存在,或目标用户超出脚本api作用范围,或目标用户未选中目标时,返回值为0。

Eg:
(1) local result = uGetPlayerTargetType(uGetToucherId());
uPrintf(result);
--获得脚本触发者当前选定的目标类型。
(2) local result = uGetPlayerTargetType();
uPrintf(result);
--获得脚本触发者当前选定的目标id。

.
公司介绍  |  由我博客  |  招聘信息  |  商务合作 |  媒体合作  |  联系我们  |  新浪微博  |  开心多尼
优万科技(北京)有限公司 版权所有 京ICP证08336号 ISBN 978-7-900648-32-7 《网络文化经营许可证》编号:文网文[2009]076号 新出网证(京)字099号
Copyright (C)2007-2010 UOneNet CO., LTD. All Rights Reserved.