Jump to content
Sign in to follow this  
thefinn

Making missions for Co-op vs SP

Recommended Posts

I did a lot of tutorials recently in order to make missions, however, none of the ones I read/watched showed the difference between sp and co-op.

I finally got a lot of that fixed (addmagazineglobal for instance), however, I cannot seem to get NVG's placed/assigned onto people. (it works fine in SP).

Can anyone show me what the difference is for CO-OP ?

Thanks!

Share this post


Link to post
Share on other sites

It should be the same, as far as I know, can you share the code your using so we can look into it?

Share this post


Link to post
Share on other sites

I goggled this and found it pretty easy. I usually google everything arma, most things people have already done it so its usually up on google. asking here is a great thing too. many people here are always willing to help.

this additem "NVGoggles";this assignitem "NVGoggles";this action["NVGoggles", this];

That gives you the goggles, assigns them to the slot, and starts you with them turned on.

another example

removeallweapons player;

player addweapon "arifle_MX_Hamr_point_grip_F";

player addweapon "hgun_rook40_f";

player additem "NVGoggles";

player addweapon "Binocular";

player additem "muzzle_snds_H";

player additem "muzzle_snds_L";

player addmagazine "100Rnd_65x39_caseless_mag_Tracer";

player addmagazine "30rnd_9x21_mag";

Share this post


Link to post
Share on other sites

Works fine single player, not in Co-op though. Also the script to set weapons to full auto at the end is failing because the magazines aren't loading into the weapons I noticed too.

removeallweapons this;

removeuniform this;

removevest this;

removebackpack this;

removeheadgear this;

this forceadduniform "U_IG_Guerilla2_1";

this addvest "V_TacVest_blk";

this addbackpack "B_FieldPack_blk";

this addheadgear "H_Watchcap_blk";

this addmagazineglobal "30Rnd_45ACP_Mag_SMG_01";

this addmagazineglobal "30Rnd_45ACP_Mag_SMG_01";

this addmagazineglobal "30Rnd_45ACP_Mag_SMG_01";

this addmagazineglobal "30Rnd_45ACP_Mag_SMG_01";

this addmagazineglobal "30Rnd_45ACP_Mag_SMG_01";

this addmagazineglobal "30Rnd_45ACP_Mag_SMG_01";

this addmagazineglobal "30Rnd_9x21_Mag";

this addmagazineglobal "30Rnd_9x21_Mag";

this addmagazineglobal "30Rnd_9x21_Mag";

this addmagazineglobal "handgrenade";

this addmagazineglobal "handgrenade";

this addmagazineglobal "B_IR_Grenade";

this addmagazineglobal "Chemlight_green";

this addmagazineglobal "SmokeShellGreen";

this addmagazineglobal "Chemlight_green";

this addmagazineglobal "SmokeShellGreen";

this addmagazineglobal "Chemlight_green";

this addmagazineglobal "SmokeShellGreen";

this addweaponglobal "SMG_01_Holo_pointer_snds_F";

this addweaponglobal "hgun_P07_snds_F";

this additem "nvgoggles";

this additem "itemgps";

this assignitem "nvgoggles";

this assignitem "itemgps";

(unitBackpack this) additemCargo ["FirstAidKit",2];

(unitbackpack this) addmagazinecargoglobal ["apersboundingmine_range_mag",3];

[this, 3000, false, true, true] call COB_fnc_HALO;

call TF_fnc_SETAUTOWEP;

---------- Post added at 09:59 ---------- Previous post was at 09:47 ----------

I goggled this and found it pretty easy. I usually google everything arma, most things people have already done it so its usually up on google. asking here is a great thing too. many people here are always willing to help.

this additem "NVGoggles";this assignitem "NVGoggles";this action["NVGoggles", this];

That gives you the goggles, assigns them to the slot, and starts you with them turned on.

another example

removeallweapons player;

player addweapon "arifle_MX_Hamr_point_grip_F";

player addweapon "hgun_rook40_f";

player additem "NVGoggles";

player addweapon "Binocular";

player additem "muzzle_snds_H";

player additem "muzzle_snds_L";

player addmagazine "100Rnd_65x39_caseless_mag_Tracer";

player addmagazine "30rnd_9x21_mag";

Did you even read the OP ? You aren't using globals in that and thus it won't work for CO-OP.

Player will join co-op and various weapons and mags will disappear.

I know how to add nvgoggles. nvgoggles disappearing in co-op is the issue.

---------- Post added at 10:06 ---------- Previous post was at 09:59 ----------

It should be the same, as far as I know, can you share the code your using so we can look into it?

I thought it should be the same also - but ... it's not working. The dude who was helping me test it has gone to work so... will be a while before I can make any headway.

Share this post


Link to post
Share on other sites

The difference between SP and CO-OP is obviously your number of players and CO-OP brings in locality issues as well, so I assume you have that code in your init.sqf, so using player or "this" could be troublesome.

Edited by JShock

Share this post


Link to post
Share on other sites

This is just in the initialization window of 4 players. (I intend on tidying it up).

Share this post


Link to post
Share on other sites

Your magazines probably aren't loading in because you need to have the weapon assigned first, before adding all the magazines in. And FYI you don't necessarily need globals just because it's a CO-OP mission, like I said it's a locality thing. So if you executed a script in the init.sqf locally on the player, you could use player in that script.

Share this post


Link to post
Share on other sites

Well the weapons don't spawn without it.

Nor the magazines.

In SP you need the magazine first in order to have the weapon loaded.

What's different in COOP ?

Not having globals is a well known issue that cropped up for co-op and thus the commands were added to the game in arma 3. It certainly fixed my original issue.

If you've not done what I'm doing before it will be hard for you to help I'd imagine.

Share this post


Link to post
Share on other sites

Actually sorry my mind went to mush, I was just thinking globals as in global variables, not the global commands (ugh, it's Thursday). And it's not that I haven't done this before, I've just only ever done CO-OP, and I also have my redress script (in my signature), which does basically what your trying to accomplish, and I don't use addMagazineGlobal in that.

Share this post


Link to post
Share on other sites

heh no worries.

I don't see a signature ?

I actually started the mission before my mate joined and everyone had ammo, as soon as he joined the magazines disappeared and only he had mags... very annoying ;)

The addmagazineglobal helped.

I wonder if that issue only crops up if it's in the initialization section of a player. But still I seem to have lost the mechanic from SP where if you have the mag in the inventory first, then the appears weapon loaded with the mag. Perhaps as he joins, the weapon unloads and doesn't load again. Either way it's totally frustrating.

Now might be a good time to throw all that into a script and just call it.

Nevermind Googled it thanks.

Edited by thefinn

Share this post


Link to post
Share on other sites

This seems to work okay for me on dedicated server. Tidied up your loadout script a bit also. Cheers.

init line

0 = this execVM "loadout.sqf"

loadout.sqf

if (isDedicated) exitWith {};

waitUntil {!(isNull _this)};

removeAllWeapons _this;
removeUniform _this;
removeVest _this;
removeBackPack _this;
removeHeadGear _this;
_this forceAddUniform "U_IG_Guerilla2_1";
_this addVest "V_TacVest_blk";
_this addBackPackGlobal "B_FieldPack_blk";
_this addHeadGear "H_Watchcap_blk";
_this addMagazines ["handgrenade", 2];
_this addMagazines ["B_IR_Grenade", 1];
_this addMagazines ["Chemlight_green", 3];
_this addMagazines ["SmokeShellGreen", 3];
_this addWeaponGlobal "NVGoggles_INDEP";
_this addWeaponGlobal "ItemGps";
{_this addItemToBackPack "FirstAidKit";} forEach [1,2];
{_this addItemToBackPack "apersboundingmine_range_mag";} forEach [1,2,3];
[_this, "SMG_01_Holo_pointer_snds_F", 6] call BIS_fnc_addWeapon;
[_this, "hgun_P07_snds_F", 3] call BIS_fnc_addWeapon;

---------- Post added at 15:21 ---------- Previous post was at 15:14 ----------

This could possibly help if having trouble with all inits (re)running on a jip. Cheers.

if (isDedicated) exitWith {};

waitUntil {!(isNull _this)};

if (isNil "INITLOADS") then { // In case all unit's init's re-run on JIP. Maybe they wont lose their shit.
INITLOADS = 1;
removeAllWeapons _this;
removeAllAssignedItems _this;
removeUniform _this;
removeVest _this;
removeBackPack _this;
removeHeadGear _this;
_this forceAddUniform "U_IG_Guerilla2_1";
_this addVest "V_TacVest_blk";
_this addBackPackGlobal "B_FieldPack_blk";
_this addHeadGear "H_Watchcap_blk";
_this addMagazines ["handgrenade", 2];
_this addMagazines ["B_IR_Grenade", 1];
_this addMagazines ["Chemlight_green", 3];
_this addMagazines ["SmokeShellGreen", 3];
_this addWeaponGlobal "NVGoggles_INDEP";
_this addWeaponGlobal "ItemGps";
{_this addItemToBackPack "FirstAidKit";} forEach [1,2];
{_this addItemToBackPack "apersboundingmine_range_mag";} forEach [1,2,3];
[_this, "SMG_01_Holo_pointer_snds_F", 6] call BIS_fnc_addWeapon;
[_this, "hgun_P07_snds_F", 3] call BIS_fnc_addWeapon;
};

Share this post


Link to post
Share on other sites

wow thanks will take a good long look at that.

Yes I didn't even realise that the topic really should've mentioned jip rather than co-op.

As Rumsfeld would say "unknown unknowns".

Will the jip version not run for SP is that why you seperated it ?

Edited by thefinn

Share this post


Link to post
Share on other sites

Yea that is the main difference between the two "types" of missions (being SP and CO-OP), singleplayer is you, yourself, and you, and then CO-OP brings in networks, locality (client/server), and JIP. So when scripting in CO-OP (aka multiplayer scripting) you just have to be aware of where the information is traveling to and from, that can solve a number of issues similar to this.

Share this post


Link to post
Share on other sites

Cool.

Damn couldn't be simple could it ? :)

Actually I have some issues with this version - I'm spawning everyone in a halo jump and for whatever reason it's interfering with the parachute being put on and equipment being put into a backpack on the front of the person while in jump...

Everyone dies ;)

---------- Post added at 13:13 ---------- Previous post was at 12:29 ----------

Ok I checked out this page here:

http://www.kylania.com/ex/?p=26

also this script:

http://editing.17thmedia.com/index.php/Arma_3_Editing/SQF_into_PBO

So going by that, a script with if (isDedicated) exitWith {}; at the start will exit if it's a co-op server.

And yet, I have a HALO script that runs with it at the start no problem on co-op.

What am I missing here ? Same with those scripts above.

Edited by thefinn

Share this post


Link to post
Share on other sites

It's because the halo needs to be local on the client side, not the server.

Share this post


Link to post
Share on other sites

Ok so ostensibly this script is run everywhere the mission is - but the server itself will end at the first line.

I getcha.

I had to go do something else for a bit to wipe the jumble from my mind lol

So equipment too is client-side, and the client tells the server what that particular soldier is putting on/taking off ?

Why then would the halo script not be running correctly after this ?

Also if there are AI in the game, they are not getting ANY equipment at all - which is because they are server-side and the script ends.

I am not sure how this is supposed to work.

Edited by thefinn

Share this post


Link to post
Share on other sites

For fixing the halo issue add another condition to the waitUntil loop at the top of your loadout sqf:

waitUntil {(!isNull _this) && (isTouchingGround _this)};

To answer the clarification question on equipment and client/server, yes, basically that is the idea of it.

For AI's, it's the concept used in my redress script, which is forEach allUnits with a condition of something (side in my script), and then redresses all the units that meet that condition, you could try that for the AI's.

Share this post


Link to post
Share on other sites

Ok works as a function, instead of execvm.

You'd know better than I why.

Share this post


Link to post
Share on other sites
Ok works as a function, instead of execvm.

You'd know better than I why.

Yea and if I would get off my lazy a$$, I actually re-wrote the entire thing into a function based system, but there is a feature I'm stuck on and don't feel like putting the brain power into it :p.

Share this post


Link to post
Share on other sites

if (isDedicated) exitWith {};

This confuses me.

IsDedicated will be true if it's running a dedicated mp server only. Going by this page: http://www.kylania.com/ex/?p=26

The issue I'm having is co-op JIP. I need more context here I think...

Like - under what circumstances does a script like this run on a client ? Why is it pulling SOME equipment off other people ?

I could understand not letting the server run the script possibly, or not letting the client run the script. So isMultiplayer could tailor your script to work either single or multiplayer. But I still don't know when I need to use it.

Have been looking for tutorials but many just cover multiplayer or make little sense because the examples given are for vehicles or something else I haven't even started to play with.

Something tells me this is all BI's fault anyhow, why isn't this shit context sensitive ?

Been playing with this for 2 days - behaviour seems completely illogical.

The below script works fine in SP, however in co-op with only 1 player the rest of the soldiers (AI) are naked with a set of nvg's ;)

Which makes SOME sense as I don't take the NVG's off them - however, the part of the code where I remove uniforms AT ALL is embedded in the if statement - so why are they naked at all ?

if (isDedicated) exitWith {};

waituntil {!(isnull _this)};

if (isNil "_DONE") then {
   removeAllWeapons _this;
   removeUniform _this;
   removeVest _this;
   removeBackPack _this;
   removeHeadGear _this;
   _this forceAddUniform "U_IG_Guerilla2_1";
   _this addVest "V_TacVest_blk";
   _this addBackPackGlobal "B_FieldPack_blk";
   _this addHeadGear "H_Watchcap_blk";
   _this addMagazines ["handgrenade", 2];
   _this addMagazines ["B_IR_Grenade", 1];
   _this addMagazines ["Chemlight_green", 3];
   _this addMagazines ["SmokeShellGreen", 3];
   _this addWeaponGlobal "NVGoggles_INDEP";
   _this addWeaponGlobal "ItemGps";
   {_this addItemToBackPack "FirstAidKit";} forEach [1,2];
   {_this addItemToBackPack "apersboundingmine_range_mag";} forEach [1,2,3];
   [_this, "SMG_01_Holo_pointer_snds_F", 6] call BIS_fnc_addWeapon;
   [_this, "hgun_P07_snds_F", 3] call BIS_fnc_addWeapon; 
_DONE = 1;
}

Edited by thefinn

Share this post


Link to post
Share on other sites

_DONE is a local variable. It is local to the script. It will always be nil every time the script is run. Make it a (local) global variable. eg; DONE. Other than that, don't know what to say. I never use init lines to loadout units =(

Share this post


Link to post
Share on other sites

How do you do it ?

(I just got through playing a co-op on steam which had the EXACT same issues involved - equipment in backpacks the players wearing them couldn't see but other players could etc...)

Share this post


Link to post
Share on other sites

You could also use my redress script, as I stated before, and if that doesn't suit you, you could look into Jona's Redress Functions. As far as I know from reports on my script and Jona's alike they work with CO-OP MP.

And what do you mean how do you do it? You simply remove the "_" from the variable as Iceman stated?

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  

×