跳到主要内容

SetPVarInt

描述

设置一个整数类型的玩家变量。

参数名说明
playerid需要设置变量的玩家 ID
const pvar[]变量名称(需用双引号包裹)
value要存储的整数值

返回值

true - 函数执行成功

false - 函数执行失败(玩家未连接或变量名为空/超过 40 字符)

示例代码

// 将玩家当前金钱存储到名为"Money"的变量
SetPVarInt(playerid, "Money", GetPlayerMoney(playerid));

// 打印玩家存储的金钱数值
printf("当前金钱: %d", GetPVarInt(playerid, "Money"));

注意事项

提示

玩家变量在OnPlayerDisconnect回调触发前不会被重置,因此在该回调中仍可访问变量值。

相关函数