Vostok7798
Member-
Content Count
3 -
Joined
-
Last visited
-
Medals
Community Reputation
0 NeutralAbout Vostok7798
-
Rank
Rookie
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
Vostok7798 started following Problem scripting ACE explosives and Trouble looping through allPlayers array
-
Trouble looping through allPlayers array
Vostok7798 posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hey, all. Just wrote this event handler script the other day, and I hope to eventually implement it into a multiplayer mission. Now, I want the event handler to assign to all players on the server, so I thought I'd just create a forEach loop with the allPlayers array. The problem is, when I make reference to the _z variable within the loop it seems to mess with the commands and produce all kinds of compiling errors. As a bit of a run down, the event handler activates when the player fires their weapon. If there is a civilian in a vehicle, within 20 meters, who possesses a detonator, as well as an explosive device attached to his car, there will be a 75% chance they will detonate it. In addition, if there is a civilian driver within 50 meters, who merely carries a gun, he will be assigned to an enemy side and made enemy to the player. Now, the obvious issue is, throughout the code, the variable "player" is used, and from what I understand, it is no recommended to use it in multiplayer, hence the "forEach allPlayers" loop. Now, I thought it was merely a matter of substituting the player variable with _z, which represents a player from the allPlayers array. However, like mentioned above, it seems to cause quite a long list of errors. To be clear, the code as depicted below works flawlessly in the editor environment. Here is the code: { // All Players _z = _x; _z addEventHandler["Fired",{ _obTemp = nearestObjects [player, ["Car"], 50]; _manTemp = nearestObjects [player, ["Man"], 50]; { // All vehicles in a 50 meter radius of the player _y = _x; _hasWeap = false; if (! isnull (driver _y)) then { if ("ACE_M26_Clacker" in items driver _y && count (attachedObjects _y) > 0) then { if ((random 100) > 25 && (player distance _y < 20)) then { [(attachedObjects _y select 0), 1] call ace_explosives_fnc_scriptedExplosive; }; }; }; { // The occupants of the aforementioned vehicles _w = _x; { // The weapons of the aforementioned occupants if (_x != "" && side (driver _y) == civilian) then {_hasWeap = true}; [east, "HQ"] sideChat format ["%1", _x != ""]; } forEach weapons _w; } forEach crew _y; if (_hasWeap) then { _agGroup = createGroup (selectRandom [WEST, INDEPENDENT]); crew _y joinSilent _agGroup; { // Members of the new hostile group _x enableAI "ALL"; } forEach units _agGroup; _agGroup leaveVehicle _y; }; } forEach _ObTemp; { // All AI units in a 50 meter radius of the player _y = _x; _hasWeap = false; _unitAr = []; { // The weapons of the aforementioned AI if (side _y == civilian && _x != "") then {_hasWeap = true}; } forEach weapons _y; if (_hasWeap) then { _x enableAI "ALL"; _unitAr = _unitAr + [_y] }; } forEach _manTemp; _agGroup = createGroup (selectRandom [WEST, INDEPENDENT]); _unitAr joinSilent _agGroup; }]; } forEach allPlayers; Fair warning: I know nearly nothing about all of the multiplayer scripting quirks (and am only a beginner at programming in general), and have very little knowledge on what should be executed on solely the server, or what should be executed globally, or what should be executed by the clients, etc.. So, and pointers are more than welcome. at this point, I just need to know if I am barking up the right or wrong tree with how I am doing things.- 2 replies
-
- loop
- allplayers
-
(and 2 more)
Tagged with:
-
Problem scripting ACE explosives
Vostok7798 replied to Vostok7798's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Brilliant, hats off to you guys. Looks like it was a just matter of changing the config class to something designed to explode. It's always the simple things. I still have to look into what you said, diwako. It still baffles me that placing "demoCharg_F" in the editor causes it to function, yet spawning it via script does not. It must, at some point during the mission initialisation, convert the explosive to a functional config class.- 3 replies
-
- explosives
- ace
-
(and 2 more)
Tagged with:
-
Hey, all. I've been attempting to create a mission for some time now, and every problem I've encountered so far, I have been able to solve... until today. Context: Simply put, the mission uses ACE, which has its own explosive framework, and to that end the ACE site does provide some useful information. Specifically, I've been using 'ace_explosives_fnc_scriptedExplosive'. The good news is, it works like a charm. The catch is that it only seems to work for explosives which are spawned in through the editor, and not those created by scripts. In my scenario, there is a trigger (code below). The idea is to have an area where all cars driven by blufor units have a demolition charge spawned and attached to said vehicle, then have it explode. The problem is the line '[_newEp, -3] call ace_explosives_fnc_scriptedExplosive;'. For whatever reason, it works wonders with explosives placed within the editor (and subsequently attached to vehicles), but doesn't do a thing for any explosive spawned in via script. I was hoping any of you, who are more versed in scripting, could shed some light on the subject. I am by no means an experienced script writer/programmer, and most of what I know is from hours of messing around, so any advice would be much appreciated. Condition Code executed by the trigger: count (nearestObjects [trig2, ["Car"], 50]) > 0; On Activation code executed by the trigger (via script): _carlist = _this select 0; { if (side (driver _x) == west) then { hint "true"; _newEp = "DemoCharge_F" createVehicle [0, 0, 0]; _newEp attachTo [_x, [0, 0, 0], "driverview"]; [_newEp, -3] call ace_explosives_fnc_scriptedExplosive; } else { hint "false" }; } forEach _carList; Where _carList is: nearestObjects [trig2, ["Car"], 50] If I had to chance a guess at what was happening, I'd wager that ACE is only applying its explosive framework to the explosives placed in the editor, while those spawned via script maintain their vanilla class attributes.
- 3 replies
-
- explosives
- ace
-
(and 2 more)
Tagged with: