Jump to content

Recommended Posts

Posted (edited)

I have 6 potential FIA Weapon Caches scattered around the map. (3 normal weapon caches, 3 special weapon caches). At the start of the mission, I would like all except for 1 from each weapon cache type to be deleted from the map, so I am only left with 2 weapon caches on the map. (Each weapon cache has a local map icon that shows the BLUFOR player where the weapon cache is located, which needs to be deleted as well).

My current script, located in my "initServer.sqf".

Spoiler

_deleteCacheN = selectRandom

[

    [ "Zeus_M_Unknown1_1", FIAWeaponCacheN1_1 ],

    [ "Zeus_M_Unknown1_2", FIAWeaponCacheN1_2 ],

    [ "Zeus_M_Unknown1_3", FIAWeaponCacheN1_3 ]

];

 

{

    ( deleteMarker _deleteCacheN select 0 );

    ( deleteVehicle _deleteCacheN select 1 );

};




 

_deleteCacheS = selectRandom

[

    [ "Zeus_M_Unknown2_1", FIAWeaponCacheS1_1 ],

    [ "Zeus_M_Unknown2_2", FIAWeaponCacheS1_2 ],

    [ "Zeus_M_Unknown2_3", FIAWeaponCacheS1_3 ]

];

 

{

    ( deleteMarker _deleteCacheS select 0 );

    ( deleteVehicle _deleteCacheS select 1 );

};

 

This doesn't seem to do anything (no error message or anything) on mission start and I am not sure why.

 

Please help!

Edited by rkemsley
Solved

Share this post


Link to post
Share on other sites

Those curly brackets above and below your deletion parts are nonsense. Idk if it causes this but it could.

  • Thanks 1

Share this post


Link to post
Share on other sites
6 hours ago, sarogahtyp said:

Those curly brackets above and below your deletion parts are nonsense. Idk if it causes this but it could.

Strangely, that was actually the cause.

Spoiler

_deleteCacheN = selectRandom

[

    [ "Zeus_M_Unknown1_1", FIAWeaponCacheN1_1 ],

    [ "Zeus_M_Unknown1_2", FIAWeaponCacheN1_2 ],

    [ "Zeus_M_Unknown1_3", FIAWeaponCacheN1_3 ]

];

deleteMarker ( _deleteCacheN select 0 );

deleteVehicle ( _deleteCacheN select 1 );

 

_deleteCacheS = selectRandom

[

    [ "Zeus_M_Unknown2_1", FIAWeaponCacheS1_1 ],

    [ "Zeus_M_Unknown2_2", FIAWeaponCacheS1_2 ],

    [ "Zeus_M_Unknown2_3", FIAWeaponCacheS1_3 ]

];

deleteMarker ( _deleteCacheS select 0 );

deleteVehicle ( _deleteCacheS select 1 );

So this script obviously deletes one of the FIAWeaponCaches from each weapon cache Array. What I am wondering how to do is get it so that it deletes all the weapons caches except for the ones picked randomly from each group.

Share this post


Link to post
Share on other sites
58 minutes ago, rkemsley said:

Strangely

not strange, just how sqf code works.

 

What strikes me is that you just throw one question after the other without learning bout the answers. That way you ll produce patched up scripts and missions full of slow code and full of bugs...

Nice advice: Read the biki-entries for any command you use carefully. This is the way to learn sqf-scripting effective and it is the fastest way as well.

 

https://community.bistudio.com/wiki/Category:Arma_3:_Scripting_Commands

 

Anyways this is not tested but should work:

 

private ["_dummy"];

private _CachesN =
[
    [ "Zeus_M_Unknown1_1", FIAWeaponCacheN1_1 ],
    [ "Zeus_M_Unknown1_2", FIAWeaponCacheN1_2 ],
    [ "Zeus_M_Unknown1_3", FIAWeaponCacheN1_3 ]
];

private _CachesS =
[
    [ "Zeus_M_Unknown2_1", FIAWeaponCacheS1_1 ],
    [ "Zeus_M_Unknown2_2", FIAWeaponCacheS1_2 ],
    [ "Zeus_M_Unknown2_3", FIAWeaponCacheS1_3 ]
];

_leftOverCacheN = selectRandom _CachesN;
_leftOverCacheS = selectRandom _CachesS;

_dummy = _CachesN deleteAt findIf { _leftOverCacheN isEqualTo _x };
_dummy = _CachesS deleteAt findIf { _leftOverCacheS isEqualTo _x };

_CachesN append _CachesS;

{
 deleteMarker ( _x select 0 );
 deleteVehicle ( _x select 1 );
} count _CachesN;

 

 

Share this post


Link to post
Share on other sites
37 minutes ago, rkemsley said:

Strangely, that was actually the cause.

It's not strange at all. What the curly brackets does is define a Code-data type block, a set of instructions that can be stored in a variable just like numbers or strings. There is no execution done by a {}-block because it's just data.

If you look at a regular if () then {}-statement it's actually the "if-then" construct that makes the engine execute the data in the Code-block.

 

  • Like 2

Share this post


Link to post
Share on other sites
Posted (edited)
Spoiler
11 hours ago, sarogahtyp said:

not strange, just how sqf code works.

 

What strikes me is that you just throw one question after the other without learning bout the answers. That way you ll produce patched up scripts and missions full of slow code and full of bugs...

Nice advice: Read the biki-entries for any command you use carefully. This is the way to learn sqf-scripting effective and it is the fastest way as well.

 

https://community.bistudio.com/wiki/Category:Arma_3:_Scripting_Commands

 

Anyways this is not tested but should work:

 



private ["_dummy"];

private _CachesN =
[
    [ "Zeus_M_Unknown1_1", FIAWeaponCacheN1_1 ],
    [ "Zeus_M_Unknown1_2", FIAWeaponCacheN1_2 ],
    [ "Zeus_M_Unknown1_3", FIAWeaponCacheN1_3 ]
];

private _CachesS =
[
    [ "Zeus_M_Unknown2_1", FIAWeaponCacheS1_1 ],
    [ "Zeus_M_Unknown2_2", FIAWeaponCacheS1_2 ],
    [ "Zeus_M_Unknown2_3", FIAWeaponCacheS1_3 ]
];

_leftOverCacheN = selectRandom _CachesN;
_leftOverCacheS = selectRandom _CachesS;

_dummy = _CachesN deleteAt findIf { _leftOverCacheN isEqualTo _x };
_dummy = _CachesS deleteAt findIf { _leftOverCacheS isEqualTo _x };

_CachesN append _CachesS;

{
 deleteMarker ( _x select 0 );
 deleteVehicle ( _x select 1 );
} count _CachesN;

 

 

Gave this a go, unfortunately, it didn't seem to work. It keeps telling me there "_dummy = _CachesN deleteAt |#|findIf { _leftOverCache isEqualTo _x };...", "Error Undefined variable in expression: findif" and "Error Mission ;"

 

I think I see what you are doing. Taking away one Array from the other. I tried this but it didn't like this either.

Spoiler

private _CacheN =

[

    [ "Zeus_M_Unknown1_1", FIAWeaponCacheN1_1 ],

    [ "Zeus_M_Unknown1_2", FIAWeaponCacheN1_2 ],

    [ "Zeus_M_Unknown1_3", FIAWeaponCacheN1_3 ]

];

_deleteCacheN = selectRandom _CacheN;

_CacheN = _CacheN - [ [ _deleteCacheN ] ];

{ deleteMarker _x } foreach ( _CacheN select 0 );

{ deleteVehicle _x } foreach ( _CacheN select 1 );

 

private _CacheS =

[

    [ "Zeus_M_Unknown2_1", FIAWeaponCacheS1_1 ],

    [ "Zeus_M_Unknown2_2", FIAWeaponCacheS1_2 ],

    [ "Zeus_M_Unknown2_3", FIAWeaponCacheS1_3 ]

];

_deleteCacheS = selectRandom _CacheS;

_CacheS = _CacheS - [ [ _deleteCacheS ] ];

{ deleteMarker _x } foreach ( _CacheS select 0 );

{ deleteVehicle _x } foreach ( _CacheS select 1 );

 

Edit: I kinda feel like this is starting to become a test. Anyway, the code below now works. (Feel free to add your criticism about how little I know about coding).

Spoiler

private _CacheN =

[

    [ "Zeus_M_Unknown1_1", FIAWeaponCacheN1_1 ],

    [ "Zeus_M_Unknown1_2", FIAWeaponCacheN1_2 ],

    [ "Zeus_M_Unknown1_3", FIAWeaponCacheN1_3 ]

];

_deleteCacheN = selectRandom _CacheN;

_CacheN deleteAt ( _CacheN findIf { _deleteCacheN isEqualTo _x } ); { 

    deleteMarker ( _x select 0 );

    deleteVehicle ( _x select 1 );

} foreach _CacheN;

 

private _CacheS =

[

    [ "Zeus_M_Unknown2_1", FIAWeaponCacheS1_1 ],

    [ "Zeus_M_Unknown2_2", FIAWeaponCacheS1_2 ],

    [ "Zeus_M_Unknown2_3", FIAWeaponCacheS1_3 ]

];

_deleteCacheS = selectRandom _CacheS;

_CacheS deleteAt ( _CacheS findIf { _deleteCacheS isEqualTo _x } ); {  

    deleteMarker ( _x select 0 );

    deleteVehicle ( _x select 1 );

} foreach _CacheS;

 

Edit Edit: It works fine when testing it as the server, however, when I test it as a client, it doesn't work. So, on map initiation, the weapon caches get deleted, but all of the map markers are still visible. I have the script located in my "initServer.sqf".

Edited by rkemsley

Share this post


Link to post
Share on other sites

Another way:

 

Place 1 weapon cash on the map.  Arrange it so that it starts at one of 3 places at random.

 

Each of those 3 places has a trigger, when the cash appears the trigger causes a marker to change size from size  zero (in effect invisible)  to a large size which makes it visible.

.

 

Share this post


Link to post
Share on other sites
Quote

private _CacheN =

[

    [ "Zeus_M_Unknown1_1", FIAWeaponCacheN1_1 ],

    [ "Zeus_M_Unknown1_2", FIAWeaponCacheN1_2 ],

    [ "Zeus_M_Unknown1_3", FIAWeaponCacheN1_3 ]

];

_deleteCacheN = selectRandom _CacheN;

_CacheN deleteAt ( _CacheN findIf { _deleteCacheN isEqualTo _x } ); {

    [ _x select 0 ] remoteExec [ "deleteMarker", 0, true ];

    deleteVehicle ( _x select 1 );

} foreach _CacheN;

 

private _CacheS =

[

    [ "Zeus_M_Unknown2_1", FIAWeaponCacheS1_1 ],

    [ "Zeus_M_Unknown2_2", FIAWeaponCacheS1_2 ],

    [ "Zeus_M_Unknown2_3", FIAWeaponCacheS1_3 ]

];

_deleteCacheS = selectRandom _CacheS;

_CacheS deleteAt ( _CacheS findIf { _deleteCacheS isEqualTo _x } ); {

    [ _x select 0 ] remoteExec [ "deleteMarker", 0, true ];

    deleteVehicle ( _x select 1 );

} foreach _CacheS;

Ok, this is now working for multiplayer.

Share this post


Link to post
Share on other sites
private _CacheN =
[
  ["Zeus_M_Unknown1_1", FIAWeaponCacheN1_1],
  ["Zeus_M_Unknown1_2", FIAWeaponCacheN1_2],
  ["Zeus_M_Unknown1_3", FIAWeaponCacheN1_3]
];
_CacheN deleteAt selectRandom [0,1,2];
{
  deleteMarker (_x#0);
  deleteVehicle (_x#1);
} count _CacheN;

private _CacheS =
[
  [ "Zeus_M_Unknown2_1", FIAWeaponCacheS1_1 ],
  [ "Zeus_M_Unknown2_2", FIAWeaponCacheS1_2 ],
  [ "Zeus_M_Unknown2_3", FIAWeaponCacheS1_3 ]
];
_CacheS deleteAt selectRandom [0,1,2];
{
  deleteMarker (_x#0);
  deleteVehicle (_x#1);
} count _CacheS;

No reason for making things complicated. No reason for remote executing deleteMarker command, if you didn't create them locally (in editor, you didn't).

 

  • Like 1

Share this post


Link to post
Share on other sites
15 hours ago, pierremgi said:

private _CacheN =
[
  ["Zeus_M_Unknown1_1", FIAWeaponCacheN1_1],
  ["Zeus_M_Unknown1_2", FIAWeaponCacheN1_2],
  ["Zeus_M_Unknown1_3", FIAWeaponCacheN1_3]
];
_CacheN deleteAt selectRandom [0,1,2];
{
  deleteMarker (_x#0);
  deleteVehicle (_x#1);
} count _CacheN;

private _CacheS =
[
  [ "Zeus_M_Unknown2_1", FIAWeaponCacheS1_1 ],
  [ "Zeus_M_Unknown2_2", FIAWeaponCacheS1_2 ],
  [ "Zeus_M_Unknown2_3", FIAWeaponCacheS1_3 ]
];
_CacheS deleteAt selectRandom [0,1,2];
{
  deleteMarker (_x#0);
  deleteVehicle (_x#1);
} count _CacheS;

No reason for making things complicated. No reason for remote executing deleteMarker command, if you didn't create them locally (in editor, you didn't).

 

I tried a method similar to this earlier (without remote executing deleteMarker) and it worked fine when testing it by starting the map in Multiplayer (where I am the server). However, as soon as I test it when I am just a client, if I don't remote execute the markers they still appear on map initiation for everyone.

On another note, I have changed what the caches are, basically making them spawn in buildings that have a bunch of stuff inside them (removing the stuff if the cache hasn't been chosen to spawn there).

Spoiler

private _Cache1 =

[

    [ "Zeus_M_Unknown1_1", getMissionLayerEntities "Layer_FIASupplyCache1_1" select 0 ],

    [ "Zeus_M_Unknown1_2", getMissionLayerEntities "Layer_FIASupplyCache1_2" select 0 ],

    [ "Zeus_M_Unknown1_3", getMissionLayerEntities "Layer_FIASupplyCache1_3" select 0 ]

];

_deleteCache1 = selectRandom _Cache1;

_Cache1 deleteAt ( _Cache1 findIf { _deleteCache1 isEqualTo _x } ); {

    [ _x select 0 ] remoteExec [ "deleteMarker", 0, true ];

    [ { deleteVehicle _x } forEach (  _x select 1 ) ] remoteExec [ "call", 0, true ];

} foreach _Cache1;

 

private _Cache2 =

[

    [ "Zeus_M_Unknown2_1", getMissionLayerEntities "Layer_FIASupplyCache2_1" select 0 ],

    [ "Zeus_M_Unknown2_2", getMissionLayerEntities "Layer_FIASupplyCache2_2" select 0 ],

    [ "Zeus_M_Unknown2_3", getMissionLayerEntities "Layer_FIASupplyCache2_3" select 0 ]

];

_deleteCache2 = selectRandom _Cache2;

_Cache2 deleteAt ( _Cache2 findIf { _deleteCache2 isEqualTo _x } ); {

    [ _x select 0 ] remoteExec [ "deleteMarker", 0, true ];

    [ { deleteVehicle _x } forEach ( _x select 1 ) ] remoteExec [ "call", 0, true ];

} foreach _Cache2;

This seems to be working as intended, but I haven't tested it as a client yet. Only as the server.

 

Edit: it does work client-side as well.

 

Edit Edit: pierremgi, what are you confused about? When you wrote your version of the script, did you test it by having your computer remotely run the server, then join as a client, rather than hosting the server through Arma 3 yourself? Because I tried a method which was pretty much what you wrote, and it doesn't work client-side.

  • Confused 1

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

×