Fandom

武装突袭 Wiki

AddPublicVariableEventHandler

简体 | 繁體

4,827个页面创建
于此维基上
添加新页面
评论0 分享

您使用了广告屏蔽软件!


Wikia通过广告运营为用户提供免费的服务。我们对用户通过嵌入广告屏蔽软件访问网站进行了使用调整。

如果您使用了广告屏蔽软件,将无法使用我们的服务。请您移除广告屏蔽软件,以确保页面正常加载。

  Arguments of this scripting command don't have to be local to the client the command is executed onEffects of this scripting command are not broadcasted over the network and remain local to the client the command is executed on

点击图片可看到更多讯息

开始使用于

游戏:
Armed Assault
版本:
1.09

描述

描述:
This event handler will detect if a missionNamespace variable (it is attached to) has been broadcast over network with publicVariable, publicVariableClient or publicVariableServer commands and will execute EH code upon detection. Arguments passed to the code in _this array are:

_this select 0: String - broadcast variable name (same variable name EH is attached to)
_this select 1: Anything - broadcast variable value

Please note:
* EH works only in Multiplayer environment.
* EH will not fire on the machine that executed broadcast command, only on the machines that receive the broadcast.
* The value of broadcast variable can be exactly the same, it is the actual broadcast that triggers EH not the change in variable.

20px Alt syntax of this command doesn't work as intended

基本句法

句法:
varName addPublicVariableEventHandler code
参数:
varName: String - missionNamespace variable name

code: Code - By default, the code is executed in missionNamespace
返回值:
Nothing

替代句法

句法:
varName addPublicVariableEventHandler [target, code] (since A3 1.46)
参数:
varName: String - name of the variable set on target with setVariable

[target, code]: Array

target: Object, Group or Team Member

code: Code
返回值:
Nothing

范例

范例1:
"publicThis" addPublicVariableEventHandler { hint format [ "%1 has been updated to: %2", _this select 0, _this select 1 ] };

范例2:
Client:"'^:)123BURP,+=lol" addPublicVariableEventHandler {hint ("NUTS are " + (_this select 1))}; Server:missionNamespace setVariable ["'^:)123BURP,+=lol", "craZZZZy"]; publicVariable "'^:)123BURP,+=lol";

额外资讯

多人游戏:
-
也可以看看:

publicVariablepublicVariableClientpublicVariableServer

注意事项

此处撰写句法皆为可行用法. 可到官网[1]专页回报错误. 你可以使用讨论页面或是论坛来进行讨论.
新增注意事项 | 如何新增?

Notes

Posted on 22 Dec, 2007
TeRp
Please note that varName indicates which variable you want to monitor with this eventhandler.
As a result, the example eventhandler on this page will only fire when the variable publicThis has been changed, but not if any other variable was changed by any other client via the publicVariable command.

Posted on 27 Feb, 2014 00:57
MulleDK13
Note on using addPublicVariableEventHandler during initialization: If you need a function to call addPublicVariableEventHandler during initialization, you must use postInit. addPublicVariableEventHandler does not work during preInit.

Posted on 27 Feb, 2014 08:40
Killzone_Kid
MulleDK13 note above needs some clarification. You don't "must" use postInit and you absolutely can use preInit function to initialise addPublicVariableEventHandler if you start scheduled script from it.
//script with preInit = 1; in CfgFunctions 0 = 0 spawn { "someVar" addPublicVariableEventHandler { //yourcode }; };

Bottom Section

Posted on November 23, 2015 - 21:36 (UTC)
SilentSpike
While it is true that the event handler will only fire on the machine receiving the broadcast value. Please note that this machine can actually be the same machine broadcasting it in the cases of publicVariableClient and publicVariableServer.

Examples: if (isServer) then {

   "OnServer" addPublicVariableEventHandler { hint "This event handler still fired!"; };
   publicVariableServer "OnServer";

}; // This example assumes the client knows their own client ID // It does also work on the server (when the server ID is used) irrespective of the command name

"OnClient" addPublicVariableEventHandler { hint "This event handler still fired!"; }; <client ID> publicVariableClient "OnClient";

更多维基

随机维基