ramon_dexter 14 Posted March 22, 2015 Hello, I'm trying to create self-healing command, hidden under condition. Something like: if player has medpack in backpack, show 'heal self' in action menu. I made up something like If (player hasWeapon "Medkit") then {player addAction [" heal self", {player setDamage 0;}]} But it dont work. No error message, just dont work. How can I make it work? Share this post Link to post Share on other sites
Jona33 51 Posted March 22, 2015 "Medikit", not "Medkit" if I remember correctly. Share this post Link to post Share on other sites
killzone_kid 1331 Posted March 22, 2015 That is because Medikit is an item [color="#FF8040"][color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#7A7A7A"]"Medikit"[/color] [color="#191970"][b]in[/b][/color] [color="#191970"][b]items[/b][/color] [color="#000000"]player[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#000000"]player[/color] [color="#191970"][b]addAction[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"Heal Self"[/color][color="#8B3E2F"][b],[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#000000"]player[/color] [color="#191970"][b]setDamage[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color] Made with KK's SQF to BBCode Converter Share this post Link to post Share on other sites
demonized 20 Posted March 22, 2015 just make use of the condition parameter in addAction: this addAction ["Heal self", "(_this select 1) setDammage 0", nil, 6, true, true, "", [color="#FF0000"]"(getDammage _target) != 0 AND _this == _target AND 'Medikit' in (items _this)"[/color]]; Share this post Link to post Share on other sites
ramon_dexter 14 Posted March 22, 2015 (edited) Thank you, Demonized, that works like a charm. Will it work, if I put it in init line? edit: One more thing. I want to make a "repair" script, like "player has to repair a device. He needs to have toolkit/etc." I made up something like: this addAction ["Repair device", "<make something>", nil, 6, true, true, "", "'Item_ToolKit' in (items dex)"]; the code is put into init line of the device object where "this" is the device. "dex" is name of player. But this don't work. Even if player has toolkit in inventory, the option doesn't show up. What am I doing wrong? Edited March 22, 2015 by ramon_dexter Share this post Link to post Share on other sites
demonized 20 Posted March 22, 2015 wrong classname for toolkit.. "ToolKit" Share this post Link to post Share on other sites
ramon_dexter 14 Posted March 23, 2015 Well, one more question: How do I remove the medikit after it is "used"? Share this post Link to post Share on other sites
Schatten 289 Posted March 23, 2015 https://community.bistudio.com/wiki/removeItem Share this post Link to post Share on other sites
ramon_dexter 14 Posted March 24, 2015 Yes, thank you Schatten, I found it out myself. Now it works like a charm. I will advance it further to add some new features. ---------- Post added at 07:54 ---------- Previous post was at 06:18 ---------- Well, I have another question: I want to make a hazard zone. When player enter the zone, he will receive a small amount of damage every one second. How can I make it? I know how to deal damagae after a time period, but continual damage? Share this post Link to post Share on other sites
demonized 20 Posted March 24, 2015 Easy way: repeatedly trigger. Anyone present. { _x setDammage 0.1; } foreach (units thisList); Where you can change amount of damage and the time on trigger. Will damage alle units inside trigger x amount / seconds. ---------- Post added at 11:20 AM ---------- Previous post was at 11:15 AM ---------- Can also use a if statement to determin if unit is in a vehicle or not inside the foreach statement. if (vehicle _x == _x) then {_x setDammage 0.1}; Share this post Link to post Share on other sites
ramon_dexter 14 Posted March 24, 2015 This don't work. I don't know what's wrong in this code, but if I do it the simpliest way > player setDamage 0.1, it is working. But not over a time, the trigger fires everytime player character enters the trigger radius, when set "repeatedly". When set "once", it fires only once per mission. When I put in your code, it don't do anything. And also, I think that command setDammage sets the damage variable, not adds to a pool. So if its set to 0.1, it sets 0.1 value everytime it is triggered, so I think that the code has to add damage, rather than setting it. Share this post Link to post Share on other sites
demonized 20 Posted March 24, 2015 youre absolutely right, my bad, was at work writing with phone, and obviously not focused :) try this place a global variable in init.sqf: zone1 = true; place a trigger with anyone present, repeatedly. in condition place: zone1 and this on activation: {_x setDammage (getDammage _x + 0.1)} foreach units thisList; zone1 = false; on deactivation: zone1 = true; Share this post Link to post Share on other sites
ramon_dexter 14 Posted March 25, 2015 Thank you, will try when I return from work ;) Share this post Link to post Share on other sites