Results 1 to 4 of 4

Thread: How do I detect when someone has fired a weapon?

  1. #1

    How do I detect when someone has fired a weapon?

    I am trying to figure out how to set it so once blufor fires one bullet they are no longer set captive and will be shot at by OPFOR. I tried finding Xeno's script in domination

    if (isNil "d_with_carrier") then {
    __pSetVar ["d_p_f_b", 0];

    XKickPlayerBaseFired = {
    if !(serverCommandAvailable "#shutdown") then {
    if (player in (list d_player_base_trig)) then {
    if ((_this select 4) isKindOf "TimeBombCore") then {
    _no = nearestObject [player, (_this select 4)];
    if (!isNull _no) then {deleteVehicle _no};
    if (d_kick_base_satchel == 0) then {
    ["d_p_f_b_k", [player, name player,1]] call XNetCallEvent;
    } else {
    ["d_p_bs", [player, name player,1]] call XNetCallEvent;
    };
    } else {
    if (!d_there_are_enemies_atbase) then {
    _num = __pGetVar(d_p_f_b);
    _num = _num + 1;
    __pSetVar ["d_p_f_b", _num];
    if !(player in (list d_player_base_trig2)) then {
    if (d_player_kick_shootingbase != 1000) then {
    if (_num >= d_player_kick_shootingbase) then {
    ["d_p_f_b_k", [player, name player,0]] call XNetCallEvent;
    };
    } else {
    if (_num >= d_player_kick_shootingbase) then {
    ["d_p_bs", [player, name player,0]] call XNetCallEvent;
    };
    };
    };
    };
    };
    } else {
    __pSetVar ["d_p_f_b", 0];
    };
    };
    };



    is all I found? Can someone help me please

  2. #2
    I have a single player mission where the player is captive. If they get a weapon and fire it, they lose their captivity status. A simple event handler does it:
    Code:
    _ehFiredDude = Dude addEventHandler["Fired",{_this execVM "scripts\fired.sqf";}];
    I have various checks in the fired.sqf script, but the main thing is to 'setCaptive false' on the firing unit.

    If you're doing this in multiplayer, I'm not sure if it works the same or not.

  3. #3
    Quote Originally Posted by AZCoder View Post
    I have a single player mission where the player is captive. If they get a weapon and fire it, they lose their captivity status. A simple event handler does it:
    Code:
    _ehFiredDude = Dude addEventHandler["Fired",{_this execVM "scripts\fired.sqf";}];
    I have various checks in the fired.sqf script, but the main thing is to 'setCaptive false' on the firing unit.

    If you're doing this in multiplayer, I'm not sure if it works the same or not.
    can you post the fired.sqf script?


    this may be all you need to make it MP compatible addMPEventHandler instead of just addEventHandler

  4. #4
    The MP behaviour of event handlers (as well as the passed arguments) can be found here. So, to answer that question, the fired EH's code will be executed globally.

    Note: The effects of setCaptive are also global anyway, so as long as the setCaptive code is executed locally to the unit in question it will work in MP. Of course using a fired EH you don't have to worry about that since it will be executed everywhere.

    An example:
    Code:
    this addEventHandler ["fired",{(_this select 0) setCaptive false}]
    VBS2 Designer

    Quote Originally Posted by Armored_Sheep View Post
    I like to call Arma a sandbox game that works pretty much like LEGO - you buy it not just because you want to have a nice car from the main picture on its box, do you?

Posting Permissions

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