[Help] hackerbox

istealth

Well-Known Member
i got this code from http://opendayz.net/index.php?threads/hacker-boxes-medical-box.7349/page-2#post-15693

but it was in a .fsm format and i just wanted it into a sqf file

Code:
//hackerbox
    [] spawn
    {
    while {true} do
    {
    _boxes = nearestObjects [_x, [""MedBox0"", ""AmmoBoxBig"", ""USBasicWeapons_EP1"", ""USBasicAmmunitionBox_EP1"", ""UNBasicWeapons_EP1"", ""UNBasicAmmunitionBox_EP1"", ""USLaunchers_EP1"", ""USVehicleBox_EP1"", ""USSpecialWeapons_EP1"", ""LocalBasicAmmunitionBox"", ""Gunrack2"", ""Gunrack1"", ""RULaunchersBox"", ""RUBasicWeaponsBox"", ""RUBasicAmmunitionBox"", ""LocalBasicWeaponsBox"", ""RUSpecialWeaponsBox"", ""USBasicWeaponsBox"", ""USVehicleBox"", ""RUVehicleBox"", ""USSpecialWeaponsBox"", ""SpecialWeaponsBox"", ""USLaunchersBox"", ""TKVehicleBox_EP1"", ""TKSpecialWeapons_EP1"", ""TKOrdnanceBox_EP1"", ""TKLaunchers_EP1"", ""TKBasicWeapons_EP1"", ""TKBasicAmmunitionBox_EP1"", ""GunrackUS_EP1"", ""GunrackTK_EP1"", ""GuerillaCacheBox_EP1"", ""GERBasicWeapons_EP1"", ""CZBasicWeapons_EP1"", ""AmmoCrates_NoInteractive_Small"", ""AmmoCrates_NoInteractive_Medium"", ""AmmoCrate_NoInteractive_"", ""GuerillaCacheBox"", ""USBasicAmmunitionBox"", ""USOrdnanceBox_EP1"", ""RUOrdnanceBox"", ""AmmoBoxSmall_556"", ""AmmoBoxSmall_762"", ""ItemMatchbox"", ""ItemToolbox"", ""CardBoardBox"", ""FoodBox1"", ""FoodBox2"",""FoodBox3""], 50];"
    {
          _box = _x;
          _weap =  getWeaponCargo _box;
          _players_nearby = _box nearEntities [AllPlayers, 50];
          if (str(_weap) != '[[],[]]') then {
          diag_log(""Hacker Box - "" + str(_players_nearby));
          {
          diag_log(""Hacker Box - "" + str(_box distance _x) + "" - "" + str(_x));
          } forEach _players_nearby;
          deleteVehicle _box;
          diag_log (""Hacker Box - Weapons list is "" + str(_weap));
          diag_log(""Hacker Box - Deleting hacker box"");
          };
          } forEach _boxes;
    };

was wondering if anyone could help out why this isnt working
 
the code looks all wrong from a quick glance.

_x isn't defined right off the bat but yet your calling a nearestObjects on _x with a radius of 50 for the boxes. so instantly you have the problem of no boxes. So your foreach code never runs.
 
because the fsm has more code before hand, the fsm has a player array predefined in the global vars, plus it runs a foreach loop on the player array which is where _x is defined.
 
Formatted it and added a missing bracket:
Code:
//hackerbox
[] spawn
{
  while {true} do
  {
    _boxes = nearestObjects [_x, ["MedBox0", "AmmoBoxBig", "USBasicWeapons_EP1", "USBasicAmmunitionBox_EP1", "UNBasicWeapons_EP1", "UNBasicAmmunitionBox_EP1", "USLaunchers_EP1", "USVehicleBox_EP1", "USSpecialWeapons_EP1", "LocalBasicAmmunitionBox", "Gunrack2", "Gunrack1", "RULaunchersBox", "RUBasicWeaponsBox", "RUBasicAmmunitionBox", "LocalBasicWeaponsBox", "RUSpecialWeaponsBox", "USBasicWeaponsBox", "USVehicleBox", "RUVehicleBox", "USSpecialWeaponsBox", "SpecialWeaponsBox", "USLaunchersBox", "TKVehicleBox_EP1", "TKSpecialWeapons_EP1", "TKOrdnanceBox_EP1", "TKLaunchers_EP1", "TKBasicWeapons_EP1", "TKBasicAmmunitionBox_EP1", "GunrackUS_EP1", "GunrackTK_EP1", "GuerillaCacheBox_EP1", "GERBasicWeapons_EP1", "CZBasicWeapons_EP1", "AmmoCrates_NoInteractive_Small", "AmmoCrates_NoInteractive_Medium", "AmmoCrate_NoInteractive_", "GuerillaCacheBox", "USBasicAmmunitionBox", "USOrdnanceBox_EP1", "RUOrdnanceBox", "AmmoBoxSmall_556", "AmmoBoxSmall_762", "ItemMatchbox", "ItemToolbox", "CardBoardBox", "FoodBox1", "FoodBox2","FoodBox3"], 50];
    {
      _box = _x;
      _weap =  getWeaponCargo _box;
      _players_nearby = _box nearEntities [AllPlayers, 50];
     
      if (str(_weap) != '[[],[]]') then
      {
        diag_log("Hacker Box - " + str(_players_nearby));
        {
          diag_log("Hacker Box - " + str(_box distance _x) + " - " + str(_x));
        } forEach _players_nearby;
        deleteVehicle _box;
        diag_log ("Hacker Box - Weapons list is " + str(_weap));
        diag_log("Hacker Box - Deleting hacker box");
      };
    } forEach _boxes;
  };
};
 
Formatted it and added a missing bracket:
Code:
//hackerbox
[] spawn
{
  while {true} do
  {
    _boxes = nearestObjects [_x, ["MedBox0", "AmmoBoxBig", "USBasicWeapons_EP1", "USBasicAmmunitionBox_EP1", "UNBasicWeapons_EP1", "UNBasicAmmunitionBox_EP1", "USLaunchers_EP1", "USVehicleBox_EP1", "USSpecialWeapons_EP1", "LocalBasicAmmunitionBox", "Gunrack2", "Gunrack1", "RULaunchersBox", "RUBasicWeaponsBox", "RUBasicAmmunitionBox", "LocalBasicWeaponsBox", "RUSpecialWeaponsBox", "USBasicWeaponsBox", "USVehicleBox", "RUVehicleBox", "USSpecialWeaponsBox", "SpecialWeaponsBox", "USLaunchersBox", "TKVehicleBox_EP1", "TKSpecialWeapons_EP1", "TKOrdnanceBox_EP1", "TKLaunchers_EP1", "TKBasicWeapons_EP1", "TKBasicAmmunitionBox_EP1", "GunrackUS_EP1", "GunrackTK_EP1", "GuerillaCacheBox_EP1", "GERBasicWeapons_EP1", "CZBasicWeapons_EP1", "AmmoCrates_NoInteractive_Small", "AmmoCrates_NoInteractive_Medium", "AmmoCrate_NoInteractive_", "GuerillaCacheBox", "USBasicAmmunitionBox", "USOrdnanceBox_EP1", "RUOrdnanceBox", "AmmoBoxSmall_556", "AmmoBoxSmall_762", "ItemMatchbox", "ItemToolbox", "CardBoardBox", "FoodBox1", "FoodBox2","FoodBox3"], 50];
    {
      _box = _x;
      _weap =  getWeaponCargo _box;
      _players_nearby = _box nearEntities [AllPlayers, 50];
   
      if (str(_weap) != '[[],[]]') then
      {
        diag_log("Hacker Box - " + str(_players_nearby));
        {
          diag_log("Hacker Box - " + str(_box distance _x) + " - " + str(_x));
        } forEach _players_nearby;
        deleteVehicle _box;
        diag_log ("Hacker Box - Weapons list is " + str(_weap));
        diag_log("Hacker Box - Deleting hacker box");
      };
    } forEach _boxes;
  };
};
thanks for posting but i tried it did not work
 
you guys are still forgeting that _x = null the whole way through this statement, so the foreach never runs...
 
I really don't understand why u don't just leave it in the server cleanup fsm file.
It is already if checking allUnits and defining _x for u, when it does a simple hacker check.

U are duplicating very workload slighty, by getting the server to retrieve allUnits twice...
Once in sqf & again in the fsm file.
But that is just my opinion

---------------------------

{
insert crap
} forEach allUnits;
 
because i couldnt make it send out a message in globalchat that there is a possible hacker box and i can do that in an sqf
 
Back
Top