player2_dz

Untitled

Oct 28th, 2014
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. fnc_p2CountStaticVehicles = {
  2.     private["_vehCount","_list","_charId"];
  3.     _vehCount = 0; //start with 0
  4.  
  5.     _list = ([0,0,0]) nearEntities [[_this], 25000]; //for each vehicle that already exists (within 25000m) with input classname (_this)
  6.     {
  7.         _vehCount = _vehCount + 1;  //add 1 to vehicle count
  8.  
  9.         _charId = (_x getVariable ["CharacterID", 0]); //check if this vehicle was purchased using char id
  10.         if (typeName _charId == typeName "") then {
  11.             _charId = parseNumber _charId;  //if charId is a string, convert it to a number
  12.         };
  13.         if (_charId > 0) then {
  14.             _vehCount = _vehCount - 1;  //if charId greater than 0, vehicle was purchased, take the 1 away from the vehicle count
  15.         };
  16.        
  17.     } forEach _list; //end of for each vehicle that already exits
  18.  
  19.     //return the amount of vehicles it counted
  20.     _vehCount
  21. };
  22.  
  23. //call the function using Ka52 as input, store result as _result
  24. _result = "Ka52Black" call fnc_p2CountStaticVehicles;
  25. //output result to logs
  26. diag_log str _result;
  27.  
  28. //In log we see: "1", as there is 1 Ka52Black on the map that is not trader purchased
Advertisement
Add Comment
Please, Sign In to add comment