Jump to content
Sign in to follow this  
snkman

How to limit actions?

Recommended Posts

Hey Guy's,

i'm working on a First Aid script which is unlimited.

Players can do first aid every time, when they are damaged > 0.6 or !canStand.

What do i have to do to limit the usage of the first aid so maybee every player can use it only 3 - 5 times?

Share this post


Link to post
Share on other sites

Need a short script that checks a variable that contains the unit's name.  If the public variable is less than lets say 3 the player is allowed to heal.  Each time he heals the variable is incremented by 1 and the variable is made public with the publicVariable command.

When I get more time later I can write something for you if you like - it would be in sqf though smile_o.gif, I can try and it convert it though.

Share this post


Link to post
Share on other sites

Hey norrin smile_o.gif

Yes this would be very helpful

Thank's a lot thumbs-up.gif

Share this post


Link to post
Share on other sites

I've been thinking about this more and you'd probably need to run a loop on the clients PC that creates an action that allows the unit to heal himself and then keeps track of the number of heals a unit has performed.  Once the limit has been reached the loop would end.  It'd be a bit like a very simplified version of my revive script, would this be OK?

A second question is would you want the heal counter to reset to zero every time a player died, ie. so he gets 3 new heals when he respawns, or would you want it to be 3 heals in total per mission?

Share this post


Link to post
Share on other sites

Yes sounds good norrin. wink_o.gif

Didn't think about that... hmm... i think 3 after each Respawn would be very nice. smile_o.gif

B.t.w. will this then also work if i use your Revive script?

Share this post


Link to post
Share on other sites

M8, here's the script: heal_player

Its set up to only work for players at the moment ie. playable AI will not heal themselves (I could set this up if you wanted but it may take a little longer to code).

Just copy across the code from the init.sqf file and copy the heal_sqf folder into your mission directory.  

Just two other bits of info you should know (1) you'll need to update the player_units variable on line 10 of the init.sqf with the names of the units you wish to use this script (they'll need to be in "") and (2) you can set the number of heals each player gets per spawn on line 12 of the init.sqf.

I must warn you I haven't done a lot of testing on this but it seems to be working well.

I don't see why this wouldn't work with my revive script, it'd mean running an extra loop which may put an extra strain on client cpu resources though.  It may be better to incorporate this code into my revive script.  If you do use it with my revive script keep in mind both scripts use the players_units variable.

By the way in the accompanying mission I've got the AI disabled in the description.ext.  If you want to try it out just run the mission that's in the zip file and shoot your team mate in the legs.  They'll then get the option to heal etc etc.

Good luck. smile_o.gif

Share this post


Link to post
Share on other sites

Hey norrin,

Thank's for the script but you exaggerated it a little bit. smile_o.gif

Only think i wanted to know was how i could do this so only a few lines of code which includes the variable and the remove 1 after 1 first aid pack was used would be enough.

But anyway now i got a complete script biggrin_o.gif

Thank you very much for all the work you made. Pretty nice thumbs-up.gif

About the Revive script: Yes i tested it and i saw this First aid ( Revive ) pretty nice.

So if i use mine toghetter with your revive there should be enough chancses to heal yourself. smile_o.gif

So thank's again norrin

Share this post


Link to post
Share on other sites

Yeah I know I got a bit carried away. smile_o.gif It was really nice to work on something other than my revive script for a change though and I could use my revive as a template of sorts so it ended up being a lot easier for me than I first thought.

Just a couple of other things about the new script are: you don't need to define the player_units variable in the init.sqf as the script doesn't use this array so just delete this line if you like - it was carry over from a slightly different version; and if you are injured in a vehicle you'll need to dismount to get the heal action to appear.

Share this post


Link to post
Share on other sites

@SNK I've been thinking about this a bit, its a good idea and it maybe of use to other mission makers. So do you mind if I/you publicise it a bit more and give the script its own thread describing how it works in detail?

Share this post


Link to post
Share on other sites

Dr SNKMAN’s Incredible Snake Oil Elixir

Cures what ails ya!

I’ve been busy making a couple of missions that use my scripts and have discovered my heal script isn’t exactly compatible with my revive script so I’ve tweaked it and now the two scripts are fully compatible.

I’ve also changed how it works a little as it will now only become available if the players damage is between 0.2 and 0.8. I’ve done this so that the medic’s role is still essential as only he can cure very bad injuries and the player can only heal the lighter ones.

ie. see line 41 of the player_heal.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if(_c == 0 && getDammage player > 0.2 && getDammage player < 0.8 && _no_heals_remaining > 0) then

You can change this range to whatever you like though, for instance, if you want the heal script to still heal all injuries (excluding death of course) then set the code up like this.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if(_c == 0 && getDammage player > 0.2 && getDammage player < 1.0 && _no_heals_remaining > 0) then

You can get the new version here

EDIT: I've been thinking more about this and there is still some overlap between the two scripts. If you want to use the two scripts (ie revive and heal) together just copy the heal_sqf folder into your mission directory

Add the <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> //Number of heals that each player gets during a mission

no_of_heals = 1; lines to the revive init.sqf file

And add the <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> //Initialise heal script for each player

call {[player, no_of_heals] execVM "heal_sqf\player_heal.sqf"}; to the onConnect script in the revive_sqf folder

When I get a new version of the revive script released I'll post a version that has both the heal and revive scripts combined.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×