BEAKSBY 11 Posted September 4, 2014 Hi all, I can't setVehicleAmmo on remote vechicles. Kju mentions this here https://community.bistudio.com/wiki/setVehicleAmmo. How can i get this to work on remote vehicles and not just those created local to the player? Share this post Link to post Share on other sites
dreadedentity 278 Posted September 4, 2014 What exactly are you trying to do? I think you'll just have to write a script and attach it to each vehicle to execute it locally. Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted September 4, 2014 (edited) You could try this: if(cursorTarget isKindOf "Car") then {[cursorTarget, {_this setVehicleAmmo 1;}, owner cursorTarget, false, true] spawn BIS_fnc_MP;}; //where cursorTarget is the car you are aiming at But as I don't know whether the "owner" command works in this case, I agree with DreadedEntity as it depends on the actual scenario. Maybe, you could also be interested in the setAmmo command. The vehicle has to be local to your client, but the result of this command will be broadcast through the network. Edited September 4, 2014 by waltenberg Share this post Link to post Share on other sites
BEAKSBY 11 Posted September 4, 2014 Could I use https://community.bistudio.com/wiki/setOwner and switch the ownership and thus switch locality to the owner's side, then use setVehicleAmmo, and switch it back to the original owner? Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted September 4, 2014 (edited) No, because as the related BIKI article says, setOwner can only be executed on the server. Edited September 4, 2014 by waltenberg Share this post Link to post Share on other sites
BEAKSBY 11 Posted September 4, 2014 You could try this:Maybe, you could also be interested in the setAmmo command. The vehicle has to be local to your client, but the result of this command will be broadcast through the network. ...but this is the problem. I would like the argument to be global (not local to the client) just like https://community.bistudio.com/wiki/setDamage but a for setVehicleAmmo. Does setVehicleAmmoDef have global arguments? Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted September 4, 2014 Can't tell as my No. 1 source is the BIKI as well. :j: But why don't you simply create global vehicles only. If you don't explicitly use "createVehicleLocal", your vehicle is global and you don't have to worry about this whole issue. Share this post Link to post Share on other sites
dreadedentity 278 Posted September 4, 2014 I would like the argument to be global Not sure what you mean Share this post Link to post Share on other sites
das attorney 858 Posted September 4, 2014 Try this: SVAGLOBAL = { if (local (_this select 0)) then { (_this select 0) setVehicleAmmo (_this select 1); } else { [_this,"SVAGLOBAL",_this select 0,FALSE] call BIS_fnc_MP; }; }; // use: [VEHICLENAME,1] call SVAGLOBAL; Share this post Link to post Share on other sites
BEAKSBY 11 Posted September 5, 2014 Thanks Das, this works!...even though I don't fully understand all of it. Does _this in [_this,"SVAGLOBAL",_this select 0,FALSE] call BIS_fnc_MP;...mean the entire function "SVAGLOBAL"? Share this post Link to post Share on other sites
das attorney 858 Posted September 5, 2014 "_this" is the arguments ( which are in the format [VEHICLENAME,1]) Basically this is a recursive function. Recursion is quite cool like in art and acronyms: http://upload.wikimedia.org/wikipedia/commons/b/b3/Screenshot_Recursion_via_vlc.png http://en.wikipedia.org/wiki/Recursive_acronym The function checks if the unit is local and sets the ammo. If it isn't local, it executes the function again where it is local via bis_fnc_mp. Hope that helps. Share this post Link to post Share on other sites
BEAKSBY 11 Posted September 5, 2014 It does, thanks! Handy little script for "simulating" a local object thant can have multiple uses. Thanks again. Share this post Link to post Share on other sites