astruyk / Ares

An arma3 mod that adds some extra functionality to Zeus
51 stars 11 forks source link

Question about Custom Module and Groups #193

Closed Talyataya closed 9 years ago

Talyataya commented 9 years ago

I'm basically bad at coding so sorry to ask this but I checked default modules' codes and couldnt figure out how but, how can I make a module that when dropped on an unit, it would affect that unit?

and I know its not the place but if I ask this somewhere else, I doubt I ll get some answer:

Is it possible to remove the limit on groups of a side on Zeus in anyway? If so , is it something that can be done by me(like dont know maybe some code to do it) or do you think to put a feature about this in future in your mod?

astruyk commented 9 years ago

Here's a good example of how you'd register a module to do something to a particular unit that the module was dropped on: https://github.com/astruyk/Ares/blob/master/src/addons/ares_zeusExtensions/scripts/Util_RemoveAllActions.sqf

That basically grabs the unit under the cursor, checks that there actually WAS one, and executes some functions on it. The _unitUnderCursor = _this select 1; bit is the bit that actually grabs the unit under the cursor.

Two parameters are always passed to the script:

_foo = _this select 0; // Sets _foo to the position where the user dropped the module
_bar = _this select 1; // Sets _bar to the unit or object under the cursor when it was dropped.

The object can be null (if, for example the user drops the module on empty space), so it's a good idea to check that it's not null (e.g. if (not isNull _bar) then { /* Your code here */ }; ).

Depending on what you do, you may have to worry about the locality of the object (that is, some commands only work when you run them on the same client that actually created the object). Normally you'd call off to the appropriate machine using the BIS_fnc_MP function if necessary. There are lots of things that this doesn't matter for - but it's a good idea to understand (this is a pretty good tutorial: http://killzonekid.com/arma-scripting-tutorials-locality/ )

I'm not sure what you mean about 'remove the limit on groups of a side' in Zeus.

Talyataya commented 9 years ago

Thanks for the fast and detailed answer, what Im talking about is group limit which you cant put more than 142 groups.(Which also is 142 units if you select units' position 1 by 1)

astruyk commented 9 years ago

I don't think there's a way to expand the number of groups that are allowed. I know there used to be (maybe still is) a bug with Zeus where groups that were removed were still counting towards the limit. I thought it got fixed, but we used to run this script to clean them up periodically:

while {true} do
{
    {deleteGroup _x} foreach allGroups;
    sleep 30;
};
astruyk commented 9 years ago

Marking as closed since I think the original questions were answered.