Robustcolor 30 Posted January 10, 2020 Hi, if i create a vehicle through a function and add a addaction command from it, will it be available for all players on a dedicated? is it possible to limit the addaction for only driver? also, is it possible to use selectrandom or similiar command to randomise which music will be played? music_one, music_two etc is defined in cfgSounds. private _veh = createVehicle [selectRandom ["O_G_Offroad_01_armed_F","I_C_Offroad_02_LMG_F"], _pos, [], 0, "NONE"]; _veh setVehicleVarName "Music"; Music = _veh; _veh addAction ["Music on",{ [Music,["music_one",2000,1]] remoteExec ["say3D"]; }]; Share this post Link to post Share on other sites
7erra 629 Posted January 10, 2020 17 minutes ago, Robustcolor said: _veh addAction ["Music on",{ [Music,["music_one",2000,1]] remoteExec ["say3D"]; }]; This will only add the action on the machine (server or ONE client) that executes the script. Visibility will depend on how you call the script. There are some symbols on the BIKI page that tell you about the MP compability of the command. In case of addAction: - Arguments Global: _veh object can be local to another machine and still be used - Effects Local: Action is only visible on the machine that executes the command Therefore remoteExecution is required: [_veh, ["Music on",{ [_veh, [selectRandom ["music_one","music_two"],2000,1]] remoteExec ["say3D"]; },[],1.5,true,true,"","driver _target == _this"]] remoteExec ["addAction", 0, _veh]; selectRandom should work. By the way: 31 minutes ago, Robustcolor said: private _veh = createVehicle [selectRandom ["O_G_Offroad_01_armed_F","I_C_Offroad_02_LMG_F"], _pos, [], 0, "NONE"]; _veh setVehicleVarName "Music"; Music = _veh; No need to create a private local variable when you want to make it global anyway. setVehicleVarname is only an identifier and has no effect in scripts. veh_music = createVehicle [selectRandom ["O_G_Offroad_01_armed_F","I_C_Offroad_02_LMG_F"], _pos, [], 0, "NONE"]; 1 Share this post Link to post Share on other sites
Robustcolor 30 Posted January 11, 2020 Thanks @7erra, worked with global variable. With local variable it causes an undefined variable with _veh when called. Is it possible to use it with local var? If i create several vehicles from the same functions and want each vehicle to play music. [veh, ["<t color ='#ffcc00'>Radio on</t>",{ [veh, [selectRandom ["music_one","music_two","music_three","music_four","music_five","music_six","music_seven"],2000,1]] remoteExec ["say3D"]; },[],1.5,true,true,"","driver _target == _this"]] remoteExec ["addAction", 0, veh]; Share this post Link to post Share on other sites
7erra 629 Posted January 11, 2020 [_veh, ["<t color ='#ffcc00'>Radio on</t>",{ params ["_target", "_caller", "_actionId", "_arguments"]; [_target, [selectRandom ["music_one","music_two","music_three","music_four","music_five","music_six","music_seven"],2000,1]] remoteExec ["say3D"]; },[],1.5,true,true,"","driver _target == _this"]] remoteExec ["addAction", 0, _veh]; The addaction script runs in another instance (scope? Don't know the correct term) of the script. No local variables from your script will be usable there. Instead we can use the arguments passed to the function where the first parameter references the object the action is attached to, the _veh. Share this post Link to post Share on other sites
Robustcolor 30 Posted January 11, 2020 Thank you for explaining and for the help @7erra Share this post Link to post Share on other sites