Jump to content
Sign in to follow this  
Fuzzy Bandit

Would this Score-Adding technique work?

Recommended Posts

I'm looking to add a certain amount of points to a variety of units upon activating certain parts of a script.

Things to know:

  • 'fcp' is a global variable defined in the 'init.sqf' of the mission. This holds the value of how many points to add to the unit. For simplicity, we'll say that fcp = 5.
  • 'additarea' is a pre-defined variable created in the 'init.sqf' of the mission. It is created by using the code:
    additarea = "waiting";


init.sqf

fcp = 5;
additarea = "waiting";

"additarea" addPublicVariableEventHandler {{_x addScore fcp;} forEach additarea;};

us.sqf

(A player-executed, local script)

additarea = "(playerSide == "WEST") && (player distance flag1 <5)";
publicVariable "additarea";

Would that then make it so that on activation of 'us.sqf', 5 points would be added to anybody on BLUFOR who is standing within 5m of the object named 'flag1'?

If not, why not? And how would it be achieved?

Edited by Fuzzy Bandit

Share this post


Link to post
Share on other sites

Not entirely sure what you are trying to do here, but to add 5 points to whoever is within 5m I would make a script kind of like this (untested):

if (isServer) then {
_objects = (getPos flag1) nearObjects ["Man",5];
_blu = [];
{
if (side _x == WEST) then {_blu = _blu + [_x]};
} forEach _objects;
{_x addScore fcp} forEach _blu;
};

As I said this is untested and it wont work if people are in vehicles, if you want it to work with people in vehicles you will have to modify it a fair bit.

Edited by Andy455

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  

×