简体   繁体   English

if语句中的“无效表达式,假定为零”错误

[英]“Invalid expression, assumed zero” error on if-statement

I'm getting the following error whenever I compile my code: "Error 029: Invalid expression, assumed zero" 每当我编译代码时,我都会收到以下错误: "Error 029: Invalid expression, assumed zero"

The error is thrown on the following line: 错误发生在以下行:

if ((PlayerInfo[playerid][ADMINLevel])) || (IsPlayerAdmin(playerid))

I want the if-statement to check if "ADMINLevel" is above zero or if the player is logged in as an RCON admin. 我希望if语句检查“ADMINLevel”是否高于零或者玩家是否以RCON管理员身份登录。

PlayerInfo[..][..] does not return a boolean. PlayerInfo [..] [..]不返回布尔值。 Add > 0 to fix it 添加> 0以修复它

You're constructing your if-statement wrong. 你正在构造你的if语句错误。 The correct way to do it is 正确的方法是

if(PlayerInfo[playerid][ADMINLevel] > 0 || IsPlayerAdmin(playerid))
{
    /* Put your desired script here */
}

Your code was nearly correct (although it did have some unnecessary brackets), you just need to actually add a comparison to the ADMINLevel check. 您的代码几乎是正确的(虽然它确实有一些不必要的括号),您只需要实际添加一个比较到ADMINLevel检查。 An if-statement should be like a question ("is admin level more than 0", rather than just "is admin level"). if语句应该像一个问题(“管理员级别大于0”,而不仅仅是“管理级别”)。 You can find more information about if-statements in Pawn here , and I think it will be useful for you to read. 你可以在这里找到关于Pawn中if语句的更多信息,我认为这对你有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM