mzgr 8 Posted August 17, 2022 I want a object (NPCpilot1) to hide when a vehicle (heliB) is destroyed (or damaged) and the same object (NPCpilot1) to show again when the vehicle (heliB) respawns (or gets repaired). Tried with triggers and condition of presence (alive heliB) but couldn't get it to work. I am in a need of a method that would work best on a multiplayer server. heliB is a locked Huron that just sits on a pad. heliB respawn module has this in init to keep variable name after respawn: `if ( isServer ) then { params[ "_newVeh", "_oldVeh" ]; _name = vehicleVarName _oldVeh; _newVeh setVehicleVarName _name; missionNamespace setVariable [ _name, _newVeh, true ]; };` Share this post Link to post Share on other sites
Joe98 92 Posted August 17, 2022 To hide an object, named for example box1, the command is hideobject box1 I don't know how to unhide an object. Neither "show" nor "unhide" appear in the scripting commands. I am sure there is a way. Share this post Link to post Share on other sites
Harzach 2518 Posted August 18, 2022 2 hours ago, Joe98 said: I don't know If you read the Biki entry for hideObject you will see that the alternate syntax allows one to "unhide" an object. _obj hideObject true; // hide object _obj hideObject false; // unhide object 10 hours ago, mzgr said: I want Untested, but the basic idea: if ( isServer ) then { params[ "_newVeh", "_oldVeh" ]; NPCPilot hideObjectGlobal false; // unhides unit when heli respawns _newVeh addEventHandler ["Killed", { params ["_unit", "_killer", "_instigator", "_useEffects"]; NPCPilot1 hideObjectGlobal true; // hides unit when heli is "killed" }]; }; If you need the heli's varName for another reason, you can still run your original code in the "then" scope. You could also use hideObject and then remoteExec it, but the above should work. As always, see the first line of my signature. 1 Share this post Link to post Share on other sites
Joe98 92 Posted August 18, 2022 If you read the Biki entry for hideObject you will see that the alternate syntax allows one to "unhide" an object. _obj hideObject true; // hide object _obj hideObject false; // unhide object If the object is named box1 how would you write the code? Share this post Link to post Share on other sites
Harzach 2518 Posted August 18, 2022 35 minutes ago, Joe98 said: how Quote Syntax: object hideObject hidden object is the object to be hidden hideObject is the command hidden is the boolean (true or false) In my example, "_obj" is just a placeholder. I used a local variable (that's what the leading underscore means, see https://community.bistudio.com/wiki/Variables) because sometimes abstractions are better suited to communicating basic concepts. Share this post Link to post Share on other sites
Joe98 92 Posted August 18, 2022 Quote I do not understand a word of that. Therefore, is this the right code? __box1 hideObject true; And what in the world is the underscore for? Share this post Link to post Share on other sites
Harzach 2518 Posted August 18, 2022 2 hours ago, Harzach said: object is the object to be hidden box1 is your object. box1 hideObject true; 25 minutes ago, Joe98 said: And what in the world is the underscore for? In this case, "box1" is what is called a variable. I provided a link that describes variables in detail above. There are two basic types of variables - global and local. A global variable, once defined, exists for all scripts that run on the machine where it was created, and on any machine to which it has been shared. Your "box1" is a global variable. A local variable, once defined, exists only in the script and scope (and hence machine) where it was created. A local variable is denoted by a single leading underscore. "_box1" would be a local variable. You've been here longer than I have. I knew literally nothing when I joined in 2012. You should take your own advice and start simple - learn a basic concept, try it in various situations to see how it works, then learn another, then combine the two, etc. Before long, you are scripting. 1 Share this post Link to post Share on other sites
Joe98 92 Posted August 18, 2022 To are helping to make my point. If I use the underscore, then it will only run on my computer. If I upload the mission, nobody else can play it. If I don't use the underscore, the I can upload the map and anybody can play it on their computer. And yet above you gave 2 examples and you chose to include the underscore. Anybody who follows your example, and uploads the mission, will have a failure and then leave the forum and the game in frustration. Share this post Link to post Share on other sites
Harzach 2518 Posted August 18, 2022 5 minutes ago, Joe98 said: To are helping to make my point. If I use the underscore, then it will only run on my computer. If I upload the mission, nobody else can play it. If I don't use the underscore, the I can upload the map and anybody can play it on their computer. And yet above you gave 2 examples and you chose to include the underscore. Anybody who follows your example, and uploads the mission, will have a failure and then leave the forum and the game in frustration. You do not understand variables. If you use them correctly, then your scripts will work. 2 Share this post Link to post Share on other sites
pierremgi 4906 Posted August 18, 2022 1 hour ago, Harzach said: You do not understand variables. If you use them correctly, then your scripts will work. Extraordinary patient! Congrats. 1 Share this post Link to post Share on other sites