Jump to content
Antman2o1o

Placing player side flags on vehicles as player enters a vehicle

Recommended Posts

Hey folks, Ant here, looking for a little help... First off let me preface that I am in no way a fluent Arma  or Arma Wasteland coder but try to come up with additional ways to enhance the game... so I try and dabble in it a bit. So that being said i have an issue that maybe someone from the community could help finalize my code or point me in the right direction.

So here goes. 

 

I am trying to place a team colored flag on a vehicle, via script, per team side, for my Arma 3 Wasteland server.

As everyone knows the team side color flags are: Blufor- "Blue", Opfor - "Red", and Independent "Green"..... It might be super cool to let their clan symbol show on the flag but not necessary.  If I could get help to get the baseline flag set that would be great.

 

Reason For Flags

We tend to get a lot of first timers that have been showing up to the server, who get excited and try to kill anything that moves.....I am  trying to cut down on the team killing from lock on AT Rockets from a distance, for same side folks driving down the road. 

The side color flag would be an additional visual reference point so they don't team kill somebody who has been working so hard to gather resources and a vehicle. So in stating that I am just looking for help or for a script that when a player enters a vehicle it attaches the team side color flag to the vehicle. 

 

Does anyone have a script that would put the driver's team flag Blue, Red or Green on the vehicle once they enter the vehicle and are driving?

I tried this but this code below and it does not work at all. I may not even be in the ball park. All of the vehicles in wasteland are dynamically spawned via markers or purchases in a shop and are not placed down in the editor so need some sort of script to associate the players side faction to a colored flag that will attach to the vehicle.

 

Code 

switch(playerSide) do {
    case west: {
      #include "carFlag setFlagTexture "\A3\Data_F\Flags\Flag_blue_CO.paa"; carFlag setFlagOwner driver this;"
    }
    case east: {
        #include "carFlag setFlagTexture "\A3\Data_F\Flags\Flag_red_CO.paa"; carFlag setFlagOwner driver this;"
    }
}

 

Any ideas suggestions highly appreciated

 

Edited by Dedmen
Removed advertisement spam

Share this post


Link to post
Share on other sites

One possible way (applying EHs on vehicles)

 

Let's say you want a flag on car1

 

MGI_stdFlags = [
  ["OPF_F","\A3\Data_F\Flags\Flag_CSAT_CO.paa"],
  ["OPF_T_F","\A3\Data_F\Flags\Flag_CSAT_CO.paa"],
  ["IND_G_F","\A3\Data_F\Flags\Flag_FIA_CO.paa"],
  ["OPF_G_F","\A3\Data_F\Flags\Flag_FIA_CO.paa"],
  ["Guerilla","\A3\Data_F\Flags\Flag_FIA_CO.paa"],
  ["IND_C_F","\A3\Data_F_Exp\Flags\flag_SYND_CO.paa"],
  ["IND_F","\A3\Data_F\Flags\Flag_AAF_CO.paa"],
  ["BLU_CTRG_F","\A3\Data_F_Exp\Flags\flag_CTRG_CO.paa"],
  ["BLU_F","\A3\Data_F\Flags\Flag_nato_CO.paa"],
  ["BLU_T_F","\A3\Data_F\Flags\Flag_nato_CO.paa"],
  ["BLU_GEN_F","\A3\Data_F_Exp\Flags\flag_GEN_CO.paa"]
];
car1 addEventHandler ["GetIn", {
  params ["_veh","_role","_unit","_turret"];
  if (_role == "driver") then {
    _faction = getText (configFile >> "cfgVehicles" >> typeOf _unit >> "faction");
    _flag = "";
    _factions = MGI_stdFlags apply {_x #0};
    _flags = MGI_stdFlags apply {_x #1};
    _flagIdx = _factions findIf {faction _unit == _x};
    if (_flagIdx >-1) then {
      _flag = _flags select _flagIdx;
    } else {
      call {
        if (side _unit == WEST) exitWith {_flag = "\A3\Data_F\Flags\Flag_blue_CO.paa"};
        if (side _unit == EAST) exitWith {_flag = "\A3\Data_F\Flags\Flag_red_CO.paa"};
        if (side _unit == INDEPENDENT) exitWith {_flag = "\A3\Data_F\Flags\Flag_green_CO.paa"};
      }
    };
    _veh forceFlagTexture _flag};
 }];
car1 addEventHandler ["GetOut", {
  params ["_veh","_role","_unit","_turret"];
  if (_role == "driver") then {_veh forceFlagTexture ""};
}];

 

 

 

Share this post


Link to post
Share on other sites

Pierre, Thank you for the reply several questions.

 

1. Looks like you are defining car1 as what the code will effect for a specific named vehicle.

In Wasteland the vehicles are dynamically generated so how could you make car1 mean every vehicle?... I am not sure how you would make it work across all dynamically spawned wheeled vehicles.

In the code below this is how the vehicles are spawned/generated  in Wasteland.


A3W_smallVehicles =
[
    "C_Quadbike_01_F",
    ["B_Quadbike_01_F", "O_Quadbike_01_F", "I_Quadbike_01_F", "I_G_Quadbike_01_F"]
];

//Civilian Vehicle List - Random Spawns
civilianVehicles =
[
    "C_Hatchback_01_F",
    "C_Hatchback_01_sport_F",
    "C_SUV_01_F",
    "C_Offroad_01_F",
    ["C_Van_01_box_F", "C_Van_01_transport_F"]
];

//Light Military Vehicle List - Random Spawns
lightMilitaryVehicles =
[
    ["I_G_Offroad_01_F", "I_G_Offroad_01_armed_F"]
];

//Medium Military Vehicle List - Random Spawns
mediumMilitaryVehicles =
[
    "B_MRAP_01_F",
    "O_T_LSV_02_AT_F",
    "O_T_LSV_02_armed_F",
    "B_T_LSV_01_AT_F",
    "B_T_LSV_01_armed_F",
    "O_MRAP_02_F",
    "I_MRAP_03_F"
];

//Water Vehicles - Random Spawns
waterVehicles =
[
    "C_Boat_Civil_01_F",
    "C_Boat_Civil_01_F",
    ["C_Boat_Civil_01_police_F", "C_Boat_Civil_01_rescue_F"],
    ["B_Boat_Armed_01_minigun_F", "O_Boat_Armed_01_hmg_F", "I_Boat_Armed_01_minigun_F"]
];

//Object List - Random Spawns.
staticWeaponsList =
[
    "B_Mortar_01_F",
    "O_Mortar_01_F",
    "I_Mortar_01_F",
    "I_G_Mortar_01_F"
];

//Object List - Random Helis.
staticHeliList =
[
    "C_Heli_Light_01_civil_F",
    "B_Heli_Light_01_F",
    "O_Heli_Light_02_unarmed_F",
    "I_Heli_light_03_unarmed_F"
    // don't put cargo helicopters here, it doesn't make sense to find them in towns; they spawn in the CivHeli mission
];

//Object List - Random Planes.
staticPlaneList =
[
    "I_Plane_Fighter_03_dynamicLoadout_F"
];

A3W_planeSpawnOdds = 0.25; // 0.0 to 1.0

//Random Weapon List - Change this to what you want to spawn in cars.
vehicleWeapons =
[
    ["SMG_01_F" /*Vermin*/, "SMG_02_F" /*Sting*/, "hgun_PDW2000_F"],
    ["arifle_TRG20_F", "arifle_TRG21_F", "arifle_TRG21_GL_F"],
    ["arifle_Mk20C_F", "arifle_Mk20_F", "arifle_Mk20_GL_F"],
    ["arifle_Katiba_F", "arifle_Katiba_C_F", "arifle_Katiba_GL_F"],
    ["arifle_MXC_F", "arifle_MX_F", "arifle_MX_GL_F", "arifle_MXM_F"],
    ["srifle_EBR_F", "srifle_DMR_01_F"],
    ["arifle_MX_SW_F", "LMG_Mk200_F", "LMG_Zafir_F"]
];

vehicleAddition =
[
    "muzzle_snds_L", // 9mm
    "muzzle_snds_M", // 5.56mm
    "muzzle_snds_H", // 6.5mm
    "muzzle_snds_H_MG", // 6.5mm LMG
    "muzzle_snds_B", // 7.62mm
    "muzzle_snds_acp", // .45 ACP
    "optic_Arco",
    "optic_SOS",
    "optic_Hamr",
    "optic_Aco",
    "optic_ACO_grn",
    "optic_aco_smg",
    "optic_Holosight",
    "optic_Holosight_smg",
    "acc_flashlight",
    "acc_pointer_IR",
    "Medikit",
    "Medikit",
    "FirstAidKit",
    "ToolKit"
];

vehicleAddition2 =
[
    "Chemlight_blue",
    "Chemlight_green",
    "Chemlight_yellow",
    "Chemlight_red"
];
 

 

2. Second question would i compile this code above into an sqf and call it from the missions init.

Sorry new at coding and trying to figure this out.

 

Once again Thank You! Any insight you have is highly appreciated.

Edited by Dedmen
Removed advertisement spam

Share this post


Link to post
Share on other sites

Yes you can call the code from init.sqf. The good question is:

Is there more vehicles than possible units (or players if they are the only ones concerned)? In fact, you can apply EHs getIn/out on vehicles or EHs getInMan/getOutMan on units. that's cool if you are applying the code on players only or with few units concerned.

And this solution is probably better in your case (MP, spawned vehicles,..)

See this page.

If you can apply this behaviour on players only, so by getInMan/getOutman instead of getIn/getOut, it's simple as adding the code (or spawning an sqf if you want), in the initPlayerLocal.sqf

If some you prefer to script for vehicles.... the getIn/Out version in init.sqf (or from it) will work with a filter loop for vehicles.

 

 

Share this post


Link to post
Share on other sites

Pierre again Thank You for your reply a little lost.

 

Here is what i tried thus far with no success

 

Created Flags.sqf

with this code below

MGI_stdFlags = [
  ["OPF_F","\A3\Data_F\Flags\Flag_CSAT_CO.paa"],
  ["OPF_T_F","\A3\Data_F\Flags\Flag_CSAT_CO.paa"],
  ["IND_G_F","\A3\Data_F\Flags\Flag_FIA_CO.paa"],
  ["OPF_G_F","\A3\Data_F\Flags\Flag_FIA_CO.paa"],
  ["Guerilla","\A3\Data_F\Flags\Flag_FIA_CO.paa"],
  ["IND_C_F","\A3\Data_F_Exp\Flags\flag_SYND_CO.paa"],
  ["IND_F","\A3\Data_F\Flags\Flag_AAF_CO.paa"],
  ["BLU_CTRG_F","\A3\Data_F_Exp\Flags\flag_CTRG_CO.paa"],
  ["BLU_F","\A3\Data_F\Flags\Flag_nato_CO.paa"],
  ["BLU_T_F","\A3\Data_F\Flags\Flag_nato_CO.paa"],
  ["BLU_GEN_F","\A3\Data_F_Exp\Flags\flag_GEN_CO.paa"]
];
lightMilitaryVehicles addEventHandler ["GetInMan", {
  params ["_veh","_role","_unit","_turret"];
  if (_role == "driver") then {
    _faction = getText (configFile >> "cfgVehicles" >> typeOf _unit >> "faction");
    _flag = "";
    _factions = MGI_stdFlags apply {_x #0};
    _flags = MGI_stdFlags apply {_x #1};
    _flagIdx = _factions findIf {faction _unit == _x};
    if (_flagIdx >-1) then {
      _flag = _flags select _flagIdx;
    } else {
      call {
        if (side _unit == WEST) exitWith {_flag = "\A3\Data_F\Flags\Flag_blue_CO.paa"};
        if (side _unit == EAST) exitWith {_flag = "\A3\Data_F\Flags\Flag_red_CO.paa"};
        if (side _unit == INDEPENDENT) exitWith {_flag = "\A3\Data_F\Flags\Flag_green_CO.paa"};
      }
    };
    _veh forceFlagTexture _flag};
 }];
lightMilitaryVehicles addEventHandler ["GetOutMan", {
  params ["_veh","_role","_unit","_turret"];
  if (_role == "driver") then {_veh forceFlagTexture ""};
}];
 

I ran the code above from my init.sqf with

[] execVM "addons\scripts\flags.sqf";

 

For the instance above I am trying to effect the vehicles spawned via the wasteland code below

//Light Military Vehicle List - Random Spawns
lightMilitaryVehicles =
[
    ["I_G_Offroad_01_F", "I_G_Offroad_01_armed_F"]
];

 

I changed the code you provided from car1 to lightMilitaryVehicles to call that vehicle class.

Nothing worked thus far.

 

I even tried running the code from the initPlayerLocal.

 

Any ideas?

 

Share this post


Link to post
Share on other sites

If you read above and the link I gave you:

getIn/out EH is for vehicles

getInMan/out is for men.

 

Anyway vehicles and men are objects here, not array or classes.

You can't apply EH to what you want, you must follow the syntax. Always. See this new link also. Each word has a sense.

You didn't reply me to my question: Is there more vehicles than possible units (or players if they are the only ones concerned)?

 

So, the easiest, for players, in init.sqf:

MGI_stdFlags = [ ["OPF_F","\A3\Data_F\Flags\Flag_CSAT_CO.paa"], ["OPF_T_F","\A3\Data_F\Flags\Flag_CSAT_CO.paa"], ["IND_G_F","\A3\Data_F\Flags\Flag_FIA_CO.paa"], ["OPF_G_F","\A3\Data_F\Flags\Flag_FIA_CO.paa"], ["Guerilla","\A3\Data_F\Flags\Flag_FIA_CO.paa"], ["IND_C_F","\A3\Data_F_Exp\Flags\flag_SYND_CO.paa"], ["IND_F","\A3\Data_F\Flags\Flag_AAF_CO.paa"], ["BLU_CTRG_F","\A3\Data_F_Exp\Flags\flag_CTRG_CO.paa"], ["BLU_F","\A3\Data_F\Flags\Flag_nato_CO.paa"], ["BLU_T_F","\A3\Data_F\Flags\Flag_nato_CO.paa"], ["BLU_GEN_F","\A3\Data_F_Exp\Flags\flag_GEN_CO.paa"] ];

{

  _x addEventHandler ["GetInMan", {

    params ["_unit", "_role", "_veh", "_turret"];

    if (_role == "driver") then {

      _faction = getText (configFile >> "cfgVehicles" >> typeOf _unit >> "faction");

      _flag = "";

      _factions = MGI_stdFlags apply {_x #0};

      _flags = MGI_stdFlags apply {_x #1};

      _flagIdx = _factions findIf {faction _unit == _x};

       if (_flagIdx >-1) then { _flag = _flags select _flagIdx; } else {

        call {

          if (side _unit == WEST) exitWith {_flag = "\A3\Data_F\Flags\Flag_blue_CO.paa"};

          if (side _unit == EAST) exitWith {_flag = "\A3\Data_F\Flags\Flag_red_CO.paa"};

          if (side _unit == INDEPENDENT) exitWith {_flag = "\A3\Data_F\Flags\Flag_green_CO.paa"};

        }

      };

      _veh forceFlagTexture _flag

      };

   }];

  _x addEventHandler ["GetOutMan", {

    params ["_unit", "_role", "_veh", "_turret"];

    if (_role == "driver") then {_veh forceFlagTexture ""};

  }];

} forEach (playableUnits + switchableUnits);

 

 

 

Share this post


Link to post
Share on other sites

PIERRE, THANK YOU!!!!  YOU ARE AWESOME!!!!!  I GOT IT TO WORK!!!!! and yes I am shouting with thankful praise for you. I could of never figured this out on my own and had no idea where to start so SUPER BIG Thank You for taking time out of your day to help me. I really appreciate it.

Edited by Dedmen
Removed advertisement spam
  • Like 1

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

×