So today I was playing around with Kylania's Self Heal script (Source) and found it a pain in the rear to setup, so... I decided I'd use the same sort of approach but make it trigger when injured, shows up red and run from the init because well why not?
/* INIT SECTION */ // For initial spawn.
player addAction ["<t color='#FF0000'>Heal Self</t>", "healSelf.sqf", [], 1, false, true,"","getdammage player > 0"];
// After respawning.
while {true} do {
waitUntil {!alive player};
waitUntil {alive player};
player addAction ["<t color='#FF0000'>Heal Self</t>", "healSelf.sqf", [], 1, false, true,"","getdammage player > 0"];
};
Now the next fun part,
/* healSelf.sqf == create a .sqf and keep it with the mission.sqm file, you can move it just remember to link to it (i.e. scripts\healSelf.sqf) */
And the simplest, saving respawn as well: player allowDamage false; (where you want).
Tried doing that but did not work for me, however I do not even use those sqf files as I run mine completely different (independent scripts initialised by init so I can remove/use them individually when making a new mission) but hey whatever works, works. As for allowDamage false, what's the fun of not being able to shoot someone's legs, let them heal and do it all over again?
It adds the action back on respawn, and it actually waits until the animation is successful to heal the player.
Sometimes I like to think as I started the whole "earplugs" thing.
W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.
am I person:Tried doing that but did not work for me
This code works 100%. The question is: how do you use it? If you don't follow the post, you'll fail.
am I person:independent scripts initialised by init so I can remove/use them individually when making a new mission
The problem is (almost) the same! This script will run if correctly spawned (not called).
But, as you're in MP (respawning is for MP), you should think about the fact a init.sqf runs every time a player joins + 1 time for server. That means, if you don't take care, you can run several times your scripts.
Did you try your addAction on a server? How many action menu for how many players?
This post was edited by Pierre MGI (2016-02-16 16:58, ago)
PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS
654wak654, that's quite a useful idea/trick, I'll have to give it a go later with my testing buddy.
UPDATE: Got your 'wait till anim finished' working, ripped apart the script for it to work how I wanted
Pierre MGI, I only had 2 players in the server to test and no issue was present, however, once I get 3 in then we will try to break it to get multiple action menus. As with initPlayerLocal.sqf and onPlayerRespawn.sqf, do you have the init setup to load these like this
Yes initplayerLocal and onPlayerRespawn.sqf are event scripts like init.sqf.
They run when needed at initialization or respawn. Very useful in MP.
onPlayerRespawn is fired in SP as well (I don't know why), but be sure these scripts work fine (for everyone in Arma3)!
And Yep, sorry, I didn't mention the OA context!
PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS
You could use one of the .sqs scripts, but I'd recommend sticking with good ol' fashion event handlers.
Irony is, I never figured out event handlers back in Arma 2 .
Sometimes I like to think as I started the whole "earplugs" thing.
W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.