Bnae 1427 Posted March 8, 2016 Hi, Again i faced a problem that i cannot solve. Short example made for this problem missionNamespace setVariable ["call_count",0,true]; fn_call = { if (call_count < 1) then { missionNamespace setVariable ["call_count",(call_count + 1),true]; createVeh = "B_MRAP_01_F" createVehicle getMarkerPos "postionMarker"; }else{ deleteVehicle createVeh; } } Function is called from init.sqf [] call compile preprocessFileLineNumbers "fn_called.sqf"; So when first player call that with "call fn_call" it will create a vehicle and on the second call it will remove the vehicle. But if the first player only creates the vehicle and second player tries to remove it will be not removed. So how do i define that createVeh? Share this post Link to post Share on other sites
pedeathtrian 98 Posted March 8, 2016 Because you don't publish the createVeh variable. It stays local to machine where vehicle was created. Either use publicVariable or set it to missionNamespace too, same as "call_count", with 3rd argument set to true. Share this post Link to post Share on other sites
sarogahtyp 617 Posted March 8, 2016 (edited) deleteVehicle paramters need to be local to get it work.there r some possibilities:1. If player A spawns it then player A should delete it2. if player A spawns it u can change the locality with setOwner (must called by server) to the one who should delete it (could be the server,too)3. You can remotely execute the deleteVehicle command at that players machine which has spawned it. That was bullsh.. see next post. Edited March 8, 2016 by sarogahtyp Share this post Link to post Share on other sites
pedeathtrian 98 Posted March 8, 2016 deleteVehicle paramters need to be local to get it work. there r some possibilities: 1. If player A spawns it then player A should delete it 2. if player A spawns it u can change the locality with setOwner (must called by server) to the one who should delete it (could be the server,too) 3. You can remotely execute the deleteVehicle command at that players machine which has spawned it. Check this out: deleteVehicle. The command is aG/eG. It does not require arguments to be local. When I said variable stays local I didn't mean the multiplayer locality, I meant that variable itself was defined only on that machine. On other machines it will be undefined until transmitted. Other machines simply do not know the value of variable. Share this post Link to post Share on other sites
Bnae 1427 Posted March 8, 2016 Thanks both of you. I think setOwner >> setGroupOwner is the thing i'm looking for. Now i'll just figure how that works and hope for the best. Again, thanks! Edit, Yeah, i know it's not defined. So in this case only the computer that called the function knows the variable creteVeh. Please share all the ideas that comes to your mind and maybe we can find the best solution. Share this post Link to post Share on other sites
pedeathtrian 98 Posted March 8, 2016 missionNamespace setVariable ["call_count",0,true]; fn_call = { if (call_count < 1) then { missionNamespace setVariable ["call_count",(call_count + 1),true]; createVeh = "B_MRAP_01_F" createVehicle getMarkerPos "postionMarker"; publicVariable "createVeh"; }else{ deleteVehicle createVeh; createVeh = objNull; publicVariable "createVeh"; } }; or missionNamespace setVariable ["call_count",0,true]; fn_call = { if (call_count < 1) then { missionNamespace setVariable ["call_count",(call_count + 1),true]; missionNamespace setVariable ["createVeh","B_MRAP_01_F" createVehicle getMarkerPos "postionMarker",true]; }else{ deleteVehicle createVeh; missionNamespace setVariable ["createVeh",objNull,true]; } }; 1 Share this post Link to post Share on other sites
Bnae 1427 Posted March 8, 2016 or missionNamespace setVariable ["call_count",0,true]; fn_call = { if (call_count < 1) then { missionNamespace setVariable ["call_count",(call_count + 1),true]; missionNamespace setVariable ["createVeh","B_MRAP_01_F" createVehicle getMarkerPos "postionMarker",true]; }else{ deleteVehicle createVeh; missionNamespace setVariable ["createVeh",objNull,true]; } }; Thank you pedeathtrian. Share this post Link to post Share on other sites
Larrow 2155 Posted March 8, 2016 missionNamespace setVariable ["call_count",0,true]; fn_call = { if (call_count < 1) then { missionNamespace setVariable ["call_count",(call_count + 1),true]; createVeh = "B_MRAP_01_F" createVehicle getMarkerPos "postionMarker"; publicVariable "createVeh"; }else{ deleteVehicle createVeh; createVeh = objNull; publicVariable "createVeh"; } }; or missionNamespace setVariable ["call_count",0,true]; fn_call = { if (call_count < 1) then { missionNamespace setVariable ["call_count",(call_count + 1),true]; missionNamespace setVariable ["createVeh","B_MRAP_01_F" createVehicle getMarkerPos "postionMarker",true]; }else{ deleteVehicle createVeh; missionNamespace setVariable ["createVeh",objNull,true]; } }; But if you ever want to create another vehicle it wont work as call_count is never reset when you delete the vehicle.Just use the one variable fn_call = { if ( isNil "createVeh" ) then { missionNamespace setVariable ["createVeh","B_MRAP_01_F" createVehicle getMarkerPos "postionMarker",true]; }else{ deleteVehicle createVeh; missionNamespace setVariable ["createVeh",nil,true]; } }; Share this post Link to post Share on other sites
Bnae 1427 Posted March 8, 2016 But if you ever want to create another vehicle it wont work as call_count is never reset when you delete the vehicle. Just use the one variable fn_call = { if ( isNil "createVeh" ) then { missionNamespace setVariable ["createVeh","B_MRAP_01_F" createVehicle getMarkerPos "postionMarker",true]; }else{ deleteVehicle createVeh; missionNamespace setVariable ["createVeh",nil,true]; } }; Thanks for noticing that, but this was example that i made. It was not supposed to be used in any purpose. Share this post Link to post Share on other sites
barbolani 189 Posted March 8, 2016 missionNamespace setVariable ["createVeh","B_MRAP_01_F" createVehicle getMarkerPos "postionMarker",true]; ? missionNamespace setVariable ["createVeh","B_MRAP_01_F" createVehicle getMarkerPos "postionMarker",true]; ???? Never thought you can put commands in the space of the variable instead of the value of the variable in setVariable command. Everytime I read Larrow's posts I learn something about coding. I wish I find a Larrow for flirting with girls. I would be George Clooney with Nespresso. Share this post Link to post Share on other sites