Mike4010 0 Posted December 17, 2017 Hey guys, so once again my noobie scripting skills make me fail miserably. What i want to achieve is if i press the button 5 (on the numpad) i want the cursorTarget (a player) to get knocked down and after 5 seconds i want him to get back up. It works all well except the 5 seconds delay. I have this in my init.sqf: waituntil {!(IsNull (findDisplay 46))}; _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", {if (_this select 1 == 76) then { dude = cursorTarget; dude switchMove "AinjPpneMstpSnonWrflDnon"; sleep 5; dude playMove "AmovPercMstpSnonWnonDnon";}}]; When i run this it returns a generic error message, the cursorTarget gets "knocked down" and right back up. Also i want to ask how to bind that code to a button combination? (Shift + F for example) And would this whole thing work in multiplayer as well? If not, what would i have to change? Excuse my pathetic problems, still quite new to scripting. Thank you in advance! Share this post Link to post Share on other sites
pierremgi 4890 Posted December 17, 2017 You need to spawn your code to create a "scheduled" scope allowing suspensions like waitUntil or sleep. The inner code becomes: { if (_this select 1 == 76 && cursorTarget isKindOf "CAManBase") then { cursorTarget spawn { _dude = _this; _dude switchMove "AinjPpneMstpSnonWrflDnon"; sleep 5; _dude playMove "AmovPercMstpSnonWnonDnon" }; } } Share this post Link to post Share on other sites