James Adams 3 Posted July 2, 2020 Hey Guys, I am trying to make a door knockdown script but I am stuck. I am having issues with this knockdown script (I have an add action in my init for it): https://pastebin.com/eGgN6Y85// < the animation line will be changed to I have also tried using cursorObject but the script doesn't work, but I think I will revert back to cursorObject to get more accurate a more accurate "cursor target" to find the door. I would highly appreciate any help, thank you in advance. James Share this post Link to post Share on other sites
gc8 977 Posted July 2, 2020 are you using the selection parameter for the addaction command? check "selection" in wiki: https://community.bistudio.com/wiki/addAction Share this post Link to post Share on other sites
James Adams 3 Posted July 2, 2020 this is my init: player addAction ["Knockdown Door", "knockdown.sqf"]; Share this post Link to post Share on other sites
gc8 977 Posted July 2, 2020 to kick the right door you must add that addaction to all doors of the house (via selection param). The selection is something like "door_x" where x is index for the door, starting from 1 Share this post Link to post Share on other sites
James Adams 3 Posted July 2, 2020 I see, well I want to implement this script for a multiplayer environment, so does your statement still apply for multiplayer? Share this post Link to post Share on other sites
gc8 977 Posted July 2, 2020 Just now, James Adams said: I see, well I want to implement this script for a multiplayer environment, so does your statement still apply for multiplayer? addaction is client side command so it only works on same client that created the addaction. each client needs to have their own addaction created Share this post Link to post Share on other sites
James Adams 3 Posted July 2, 2020 yes I know, but rn this is only for testing purposes, but idk why the script doesn't work is why I originally posted. Because It doesn't get to the step where the switch move even happens Share this post Link to post Share on other sites
gc8 977 Posted July 2, 2020 6 minutes ago, James Adams said: yes I know, but rn this is only for testing purposes, but idk why the script doesn't work is why I originally posted. Because It doesn't get to the step where the switch move even happens it can't work because the _door is not defined properly this: private _door = [objNull, 0]; does nothing useful Share this post Link to post Share on other sites
James Adams 3 Posted July 2, 2020 oh well I tried changing it to cursorTarget and cursor Object but with no luck, you have any idea how to redefine it Share this post Link to post Share on other sites
gc8 977 Posted July 2, 2020 did you wrote that script your self? the _door variable should be index from 1 - max doors and get rid of the "player distance _door <= 1" because that wont work Share this post Link to post Share on other sites
gc8 977 Posted July 2, 2020 also there's ; before else that has to be removed Share this post Link to post Share on other sites
James Adams 3 Posted July 2, 2020 yeah I wrote it all by myself Share this post Link to post Share on other sites
James Adams 3 Posted July 2, 2020 I removed the ; before else and what do you mean by the _door variable should be index from 1- max doors Share this post Link to post Share on other sites
gc8 977 Posted July 2, 2020 _door should be index of the door try this code (several fixes): if !(alive player) exitWith {}; private _checkLock = 0; if (cursorTarget isKindOf "house") then { _house = cursorTarget; private _door = 1; // First door _checkLock = _house getVariable [format ["bis_disabled_Door_%1", _door], 0]; if (_checkLock == 1 && !isNull cursorTarget) then { //&& [cursorTarget] call BIS_fnc_isBuildingEnterable; _house setVariable [format ["bis_disabled_Door_%1", _door], 0, true]; player playAnimation kick; [_door] call BIS_fnc_DoorOpen; } else { hint "Door is unlocked."; }; }; havent tested the code. have to go now but will come back later Share this post Link to post Share on other sites
James Adams 3 Posted July 2, 2020 14 minutes ago, gc8 said: _door should be index of the door try this code (several fixes): if !(alive player) exitWith {}; private _checkLock = 0; if (cursorTarget isKindOf "house") then { _house = cursorTarget; private _door = 1; // First door _checkLock = _house getVariable [format ["bis_disabled_Door_%1", _door], 0]; if (_checkLock == 1 && !isNull cursorTarget) then { //&& [cursorTarget] call BIS_fnc_isBuildingEnterable; _house setVariable [format ["bis_disabled_Door_%1", _door], 0, true]; player playAnimation kick; [_door] call BIS_fnc_DoorOpen; } else { hint "Door is unlocked."; }; }; havent tested the code. have to go now but will come back later Ok thank you Share this post Link to post Share on other sites
gc8 977 Posted July 2, 2020 I was bored and may need this for my self as well so I wrote the door kicking script: kickTheDoor = { params ["_plr","_bldg","_doorIndex"]; _checkLock = _bldg getVariable [format ["bis_disabled_Door_%1", _doorIndex], 0]; if(_checkLock == 1) then { // player playAnimation "kick"; player playActionNow "kick"; // Doesnt Work [_bldg,_doorIndex,0] call toggleDoorLock; // Unlock _bldg animate [format["door_%1_rot",_doorIndex], 1]; // Open } else { hint "Door is unlocked."; }; }; toggleDoorLock = { params ["_bldg","_doorIndex","_lock"]; _bldg setVariable [format["bis_disabled_Door_%1",_doorIndex], _lock, true]; }; isDoorOpen = { params ["_bldg","_doorIndex"]; (_bldg animationPhase format["door_%1_rot",_doorIndex]) == 1 }; _allbldgs = nearestObjects [player, ["house"], 200]; { _bldg = _x; _numDoors = getNumber (configfile >> "CfgVehicles" >> typeOf _bldg >> "numberOfDoors"); for "_doorIndex" from 1 to _numDoors do { _doorsel = format["Door_%1", _doorIndex]; [_bldg,_doorIndex,1] call toggleDoorLock; _bldg addAction [ "<t color='#FF0000'>Kick door</t>", // title { params ["_target", "_caller", "_actionId", "_doorIndex"]; // script [_caller,_target,_doorIndex] call kickTheDoor; }, _doorIndex, // arguments 1.5, // priority true, // showWindow true, // hideOnUse "", // shortcut format["!([_target,%1] call isDoorOpen)",_doorIndex], // condition 50, // radius false, // unconscious _doorsel, // selection "" // memoryPoint ]; }; } foreach _allbldgs; //hint format["STARTED %1", count _allbldgs]; It locks houses at 200 meter radius from the player so you can test on those It's not MP ready though. And player kick animation doesn't play for some reason 1 Share this post Link to post Share on other sites
johnnyboy 3789 Posted July 2, 2020 @James Adams, there is no command "playAnimation". To play an animation for a unit use switchMove, playMove, playAction, or playActionNow. To make these commands work in MP, you want to wrap them in a remoteExec call. 2 hours ago, gc8 said: player playActionNow "kick"; // Doesnt Work Unfortunately there is no "kick" action in the play actions. And there is no good vanilla kick animation available for switchMove/playMove to the best of my knowledge (I have searched the animations many times over the last few years). I would love to be proven wrong though, so if someone know of a kick animation please share it. You can probably find a mod with a kick animation though. You could potentially use the "rifle butt smash" animation, and pretend the unit is smashing the lock on the door. This is also an example of how to use remoteExec so the animation is played on all clients in MP. [_unit,"acts_miller_knockout"]remoteExec["switchMove",0,true]; You can see this animation in action in this video (its used to smash target unit's head). Spoiler I would love to see a good door kick script, so I wish you the best of luck! 🙂 Share this post Link to post Share on other sites
James Adams 3 Posted July 2, 2020 1 hour ago, johnnyboy said: @James Adams, there is no command "playAnimation". To play an animation for a unit use switchMove, playMove, playAction, or playActionNow. To make these commands work in MP, you want to wrap them in a remoteExec call. Unfortunately there is no "kick" action in the play actions. And there is no good vanilla kick animation available for switchMove/playMove to the best of my knowledge (I have searched the animations many times over the last few years). I would love to be proven wrong though, so if someone know of a kick animation please share it. You can probably find a mod with a kick animation though. You could potentially use the "rifle butt smash" animation, and pretend the unit is smashing the lock on the door. This is also an example of how to use remoteExec so the animation is played on all clients in MP. [_unit,"acts_miller_knockout"]remoteExec["switchMove",0,true]; You can see this animation in action in this video (its used to smash target unit's head). Reveal hidden contents I would love to see a good door kick script, so I wish you the best of luck! 🙂 thank you ! 1 Share this post Link to post Share on other sites
James Adams 3 Posted July 2, 2020 4 hours ago, gc8 said: I was bored and may need this for my self as well so I wrote the door kicking script: kickTheDoor = { params ["_plr","_bldg","_doorIndex"]; _checkLock = _bldg getVariable [format ["bis_disabled_Door_%1", _doorIndex], 0]; if(_checkLock == 1) then { // player playAnimation "kick"; player playActionNow "kick"; // Doesnt Work [_bldg,_doorIndex,0] call toggleDoorLock; // Unlock _bldg animate [format["door_%1_rot",_doorIndex], 1]; // Open } else { hint "Door is unlocked."; }; }; toggleDoorLock = { params ["_bldg","_doorIndex","_lock"]; _bldg setVariable [format["bis_disabled_Door_%1",_doorIndex], _lock, true]; }; isDoorOpen = { params ["_bldg","_doorIndex"]; (_bldg animationPhase format["door_%1_rot",_doorIndex]) == 1 }; _allbldgs = nearestObjects [player, ["house"], 200]; { _bldg = _x; _numDoors = getNumber (configfile >> "CfgVehicles" >> typeOf _bldg >> "numberOfDoors"); for "_doorIndex" from 1 to _numDoors do { _doorsel = format["Door_%1", _doorIndex]; [_bldg,_doorIndex,1] call toggleDoorLock; _bldg addAction [ "<t color='#FF0000'>Kick door</t>", // title { params ["_target", "_caller", "_actionId", "_doorIndex"]; // script [_caller,_target,_doorIndex] call kickTheDoor; }, _doorIndex, // arguments 1.5, // priority true, // showWindow true, // hideOnUse "", // shortcut format["!([_target,%1] call isDoorOpen)",_doorIndex], // condition 50, // radius false, // unconscious _doorsel, // selection "" // memoryPoint ]; }; } foreach _allbldgs; //hint format["STARTED %1", count _allbldgs]; It locks houses at 200 meter radius from the player so you can test on those It's not MP ready though. And player kick animation doesn't play for some reason thank you, yeah the kick animation thing I forgot is not actually a thing it has to "switchmove" lol Share this post Link to post Share on other sites
James Adams 3 Posted July 2, 2020 4 hours ago, gc8 said: I was bored and may need this for my self as well so I wrote the door kicking script: kickTheDoor = { params ["_plr","_bldg","_doorIndex"]; _checkLock = _bldg getVariable [format ["bis_disabled_Door_%1", _doorIndex], 0]; if(_checkLock == 1) then { // player playAnimation "kick"; player playActionNow "kick"; // Doesnt Work [_bldg,_doorIndex,0] call toggleDoorLock; // Unlock _bldg animate [format["door_%1_rot",_doorIndex], 1]; // Open } else { hint "Door is unlocked."; }; }; toggleDoorLock = { params ["_bldg","_doorIndex","_lock"]; _bldg setVariable [format["bis_disabled_Door_%1",_doorIndex], _lock, true]; }; isDoorOpen = { params ["_bldg","_doorIndex"]; (_bldg animationPhase format["door_%1_rot",_doorIndex]) == 1 }; _allbldgs = nearestObjects [player, ["house"], 200]; { _bldg = _x; _numDoors = getNumber (configfile >> "CfgVehicles" >> typeOf _bldg >> "numberOfDoors"); for "_doorIndex" from 1 to _numDoors do { _doorsel = format["Door_%1", _doorIndex]; [_bldg,_doorIndex,1] call toggleDoorLock; _bldg addAction [ "<t color='#FF0000'>Kick door</t>", // title { params ["_target", "_caller", "_actionId", "_doorIndex"]; // script [_caller,_target,_doorIndex] call kickTheDoor; }, _doorIndex, // arguments 1.5, // priority true, // showWindow true, // hideOnUse "", // shortcut format["!([_target,%1] call isDoorOpen)",_doorIndex], // condition 50, // radius false, // unconscious _doorsel, // selection "" // memoryPoint ]; }; } foreach _allbldgs; //hint format["STARTED %1", count _allbldgs]; It locks houses at 200 meter radius from the player so you can test on those It's not MP ready though. And player kick animation doesn't play for some reason yeah I would like to have a MP ready one and have that add action on the player, I saw that getCursorObjectParams could work here, because I would like to have it universal for this script to work for any door Share this post Link to post Share on other sites
gc8 977 Posted July 2, 2020 4 minutes ago, James Adams said: yeah I would like to have a MP ready one and have that add action on the player, I saw that getCursorObjectParams could work here, because I would like to have it universal for this script to work for any door Haven't tested it in MP but it might just work, no promises! 🙂 i think the addaction has to be on the house because the "selection" parameter is used. This should work in every door unless I am mistaken Share this post Link to post Share on other sites
James Adams 3 Posted July 2, 2020 Just now, gc8 said: Haven't tested it in MP but it might just work, no promises! 🙂 i think the addaction has to be in the house because the "selection" parameter is used. This should work in every door unless I am mistaken Yes but I would like to have it universal for any door without triggers nothing for the player addAction, here is a video: Idk this id modded but its just as an example the script itself can be used for vanilla here just not the animation Share this post Link to post Share on other sites
gc8 977 Posted July 2, 2020 21 minutes ago, James Adams said: Yes but I would like to have it universal for any door without triggers nothing for the player addAction, here is a video: Idk this id modded but its just as an example the script itself can be used for vanilla here just not the animation Why not just download the mod? Share this post Link to post Share on other sites
James Adams 3 Posted July 2, 2020 1 minute ago, gc8 said: Why not just download the mod? Its not open to the public, so I can't learn from how they wrote their script Share this post Link to post Share on other sites
gc8 977 Posted July 2, 2020 8 minutes ago, James Adams said: Its not open to the public, so I can't learn from how they wrote their script well can't really help you then. I prefer simpler scripts like the one I posted 🙂 Share this post Link to post Share on other sites