Jump to content

dreadedentity

Member
  • Content Count

    1224
  • Joined

  • Last visited

  • Medals

Everything posted by dreadedentity

  1. It depends, if you are using an editor-placed vehicle + soldiers, or created from script. Here is the wiki page for moveInCargo. So from that page you can see that the structure of the command is unit moveInCargo vehicle so if you put down a vehicle in the editor and give it a variable name then put down a unit and put this in it's init: this moveInCargo myVehicle //replace myVehicle with the variable name you gave the vehicle or if you created the objects from a script using createVehicle: _soldier = createVehicle [etc...]; _vehicle = createVehicle [etc...]; _soldier moveInCargo _vehicle; Look at moveInCargo#See_Also and you will also see other commands like moveInDriver, moveInCommander, etc By the way, this command will move the unit into the vehicle instantly. If you want the unit to run up to the vehicle and "get in" like if you used the get in option in the action menu there is a different process. See AI Group Vehicle Management for an overview. The vehicle must be added to the "group" before AI can ever interact with it. Then the unit must be given (assigned) a role in the vehicle. After that, order the unit to get in the vehicle. Look at assignAsCargo#See_Also for commands to assign other roles to the AI. You may also have to allow units to get in before they are able to. I think this is default to true for new groups, but if you disallow it then you must re-allow before they are able to get in again. To get the units to exit the vehicle, there is doGetOut, but I've found that this is pretty slow as the units will exit the vehicle one by one. A much better command in my opinion is moveOut. You will also need to orderGetIn with false, otherwise they will just get back in the vehicle That should get you started in the right direction
  2. dreadedentity

    [Release] Liberation RX

    Awesome! So I can just buy some more AI when I come back on. Also, I'm assuming that once you win, it will start over if you start the server again?
  3. dreadedentity

    [Release] Liberation RX

    Been playing for a few hours and I think it's a very cool mission. I wish AI would scale based on number of players, since I am alone I am stuck with 1 squad of 4 (3 AI). I gotta close the game and get some sleep for work tomorrow, is there a way to save progress? I'd like to come back to this and play more now that I've started to get the hang of it, but it wouldn't be great to have to restart every time
  4. dreadedentity

    unit has string in name

    You can use name, but this might not be how you want to do this, because you will need to set up an Identity in Description.ext
  5. I tried it by naming a random soldier ra1 and pasted this in his init and I'm not getting any script errors. But I'm not on a server, and don't have CfgSounds set up. Just in case, delete that from the Init of the soldier and try pasting it again: ra1 addAction [ "On" , { _globalSoundSource = missionNamespace getVariable ["CURRENT_SOUND", objNull]; if (!(_globalSoundSource isEqualTo objNull)) then { deleteVehicle _globalSoundSource; }; [ra1, "Audioger", 50, 1] remoteExec ["playSoundGlobal", [0, -2] select isDedicated]; }];
  6. dreadedentity

    Making a script for multiple objects

    This is the way. After 2-3 solid years of arma scripting, hundreds of posts in this forum helping people, and numerous edits to the wiki, I still haven't even tackled MP scripting 😀
  7. dreadedentity

    Making a script for multiple objects

    As @7erra said you have many syntax errors. The sqf engine expects commands in a specific format and when it doesn't get them like it expects then it starts saying error error. Here are the pages for select, forEach, call, and addAction. I think it would be a good idea for you to take a look at those pages to match the syntax used on the wiki and to get familiar with looking at the wiki, in general. Many of us from this forum also spend a lot of time making edits and tweaks to it, making it the best it can be The reason you got the generic error in expression is because you have an extra comma at the end of your list right before the closing square bracket
  8. MP is not really my thing, but I did some reading and this might be able to work in MP. I think you will need to create init.sqf because remoteExec requires a function to work. So we need init.sqf just to hold the function we need to create. Make a file named "init.sqf" in the same folder with Description.ext. Then put this inside: init.sqf: playSoundGlobal = { CURRENT_SOUND = (_this select 0) say3D (_this select [2,3]); }; Now in the addAction replace this with what's below it: CURRENT_SOUND = ra1 say3D [ "Audioger", 50, 1]; //replace with: [ra1, "Audioger", 50, 1] remoteExec ["playSoundGlobal", [0, -2] select isDedicated]; What this hopes to do is broadcast the say3D command so all players will hear it. DeleteVehicle already has a global effect so we don't need to do anything I hope this works because if it doesn't I can't really help figure it out
  9. This is my fault, I keep forgetting that in sqf when you have If you need Then. So, a small fix to the code I posted before: if (!(_globalSoundSource isEqualTo objNull)) then { //then goes just before the code block deleteVehicle _globalSoundSource; };
  10. Feel free to make some edits
  11. For me, the main benefit is that getVariable can return a default value if the variable is nil so you can do a 1-line If statement, plus won't throw error for undefined variable: if (missionNamespace getVariable ["myInt", 42] < 100) then { //do something }; //vs myInt = //some value if (myInt < 100) then { //I think would throw error if it didn't exist also //etc. But there are 2 other reasons as well: They don't know about this They like to do a lot of typing I'm pretty sure this also works with other namespaces if you switch contexts using the with command: with profileNamespace do { DE_Greeting = "DreadedEntity was here"; saveProfileNamespace; }; hintSilent (profileNamespace getVariable "DE_Greeting"); So in a way, you can think about missionNamespace being the "default" namespace, at least I do
  12. Sure, if you save the sound source from say3D in a global variable, then you just need to add a check if it exists then delete it before starting a new sound. Then you can have as many songs as you like. For the "OFF" action, just do the same thing, but don't play a new sound ra1 addAction [ "On" , { _globalSoundSource = missionNamespace getVariable ["CURRENT_SOUND", objNull]; if (!(_globalSoundSource isEqualTo objNull)) { deleteVehicle _globalSoundSource; }; CURRENT_SOUND = ra1 say3D [ "Audioger", 50, 1]; } ];
  13. If it's a global variable then you can just use it without needing to pass any parameter. This is the exact reason why you shouldn't make too heavy use of them. myGlobalVariable = "Hello World"; [] spawn { sleep 2; hintSilent myGlobalVariable; }; Fun fact, missionNamespace setVariable ["myGlobalVariable", "Hello World"]; myGlobalVariable = "Hello World"; Are the same thing, or I suppose it's more accurate to say "a global variable is a missionNamespace variable" Proof: missionNamespace setVariable ["myGlobalVariable", "Hello hint"]; myGlobalVariable2 = "Hello systemChat"; [] spawn { sleep 2; hintSilent myGlobalVariable; systemChat (missionNamespace getVariable "myGlobalVariable2"); };
  14. Yeah I don't mind, it reminds me of when I was making a system pretty much exactly like this years ago. I do wish you would make a github repo so I can download the mission and try it myself though
  15. Anything is possible. You can stop a sound by deleting the sound object that is returned by say3D: _soundSource = player say3D ["mySound1", 100]; _soundSource spawn {sleep 2; deleteVehicle _this;}; You should probably start by getting some sounds in Description.ext by using CfgSounds After that, with a little clever scripting and a few addAction's, you should have what you're looking for
  16. I think the documentation is saying that it will return the value literally if no value is found, try finding your x,y,z coordinates and manually fill out the array (replace the 0's): ["read", ["Player Location", "Location", [0,0,0]]] call _inidbi; Give this a try, I think this might be the break you need
  17. You should make a github account, I'd love to look this script over and see if I can help
  18. I think maybe I see the issue here: _gear = (_this select 1); _location = [_this select 0, _this select 1, _this select 2]; In the public variable event handler, you have to use _this select 1 to get the value of the variable: "loadData" addPublicVariableEventHandler { _loadDataValue = _this select 1; //take the whole value and store it in a variable, value is [_gear, _location] _gear = _loadDataValue select 0; //select the first element of the array to get gear, alternatively could use ((_this select 1) select 0) _location = _loadDataValue select 1; //select second element, alternatively could use ((_this select 1) select 1) player setUnitLoadout _gear; player setPosATL _location; };
  19. Try: hintSilent str variable; or systemChat str variable; before your get to the line where the error is, that should give you some insight as to what's going on
  20. dreadedentity

    [HELP] - SC logic fails after X time

    Thanks, I try to be helpful! Not a problem, we wouldn't answer questions here if it bothered us 😀 To be honest, I feel like I never truly mastered MP scripting, so I can't say with certainty but I believe the game gives you a new unit when you respawn, instead of re-using the previous unit. Someone might have to answer that for me. Regardless, it would be far easier to replace the true with alive _unit in the while loop to make the old script die off when the player dies, and just leave the script adding on respawn You're still doing some copy-pasting. The only thing that seems to be changing is this 1 line of code, so that's all you would need to do a switch on: while {_sectorSelected getVariable "owner" == west} do { while {_sectorSelected getVariable "owner" == east} do { while {_sectorSelected getVariable "owner" == independent} do { Would be something like this: params ["_unit"]; sleep 1; _sectorsArray = [sectornum_1, sectornum_2, sectornum_3, sectornum_4, sectornum_5, sectornum_6]; while {true} do { _sectorSelected = _sectorsArray call BIS_fnc_selectRandom; switch (side _unit) do { case west: { while {_sectorSelected getVariable "owner" == west} do { _sectorSelected = _sectorsArray call BIS_fnc_selectRandom; }; }; case east: { while {_sectorSelected getVariable "owner" == east} do { _sectorSelected = _sectorsArray call BIS_fnc_selectRandom; }; }; case independent: { while {_sectorSelected getVariable "owner" == independent} do { _sectorSelected = _sectorsArray call BIS_fnc_selectRandom; }; }; }; _sectorLoc = getPos _sectorSelected; _unit doMove _sectorLoc; waitUntil {unitReady _unit}; // ToDo Sector owner check sleep 30; }; Now hold on, we still have some repeated code, and yes, we can even get rid of that too: params ["_unit"]; sleep 1; _sectorsArray = [sectornum_1, sectornum_2, sectornum_3, sectornum_4, sectornum_5, sectornum_6]; while {alive _unit} do { //loop only runs while unit is alive, when it dies the script will end after it gets to sleep 30; _sectorSelected = _sectorsArray call BIS_fnc_selectRandom; _unitSide = side _unit; //maybe not a huge issue but cache the value so arma doesn't have to get it over and over while {_sectorSelected getVariable "owner" == _unitSide} do { _sectorSelected = _sectorsArray call BIS_fnc_selectRandom; }; _sectorLoc = getPos _sectorSelected; _unit doMove _sectorLoc; waitUntil {unitReady _unit}; // ToDo Sector owner check sleep 30; }; Turns out we didn't need a switch after all!
  21. dreadedentity

    [HELP] - SC logic fails after X time

    Happy to help, as always ExecVM and spawn both will return a Script Handle object. Then you can terminate it: _script1 = [] spawn {}; systemChat str _script1; _script2 = [] execVM "myScript.sqf"; systemChat str _script2; { terminate _x; } foreach [_script1, _script2]; Also no, the script is not attached to the unit in any way so it would keep running
  22. After reading your response and reflecting further, I see in getData.sqf that you read the gear and location, I see that you set gear into the public variable, I do not see where you included location in the public variable. Maybe you meant it to be more like this: _gear = ["read", ["Player Gear", "Gear", []]] call _inidbi; _location = ["read", ["Player Location", "Location", []]] call _inidbi; loadData = [_gear, _location]; _clientID publicVariableClient "loadData"; If so, then your public variable event handler could be like this: "loadData" addPublicVariableEventHandler { _input = _this select 1; _gear = _input select 0; _location = _input select 1; player setUnitLoadout _gear; player setPosATL _location; }; //but could be even shorter: "loadData" addPublicVariableEventHandler { _input = _this select 1; player setUnitLoadout (_input select 0); player setPosATL (_input select 1); };
  23. dreadedentity

    [HELP] - SC logic fails after X time

    What is an SC mission? That line you wrote a comment about definitely is a problem. It looks like it just recursively calls itself so as soon as 1 unit respawns, you will start creating hundreds of runs of unitMoveWest. ExecVM runs in a scheduled environment so what happens is you end up with hundreds of scripts all waiting for their turn to run. I'm kind of interested to see what would happen if this was a scheduled environment. Ah, I figured out what you were trying to do while I was typing out something else heheh. You want to select another array element if it is side west. Why not: _sectorSelected = _sectorsArray call BIS_fnc_selectRandom; while {_sectorSelected getVariable "owner" == west} do { _sectorSelected = _sectorsArray call BIS_fnc_selectRandom; }; _sectorLoc = getPos _sectorSelected; That should take care of the issue I think; but you have more code, so, as long as it's here, I'd like to offer some critiques and improvements to it as well: then {_unit execVM "unitMoveWest.sqf"}; then {_unit execVM "unitMoveEast.sqf"}; then {_unit execVM "unitMoveIndi.sqf"}; "unitMoveWest.sqf" "unitMoveEast.sqf" "unitMoveIndi.sqf" I am seeing this and instantly smelling copy-pasted code. The naming scheme alone implies that this should be a parameter of 1 script, instead of just 3 different scripts. Unless unitMove.sqf is doing more than just switching which script gets run, it would make much more sense to just remove it entirely and directly run a different script. The best part is that you can even move the side check into the script since you are passing the unit: //the copy-pasted code, etc switch (side _this) do { case west: { }; case east: { }; case independent: { }; default { }; } I think you should combine the 3 scripts into just 1 and then you can use a switch for side-specific logic as seen above _targetSector_1 = sectornum_1; _targetSector_2 = sectornum_2; _targetSector_3 = sectornum_3; _targetSector_4 = sectornum_4; _targetSector_5 = sectornum_5; _targetSector_6 = sectornum_6; _sectorsArray = [_targetSector_1, _targetSector_2, _targetSector_3, _targetSector_4, _targetSector_5, _targetSector_6]; _sectorSelected = _sectorsArray call BIS_fnc_selectRandom; // ^ this is all noise //why not: _sectorsArray = [sectornum_1, sectornum_2, sectornum_3, sectornum_4, sectornum_5, sectornum_6]; _sectorSelected = _sectorsArray call BIS_fnc_selectRandom; //And if you only use _sectorsArray 1 time maybe just get rid of that too: _sectorSelected = [sectornum_1, sectornum_2, sectornum_3, sectornum_4, sectornum_5, sectornum_6] call BIS_fnc_selectRandom; If you only use a variable 1 time and have no intention of expanding on it that will require you to use it more than once, I see very little value in bothering to save it as a variable _unit doMove _sectorLoc; waitUntil {unitReady _unit}; // ToDo Sector owner check sleep 30; _unit execVM "unitMoveWest.sqf"; I think you are now familiar with why many people don't like recursion and how it can easily cause issues so what if we make this not recursive by combining it with the first bit of code from this post: while {true} do { _sectorSelected = _sectorsArray call BIS_fnc_selectRandom; while {_sectorSelected getVariable "owner" == west} do { _sectorSelected = _sectorsArray call BIS_fnc_selectRandom; }; _sectorLoc = getPos _sectorSelected; _unit doMove _sectorLoc; waitUntil {unitReady _unit}; // ToDo Sector owner check sleep 30; }; Hope that helps
  24. As the error states, your issue lies in the "loadData" public variable event handler. Take another look at the addPublicVariableEventHandler page and see what "_this select 0" refers to. This is the name of the variable attached to the event handler, which is a string, and is exactly the error stated. I think when setting _location, you meant to select from _gear instead of _this and it should be something like: "loadData" addPublicVariableEventHandler { _gear = (_this select 1); _location = [_gear select 0, _gear select 1, _gear select 2]; player setUnitLoadout _gear; player setPosATL [_location select 0, _location select 1, _location select 2]; }; }; As a side note, as long as you are selected from an array, there is no need to do this kind of stuff: ...etc _location = [_gear select 0, _gear select 1, _gear select 2]; ... player setPosATL [_location select 0, _location select 1, _location select 2]; etc... Instead you can simply do this: _location = _gear select ?????; player setPosATL _location; EDIT: forgot to mention, if you are having issues like this, since there is no debugger it is incredibly useful to put this at the beginning of your functions: systemChat str _this;
×