SetPVarFloat
描述
设置浮点型玩家变量的值。
名称 | 说明 |
---|---|
playerid | 要设置变量的玩家 ID |
const pvar[] | 变量名称 |
Float:value | 要存储的浮点数值 |
返回值
true - 函数执行成功。
false - 函数执行失败。玩家未连接或变量名为空/超过 40 字符。
示例
SavePlayerPos(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z); // 获取玩家位置
SetPVarFloat(playerid, "Xpos", x); // 将浮点数存入玩家变量
SetPVarFloat(playerid, "Ypos", y); // 将浮点数存入玩家变量
SetPVarFloat(playerid, "Zpos", z); // 将浮点数存入玩家变量
return 1;
}
注意
提示
变量在OnPlayerDisconnect回调后才会重置,因此在断开连接时仍可访问。
相关函数
- SetPVarInt: 设置整型玩家变量
- GetPVarInt: 获取整型玩家变量值
- SetPVarString: 设置字符串型玩家变量
- GetPVarString: 获取字符串型玩家变量值
- GetPVarFloat: 获取浮点型玩家变量值
- DeletePVar: 删除玩家变量