Jump to content
Sign in to follow this  
CombatComm1

setvehicleinit not working/help with new function

Recommended Posts

I am kinda frustrated by this new BIS_callMPfunction or whatever it is called. setvehicleinit was so simple and I really need to addaction to spawned units.

Here is my code just in case it is an error here that is making it not work. I get a "missing ;" in the debugger.

_newSoldier = "Land_Wreck_Car2_F" createVehicle (position player);
_newSoldier setvehicleinit "this addaction ["save","save.sqf"]";

Is this wrong in some way? OR is this not working because it was replaced with that overly complicated function I have absolutely no idea how to use.

Thanks in advance.

Share this post


Link to post
Share on other sites

If you're spawning something you don't need init fields, you're already inside an init field, your function.

_newSoldier = "Land_Wreck_Car2_F" createVehicle (position player);
_newSoldier addaction ["save","save.sqf"]";

Though I'm assuming you're going to want everyone connected to access it? Then you'll need a function to handle adding actions to everyone:

COM_fnc_addAction = {
   private["_object","_script"];
   _object = _this select 0;
   _script = _this select 1;
   _object addAction _script;
};

_newSoldier = createVehicle ["Land_Wreck_Car2_F", (position player), [], 0, ""];
[[_newSoldier, ["Save", '"save.sqf"]], "COM_fnc_addAction", nil, true] spawn BIS_fnc_MP;

Share this post


Link to post
Share on other sites

@kylania

Your func works well... but i have a question :

This is my old code that i used inside a script to give spawned units an important addAction menu:

pilot1 setVehicleInit "this addAction [(""<t color=""""#F8E115"""">"" + (""-> CAS"") + ""</t>""),""pathto.sqf"",(case1),1,false,true,"""",""_this == player""];";

This is my new code with your function :

[[pilot1, ["Text", "file.sqf"]], "COM_fnc_addAction", nil, true] spawn BIS_fnc_MP; 

Now i want to recolor the "Text", how is this possible with BIS_fnc_MP and your function AND how is it possible to use different cases like my code or must i write a single script for every action ??

Thanks for helping...

Share this post


Link to post
Share on other sites

[[pilot1, [(""<t color=""""#F8E115"""">"" + (""-> CAS"") + ""</t>""),""pathto.sqf"",(case1),1,false,true,"""",""_this == player""]], "COM_fnc_addAction", nil, true] spawn BIS_fnc_MP; 

I don't see any reason why this would not work.

Note that Arma 3 now allows you to use code directly into addAction.

I don't know if it's the case here, but you can avoid having to create a new .sqf for every single action.

Share this post


Link to post
Share on other sites

So many "" :) You can interchange ' and " to make things more readable too.

COM_fnc_addAction = {(_this select 0) addAction (_this select 1)};

[[pilot1, ["<t color='#F8E115'> -> CAS</t>","pathto.sqf",(case1),1,false,true,"","_this == player"]], "COM_fnc_addAction", nil, true] spawn BIS_fnc_MP;

Share this post


Link to post
Share on other sites

@ BlackMamb & kylania

thanks for your help, i will try this later this day... :)

yeah, BIS_fnc_MP is a little bit crazy for me... have to think around a corner... :)

thanks for this time... :)

greetz, phantom

Share this post


Link to post
Share on other sites

So since this is about the new function (quite old now), I really didn't want to touch these commands but since they removed setVehicleInit I was wondering on how I could use this script

myVEH = createVehicle ["I_Heli_Transport_02_F", getPos HELI22, [], 0,""];myVEH setDir -48.56111;
["scripts\aw_unitSetup.sqf","BIS_fnc_execVM",false,false] spawn BIS_fnc_MP;

I did a bit of research before hand but every time I spawn this vehicle in and jump into it the AW scripts are not working.

This script is also being used to spawn an empty CH-49 on the ground with that script onboard, I've got it setup as an addaction to a cash register. Also was wondering if its possible to execute more than 1 script

Edited by Lala14

Share this post


Link to post
Share on other sites

That's not really how BIS_fnc_MP works. It's designed to execute local functions on all clients at once. For your example there you wouldn't need it, except maybe inside the aw_unitSetup.sqf if that code does something like adding addActions to the new vehicle. Your scripts aren't working since whatever that aw_unitSetup.sqf thing is has no idea what it's supposed to be working on. It probably could be just the following, but without seeing what that aw script is trying to do it's difficult to tell.

myVEH = createVehicle ["I_Heli_Transport_02_F", getPos HELI22, [], 0,"NONE"];
myVEH setDir -48.56111;
[myVEH] execVM "scripts\aw_unitSetup.sqf";

You generally don't want BIS_fnc_MP to be running scripts. Instead you'd want it to run functions instead with as little input as possible. Like if you wanted to add a static addAction starting a cash register you'd do something like this:

// this is declared in your functions area
LALA_fnc_addCashRegister = {
   _reg = _this select 0;

   _reg addAction ["Cash Register", "cashRegister.sqf"];
};

// To add a cash register to something:
[_object, "LALA_fnc_addCashRegister", nil, true] spawn BIS_fnc_MP;

So in that case all you'd be passing would be the reference to the _object instead of an entire script each time.

Share this post


Link to post
Share on other sites

Hey

ähm, kylania ? I can't get your func working in MP... on a dedicated i don't see my Actionmenu !! :(

First i thought, i'am doing something wrong with the locality, but i've tested this with various parameter (isServer or !isServer), but with no effect !! MP hosted local on my Machine is no problem, Menu is shown, but on a dedi... :(

Any Tips ?? What do i wrong ??

Thanks for help...

Greetz, Phantom

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  

×