Jump to content
Sign in to follow this  
BEAKSBY

How to setVehicleAmmo to remote vehicles

Recommended Posts

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

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 by waltenberg

Share this post


Link to post
Share on other sites
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

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

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

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

"_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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×