Jump to content
kupcho

RESPAWN Modules

Recommended Posts

Howdy folks.

I'm trying to have a vehicle respawn with certain items in its inventory. Specifically, I'd like to add a camping backpack to use as a respawn point.

This what I've tried...

 

Place the vehicle...place a VEHICLE RESPAWN MODULE...Sync them together and type this     "this addItemCargo [b_Respawn_TentDome_F,1];"     into the EDIT VEHICLE RESPAWN - SYSTEM SPECIFIC - VEHICLE RESPAWN EXPRESSION field found in the module attributes.

 

I'm VERY far from understanding scripting using code placed in .sqf files (or anywhere the script would be entered to be honest), so I'd appreciate answers that only use the modules features.

Or, if you feel that you must give your answer using a script, PLEASE...be generous with your directions. Like I said...I'm pretty damn ignorant when it comes to the stuff.

 

Thanks in advance.

Share this post


Link to post
Share on other sites

I might've been mistaking but I think the correct script would be "(_this select 1) addItemCargoGlobal ["bla",1];

Make sure to check "force respawn"

_this select 0 is the old vehicle and _this select 1 the new spawned.

"Force respawn" creates the vehicle, deletes it and creates it again forcing the code on it.

The one thing I am not quite sure about is, if the code is run locally or on every client. So if you play this with your friends and there are as many backpacks as there are players then it might get a little bit more complicated.

I will try the code when I am at my pc

Share this post


Link to post
Share on other sites

I tried the script you suggested, but I couldn't get it to work. I assumed that the "bla" was a place holder for the item I wanted to put into the vehicle (B_Respawn_TentDome_F), but even so, I tried typing in the "bla" too.

One thing I did figure out was that I was using addItemCargo where I should be using addBackpackCargo.

Also, I guess that you may have misunderstood my intentions, I want the tent in a specific truck, not in every one. And I only want one or two of the backpacks in the vehicle anyway.

Would I be wrong to assume the addItemCargoGlobal would put it into every vehicle synced to the module? Or every Offroad (the vehicle I'm trying to use...going camping y'know...) I have on the map?

Sorry if the questions are too basic, but like I said...I'm really not very well versed in scripting.

In any event, I appreciate your time and suggestion.

Share this post


Link to post
Share on other sites

Name the specific Offroad you want to have the cargo, say Bob and synch it to the module.  Then in your Vehicle Respawn Module put this in it's expression field:

_this select 0 lock 0; if (bob == _this select 0) then {bob addBackpackCargoGlobal ["B_Respawn_TentDome_F",1]}  

The first part is to force it to unlock, since I've seen a lot of problems with it locking after respawn. :)  The second part checks if the vehicle being respawned is bob and if it is puts the backpack in it's inventory.  Other vehicles synched to the module respawn normally without the backpack.

Share this post


Link to post
Share on other sites

Ah yes it was backpackcargo. Well the respawn module will apply the code to the objects synced to it.

So if you want to have different codes running on different objects then just place another module.

Or make a nice script like kylania filtering out the things you want.

Share this post


Link to post
Share on other sites

Thanks guys, it works great!

Just what I needed.

 

As a further experiment, I tried this line to add a GPS unit.

 

_this select 0 lock 0; if (bob == _this select 0) then {bob addBackpackCargoGlobal ["B_Respawn_TentDome_F",1]; bob addItemCargoGlobal ["itemgps",1]}

 

It also worked, but just so I'm clear, could I keep adding things in this manner?

I just want to make sure that I'm getting the syntax correct.

 

Again...

THANK YOU for the help. :)

Share this post


Link to post
Share on other sites

Jupp, you can add as much stuff as you want.

It will get messy, with everything in one line so I would recommend putting it in an external script.

Share this post


Link to post
Share on other sites

so I would recommend putting it in an external script.

 

Since you say you're not very familiar with scripting, once you have more than a few lines of code, it's usually much easier to put that code into its own file to make it easier to read (and therefore easier to spot mistakes), especially once you have things like if statements.  So you could take your code and using something like Notepad (or Notepad++) make a file called "addVehicleCargo.sqf" that contains:

params ["_veh"]; // Since we're calling this code from a script file, we need to pass in the vehicle as an argument (the "_this select 0" part below)
_veh lock 0; // And you can put in comments after a double slash to remind you what each line does
if (bob == _veh) then {
  _veh addBackpackCargoGlobal ["B_Respawn_TentDome_F", 1]; 
  _veh addItemCargoGlobal ["itemgps", 1]; // It's good practice to end each line with a semicolon, even if it's the last line
}; // So another semicolon here too in case you add something after it later

and save that file in your mission's folder (so it appears alongside your mission.sqm file in the same directory).  Then instead of calling those lines of code verbatim inside the module's Expression field, you'd put this instead:

[_this select 0] execVM 'addVehicleCargo.sqf'

and the contents of that file will be executed just like the code you had in that field was previously.

  • Like 1

Share this post


Link to post
Share on other sites

 

On 26/5/2016 at 6:21 AM, ravenleg said:

 

Since you say you're not very familiar with scripting, once you have more than a few lines of code, it's usually much easier to put that code into its own file to make it easier to read (and therefore easier to spot mistakes), especially once you have things like if statements.  So you could take your code and using something like Notepad (or Notepad++) make a file called "addVehicleCargo.sqf" that contains:


params ["_veh"]; // Since we're calling this code from a script file, we need to pass in the vehicle as an argument (the "_this select 0" part below)
_veh lock 0; // And you can put in comments after a double slash to remind you what each line does
if (bob == _veh) then {
  _veh addBackpackCargoGlobal ["B_Respawn_TentDome_F", 1]; 
  _veh addItemCargoGlobal ["itemgps", 1]; // It's good practice to end each line with a semicolon, even if it's the last line
}; // So another semicolon here too in case you add something after it later

and save that file in your mission's folder (so it appears alongside your mission.sqm file in the same directory).  Then instead of calling those lines of code verbatim inside the module's Expression field, you'd put this instead:


[_this select 0] execVM 'addVehicleCargo.sqf'

and the contents of that file will be executed just like the code you had in that field was previously.

 

Hi @ravenleg@kylania , I need empty the default loadout on respawning to only get in my items and not defaults, how is the script to make this? May be with clearItemCargoGlobal and clearBackpackCargoGlobal? I don't know how apply in this script.

Thanks!

 

My script:

params ["_veh"]; // Since we're calling this code from a script file, we need to pass in the vehicle as an argument (the "_this select 0" part below)
_veh lock 0; // And you can put in comments after a double slash to remind you what each line does
if (m113_amb_bushlurker == _veh) then {
 _veh addItemCargoGlobal ["MineDetector", 1];
 _veh addItemCargoGlobal ["Binocular", 1];
 _veh addItemCargoGlobal ["ACE_bodyBag", 5];
 _veh addItemCargoGlobal ["ACE_wirecutter", 1];
 _veh addItemCargoGlobal ["ACE_personalAidKit", 10];
 _veh addItemCargoGlobal ["ACE_microDAGR", 1];
 _veh addItemCargoGlobal ["ACE_MapTools", 1];
 _veh addItemCargoGlobal ["ACE_surgicalKit", 5];
 _veh addItemCargoGlobal ["ACE_key_lockpick", 1];
 _veh addItemCargoGlobal ["ACE_Flashlight_XL50", 1];
 _veh addItemCargoGlobal ["ItemMap", 1];
 _veh addItemCargoGlobal ["ACE_EntrenchingTool", 1];
 _veh addItemCargoGlobal ["ACE_SpraypaintRed", 1];
 _veh addItemCargoGlobal ["ACE_CableTie", 5];
 _veh addItemCargoGlobal ["ACE_Sandbag_empty", 5];
 _veh addItemCargoGlobal ["ACE_EarPlugs", 10];
 _veh addItemCargoGlobal ["ACE_fieldDressing", 10];
 _veh addItemCargoGlobal ["ACE_elasticBandage", 10];
 _veh addItemCargoGlobal ["ACE_quikclot", 10];
 _veh addItemCargoGlobal ["ACE_packingBandage", 10];
};
if (m113_zapador1 == _veh) then {
 _veh addItemCargoGlobal ["MineDetector", 1];
 _veh addItemCargoGlobal ["Binocular", 1];
 _veh addItemCargoGlobal ["ACE_Clacker", 4];
 _veh addItemCargoGlobal ["ACE_wirecutter", 1];
 _veh addItemCargoGlobal ["ACE_personalAidKit", 4];
 _veh addItemCargoGlobal ["ACE_microDAGR", 1];
 _veh addItemCargoGlobal ["ACE_MapTools", 1];
 _veh addItemCargoGlobal ["ACE_key_lockpick", 1];
 _veh addItemCargoGlobal ["ACE_Flashlight_XL50", 1];
 _veh addItemCargoGlobal ["ItemMap", 1];
 _veh addItemCargoGlobal ["ACE_EntrenchingTool", 1];
 _veh addItemCargoGlobal ["ACE_SpraypaintRed", 1];
 _veh addItemCargoGlobal ["ACE_CableTie", 5];
 _veh addItemCargoGlobal ["ACE_Sandbag_empty", 5];
 _veh addItemCargoGlobal ["ACE_EarPlugs", 10];
 _veh addItemCargoGlobal ["ACE_fieldDressing", 4];
 _veh addItemCargoGlobal ["ACE_elasticBandage", 4];
 _veh addItemCargoGlobal ["ACE_quikclot", 4];
 _veh addItemCargoGlobal ["ACE_packingBandage", 4];
 _veh addItemCargoGlobal ["ToolKit", 1];
 _veh addItemCargoGlobal ["SatchelCharge_Remote_Mag", 4];
 _veh addItemCargoGlobal ["DemoCharge_Remote_Mag", 4];
};

 

Share this post


Link to post
Share on other sites

Gonna put this here cause it took me a bit to figure out how to clear the vehicle of its default loadout. You can see the _veh is used after clearitemcargo and the other two. Do not use "remove" on vehicles. I wanted to load a chair into the thing but I can't get it in LOL


 

params ["_veh"]; // Since we're calling this code from a script file, we need to pass in the vehicle as an argument (the "_this select 0" part below)
_veh lock 0; // And you can put in comments after a double slash to remind you what each line does
if (bob == _veh) then {
clearItemCargo _veh ;
clearmagazineCargo _veh;
clearWeaponCargo _veh;

_VEH addweaponcargoglobal ["uns_ak47", 35]; 

_VEH addweaponcargoglobal ["CUP_hgun_Colt1911", 35];

 

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

×