setCaptive – Talk

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:
Simple test: In the player unit's init line type '''if (!isServer) then {this setCaptive true;};''' and enemies will still shoot at you on a dedicated server even though you are the unit and thus it should be local to you when the command is run on your machine. So either my test is messed up or the above is incorrect.
Simple test: In the player unit's init line type '''if (!isServer) then {this setCaptive true;};''' and enemies will still shoot at you on a dedicated server even though you are the unit and thus it should be local to you when the command is run on your machine. So either my test is messed up or the above is incorrect.
Then again When I ran the commands only on the server, I couldn't tell my friendly AI to engage the enemy even though he was only set to captive on the server. So what gives?
Then again When I ran the commands only on the server, I couldn't tell my friendly AI to engage the enemy even though he was only set to captive on the server. So what gives?
:The problem of your test is that the locality is a little special at missionstart (at that time the init lines are evaluated): All units are local to the server at the very beginning (time = 0) - you can easily check this by adding a '''diag_log (local this)''' to the init line of the player. In the .rpt file of the server you'll get a '''true''', at the client a '''false''' - later (time > 0) it's the other way round.
:So better use '''if (local this) then {this setCaptive true;};''' as test (in the init line). --[[User:Master85|Master85]] 20:22, 24 August 2010 (CEST)

Revision as of 19:22, 24 August 2010

Where do you need to execute this command in multiplayer? Where the unit is local or on all machines (or something else)?

Command should be executed where the unit is local. --Master85 00:06, 11 April 2010 (CEST)

Simple test: In the player unit's init line type if (!isServer) then {this setCaptive true;}; and enemies will still shoot at you on a dedicated server even though you are the unit and thus it should be local to you when the command is run on your machine. So either my test is messed up or the above is incorrect. Then again When I ran the commands only on the server, I couldn't tell my friendly AI to engage the enemy even though he was only set to captive on the server. So what gives?

The problem of your test is that the locality is a little special at missionstart (at that time the init lines are evaluated): All units are local to the server at the very beginning (time = 0) - you can easily check this by adding a diag_log (local this) to the init line of the player. In the .rpt file of the server you'll get a true, at the client a false - later (time > 0) it's the other way round.
So better use if (local this) then {this setCaptive true;}; as test (in the init line). --Master85 20:22, 24 August 2010 (CEST)