Jump to content

Neonz27

Member
  • Content Count

    16
  • Joined

  • Last visited

  • Medals

Everything posted by Neonz27

  1. I have a mission where I'm wanting to spawn several structures consisting of around 20-25 props each when a trigger is activated. I am fully aware that I can use createVehicle to spawn individual props & pieces of the structure, but is there an easy way for me to spawn the structure as a whole? It seems like quite a task to create multiple triggers each with dozens of addVehicle calls for each individual prop. I hope that I'm wording this in a way that's easy to understand. Thanks to everyone that has & will help me become a better mission editor!
  2. Currently, I have flag posts that teleport to & from each base. The base only appears when the town near it is captured by Blufor forces. The flags have scripts attached to them, and have to stay visible at all times, but the bases are only constructed once the town is captured which is what I originally wanted!
  3. So, it definitely works. I got a huge array of objects from the ObjectGrabber function & I can create them with the ObjectsMapper function. Now the problem is that I'm basically spawning in new objects. The object properties I can change in the editor have no effect on the array of objects you get from the ObjectGrabber function. I will have to toy about with a work-around in the meantime, but I thank you a lot for introducing these functions to me. I am trying to make the objects that spawn indestructible & have dynamic simulation. I'm also unable to assign init scripts or variable names to the objects.
  4. I would have no problem using Achilles for this provided we had a Zeus for this mission. I'm less worried about convenience & more concerned with bettering my scripting skills. I figure if I can do what a mod can do in a few lines of code, then it's beneficial to me learning the editor.
  5. So this seems exactly like what I was asking for, but my question is now am I able to use this with the createVehicle command? My idea is to have a trigger that, when activated, creates an instance of the custom composition I created earlier.
  6. I think the title is pretty self-explanatory, but I can provide my details if they are requested. I only need the action on playable units; not NPCs. Demonstrations would be very helpful.
  7. I need a way to bleed tickets once per second as the Bleed Tickets module does, but with the bleed amount being equivalent to the number of sectors controlled by that team. For example, if Blufor has 5 objectives while Opfor has 3, Opfor will lose 5 tickets each second while Blufor will lose 3 tickets each second. Below are a few things I have tried so far which seemed to either not work or freeze my game. I apologize if I have no clue what I'm doing. [sector_alpha, "ownerChanged", { params["_sector", "_owner", "_ownerOld"]; while { true } do { [_owner, 1] call BIS_fnc_respawnTickets; sleep 1; }; }] call BIS_fnc_addScriptedEventHandler; [sector_alpha, "ownerChanged", { params["_sector", "_owner", "_ownerOld"]; waitUntil { sleep 1; [_owner, 1] call BIS_fnc_respawnTickets; }; }] call BIS_fnc_addScriptedEventHandler;
  8. While I am no beginner at programming in general, I am relatively new to SQF scripting for Arma 3. After 1000 hours I decided to finally toy around with the scripting side of things and I've already completely broken my first script. I apologize for any mistakes I may have made in advance, I am really new to this and I need some help solving this problem. At the moment the script is executing, however, it is not displaying the kills in the chat as it should be. I am realizing more and more that the YouTube video I learned this from is very inaccurate and riddled with errors. ----------initClient.sqf---------- // Executes all client scripts remotely and globally (with restrictions to client only if set in the script itself). [] remoteExec ["killFeedClient", 0]; ----------initServer.sqf---------- // Executes all client scripts remotely and server-sided. [] remoteExec ["killFeedServer", 2]; ----------killFeedClient.sqf---------- // Creates "killFeedClient" function to be executed in "initClient.sqf." killFeedClient = { { // Adding an event handler for the "Killed" action to every unit. _x addEventHandler ["Killed", { // Initializes all of the variables used in the formatting of the kill-feed statement. _unit = (_this select 0); _killedBy = (_this select 1); // Organizing and grouping all of the variables into a single array. deathInfo = [_unitName, _killedBy]; // Creating the "killFeedUpdate" public variable event handler. publicVariableServer "killFeedUpdate"; }]; } forEach allUnits; }; ----------killFeedServer.sqf---------- // Creates "killFeedServer" function to be executed in "initServer.sqf." killFeedServer = { // Only runs this script if the machine executing it is the server. if (isServer) then { // Listens for updates from the "killFeedUpdate" public variable event handler. "killFeedUpdate" addPublicVariableEventHandler { // Initalizes "_deathInfo" private array and sets it's value from the previously mentioned event handler. private "_deathInfo"; _deathInfo = (_this select 1); // If you are confused by why we used 1 and not 0 refer to "addPublicVariableEventHandler" documentation on the wiki. // Extracts each variable from the "_deathInfo" private array. _unit = (_deathInfo select 0); _killedBy = (_deathInfo select 1); // Grabs some more data by passing the previously mentioned variables through a variety of functions. _unitName = name _unit; _killedByName = name _killedBy; _distance = _unit distance _killedBy; // Formats the kill-feed statement to be displayed in the game chat. _killFeedStatement = format ["%1 was killed by %2. (%3m)", _unitName, _killedByName, _distance]; // Displays the kill-feed statement in the game chat as if it were being called in by the killer. _killedBy globalChat _killFeedStatement; }; }; };
  9. Now before anyone says it, I realize that this forum is dedicated to Arma 3 and usually does not support any 3rd party addons, mods, plugins, etc., however, I believe that as CBA is such a big part of SQF scripting that I feel as if I need to learn to use it. I have tried to use the official CBA documentation on their GitHub, but if I am being completely honest, it is genuinely quite confusing and difficult for me to wrap my head around. I have some prior programming and scripting experience in languages such as C++, Javascript, Python, and a few others, yet this seems more complicated than anything I'm used to. I guess I should get to the point and ask my question. Is there any YouTube videos or written guides that can explain these CBA features to a beginner in both SQF and CBA? Any and all responses are greatly appreciated, as always! 😊
  10. On another note, does anyone know if there is a way to close this forum thread?
  11. Thanks, again, to Mr.H for the assistance and wonderful explanation to go along with it. I now have two completely working versions. One of which works for vanilla Arma 3 and the other of which works with the CBA/ACE mods. ----------CBA Version---------- // Only runs the following code if the machines executing it is the server. if (!isServer) exitWith {}; if (isServer) then { // Add a "killed" CBA event-handler to all units in the game. ["CAManBase", "killed", { // Telling the previously mentioned event-handler which parameters we need access to. params ["_unit", ["_killer", objNull]]; // Only use the following line of code if you are doing strictly PVP, this will remove PVE capabilities. // To enable, simply remove the /'s signifying a comment. // if !(isPlayer _unit) exitWith {}; // This sets the "_killer" variable to the last unit that damaged the target unit. // If the killer is the target itself, then the target died due to bleeding out. _killer = _unit getVariable ["ace_medical_lastDamageSource", objNull]; // Remotely executing a system chat message that will display our kill-feed statement. [[_unit, _killer], { // Grabbing our previous variables to format the kill-feed statement. params ["_unit", "_killer"]; // Initializing the "killFeedStatement" variable. _killFeedStatement = ""; // Checking whether the target unit was killed by another unit or bled out. if (_killer isEqualTo _unit) then { // Initializes a variable to contain the unit's name. _unitName = name _unit; // Formatting the kill-feed statement that displays when a unit has bled out. _killFeedStatement = format ["%1 has died of blood loss.", _unitName]; // Displays the kill-feed statement as a system chat log. systemChat _killFeedStatement; } else { // Initializing variables to be used in the formatting of the kill-feed statement. _unitName = name _unit; _killerName = name _killer; _distance = _unit distance _killer; // Formatting the regular kill-feed statement. _killFeedStatement = format ["%1 was killed by %2. [%3m]", _unitName, _killerName, _distance]; // Displays the kill-feed statement as a system chat log. systemChat _killFeedStatement; }; }] remoteExec ["Call", 0]; }] call CBA_fnc_addClassEventHandler; }; ----------Vanilla Version---------- // Only runs this script if the machine executing it is the server. if (!isServer) exitWith {}; if (isServer) then { // Whenever an entity is spawned, run the following code regardless of how it was spawned. [] spawn { while {true} do { { // Adds a multiplayer event-handler for each unidentified unit in the game. _x addMPEventHandler ["MPKilled", { // Parses input argument into array of private variables. params ["_killed", "_killer"]; // Initalizes more private variables so they can have their values defined afterwards. private ["_killedName", "_killerName", "_distance", "_killFeedStatement"]; // Grabs some more data by passing the previously mentioned parameters through a variety of functions. _killedName = name _killed; _killerName = name _killer; _distance = _killed distance _killer; // Formats the kill-feed statement differently depending on whether another unit killed the target unit or the target unit bled out. if (_killed isEqualTo _killer) then { // Formats the kill-feed statement to be displayed in the game chat when the target unit has bled out. _killFeedStatement = format ["%1 has died of blood loss.", _killedName]; } else { // Formats the regular kill-feed statement to be displayed in the game chat. _killFeedStatement = format ["%1 was killed by %2. [%3m]", _killedName, _killerName, _distance]; }; // Displays the kill-feed statement in the game chat as if it were being called in by the killer. [_killer, _killFeedStatement] remoteExec ["globalChat", 0]; }]; // Sets the "unitIdentified" variable to true, letting the loop know this unit has already been modified. _x setVariable ["unitIdentified", true]; } forEach (allUnits select {isNil {_x getVariable "unitIdentified"}}); // Sleeping 2 seconds so we don't overload the game with too many loop cycles. sleep 2; }; }; };
  12. So I incorporated what pierremgi said and it worked fine with vanilla Arma 3, however, when I added ACE and RHS it broke the script. It still displays the kill in the chat but it says that the unit being killed committed suicide (regardless of how they were killed) and the range displayed is set to zero meters for some reason. What the actual hell is going on, and how can I fix it? // Only runs this script if the machine executing it is the server. if (isServer) then { // Whenever an entity is spawned, run the following code regardless of how it was spawned. [] spawn { while {true} do { { // Adds a multiplayer event-handler for each unidentified unit in the game. _x addMPEventHandler ["MPKilled", { // Parses input argument into array of private variables. params ["_killed", "_killer"]; // Initalizes more private variables so they can have their values defined afterwards. private ["_killedName", "_killerName", "_distance", "_killFeedStatement"]; // Grabs some more data by passing the previously mentioned parameters through a variety of functions. _killedName = name _killed; _killerName = name _killer; _distance = _killed distance _killer; // Formats the kill-feed statement to be displayed in the game chat. _killFeedStatement = format ["%1 was killed by %2. (%3m)", _killedName, _killerName, _distance]; // Displays the kill-feed statement in the game chat as if it were being called in by the killer. [_killer, _killFeedStatement] remoteExec ["globalChat", 0]; }]; // Sets the "unitIdentified" variable to true, letting the loop know this unit has already been modified. _x setVariable ["unitIdentified", true]; } forEach (allUnits select {isNil {_x getVariable "unitIdentified"}}); // Sleeping 2 seconds so we don't overload the game with too many loop cycles. sleep 2; }; }; };
  13. Does this mean I could hypothetically loop over the working script I sent earlier to add the event handler to each new unit spawned by my other scripts? It already works for units placed in the editor as well as those placed by Zeus though.
  14. I got it working with the following code. Thanks for your assistance guys! Especially to Larrow! ----------initServer.sqf---------- // Only runs this script if the machine executing it is the server. if (isServer) then { // Adding a mission event-handler for the "EntityKilled" action. addMissionEventHandler ["EntityKilled", { // Parses input argument into array of private variables. params ["_killed", "_killer"]; // Initalizes more private variables so they can have their values defined afterwards. private ["_killedName", "_killerName", "_distance", "_killFeedStatement"]; // Grabs some more data by passing the previously mentioned parameters through a variety of functions. _killedName = name _killed; _killerName = name _killer; _distance = _killed distance _killer; // Formats the kill-feed statement to be displayed in the game chat. _killFeedStatement = format ["%1 was killed by %2. (%3m)", _killedName, _killerName, _distance]; // Displays the kill-feed statement in the game chat as if it were being called in by the killer. [_killer, _killFeedStatement] remoteExec ["globalChat", 0]; }]; };
  15. Doesn't this imply that it only displays kills against players? I need to use something for both editor placed and spawned AI units. It will be used for a multiplayer game, however, I do not believe there will be any JIP players. I'm just using this to track kills and spawns for the AI in a small op with friends.
×