Results 1 to 2 of 2

Thread: Would this Score-Adding technique work?

  1. #1

    Would this Score-Adding technique work?

    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:
      Code:
      additarea = "waiting";


    init.sqf
    Code:
    fcp = 5;
    additarea = "waiting";
     
    "additarea" addPublicVariableEventHandler {{_x addScore fcp;} forEach additarea;};

    us.sqf
    (A player-executed, local script)
    Code:
    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?
    Last edited by Fuzzy Bandit; May 17 2010 at 11:40.

  2. #2
    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):
    Code:
    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.
    Last edited by Andy455; May 17 2010 at 12:28.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •