Jump to content
Sign in to follow this  
acsriot

Help with Recruit Script - Need to limit execution

Recommended Posts

Hey guys, quick question, I'm making a custom mission where the player needs to have the ability to quickly pull a AI squad, I have constructed this script to allow him to do so.

"B_soldier_F" createUnit [getmarkerpos "hire", group player]; 
"B_soldier_F" createUnit [getmarkerpos "hire", group player]; 
"B_soldier_F" createUnit [getmarkerpos "hire", group player]; 
"B_soldier_repair_F" createUnit [getmarkerpos "hire", group player]; 
"B_medic_F" createUnit [getmarkerpos "hire", group player]; 

w/ This is the "Recruiters" init line

this addAction ["Recruit Fanboi", {_this execVM "rec.sqf"}] ;

That all works fine, But i'm worried when I get out of the development stage there is nothing to stop players from just spamming that action key. I was wondering if there is a way to use a If/Then statement to set somthing like "This script can only be executed every X number of seconds"

Any ideas?

Share this post


Link to post
Share on other sites

you could do it by time or have a "max units" setting, but that would take more scripting and testing than I would like to do at the moment. the time one however is easy :)

rec.sqf

_recruiter = _this select 0;
_id = _this select 2;
_timelimit = 10; //number of seconds you want to wait before the action comes back up

removeaction _id;

"B_soldier_F" createUnit [getmarkerpos "hire", group player]; 
"B_soldier_F" createUnit [getmarkerpos "hire", group player]; 
"B_soldier_F" createUnit [getmarkerpos "hire", group player]; 
"B_soldier_repair_F" createUnit [getmarkerpos "hire", group player]; 
"B_medic_F" createUnit [getmarkerpos "hire", group player];

sleep _timelimit;

_recruiter addaction ["Recruit Fanboi","rec.sqf"];

I didnt test this, but I think itll work!

also you might want to make the recruiter invincible so that frustrated people dont just shoot him and therefore make the action no longer usable

Share this post


Link to post
Share on other sites

not working sadly, says that the _recuriter is not defined =/

Share this post


Link to post
Share on other sites

Try something similar to what I've written below. This would limit both the time in between recruiting, and the amount of times a player can recruit. Look into using addAction and removeAction within the script.

rec.sqf

_max = 10;
_cur = 0;

if (_cur > _max) then {
   //removeAction
   "B_soldier_F" createUnit [getmarkerpos "hire", group player]; 
   "B_soldier_F" createUnit [getmarkerpos "hire", group player]; 
   "B_soldier_F" createUnit [getmarkerpos "hire", group player]; 
   "B_soldier_repair_F" createUnit [getmarkerpos "hire", group player]; 
   "B_medic_F" createUnit [getmarkerpos "hire", group player];
   _cur = _cur + 1;
   sleep 10;
   //addAction
} else {
   hint "You have reached the recruitment limit.";
};

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  

×