Jump to content
Barba-negra

maximum amount of vehicle type present

Recommended Posts

hello guys, greetings, I am here exposing a small problem which I have not been able to solve, I have a script that I am trying to put together that indicates that if there is already an object of that class present on the map, do an action:

 

limit = 1;
Ship = "B_Boat_F";  

     

if ((count Ship) > limit) then {

 

hint "can't start";
 
} else { 

 

hint "starting process";

 

};

 

but it gives me error, I don't understand very well how to configure the count command, please help.

Share this post


Link to post
Share on other sites

Not sure what "B_Boat_F" is, but:

limit = 1; 
Ship = "B_Boat_Transport_01_F";   
 
if (({typeOf _x == ship} count vehicles) > limit) then { 
    hint "can't start"; 
} else {  
    hint "starting process"; 
};
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
3 minutes ago, Harzach said:

Not sure what "B_Boat_F" is, but:


limit = 1; 
Ship = "B_Boat_Transport_01_F";   
 
if (({typeOf _x == ship} count vehicles) > limit) then { 
    hint "can't start"; 
} else {  
    hint "starting process"; 
};

thanks brother i had a lot of time trying to make it work

Share this post


Link to post
Share on other sites

If you want to find all BLUFOR boats:

limit = 1; 
Ship = "Boat_F";   

if ((ship countType vehicles) > limit) then { 
    hint "can't start"; 
} else {  
    hint "starting process"; 
};

 

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, Harzach said:

Si desea encontrar todos los barcos BLUFOR:



 

Very well bro, the first one who publishes this does what I need, the second one I will keep

Share this post


Link to post
Share on other sites

If someone wants to limit spawned friendly vehicles on server, this is how I managed to do it (aka the prehistoric, cave method 😂)

//FRIENDLY VEHICLE LIMIT IN MP 
//define function properly in description.ext
class CfgFunctions
{
	class KIB
	{
		class buymenu
		{
			file = "path\to\category";
			class maxVeh
			{
			file = "function\maxveh.sqf";
			};
		};
	};
};
//in maxveh.sqf type the classnames of the vehicles the players can buy
_countRzr = {typeOf _x == "rhsusf_mrzr4_d"} count vehicles;
_countHumvee = {typeOf _x == "rhsusf_m1165a1_gmv_m134d_m240_socom_d"} count vehicles;
_countMrap = {typeOf _x == "rhsusf_m1245_m2crows_socom_d"} count vehicles;
_countTruck = {typeOf _x == "CUP_B_MTVR_USA"} count vehicles;
_countCh53 = {typeOf _x == "rhsusf_CH53E_USMC_GAU21_D"} count vehicles;
_countStrykerM2 = {typeOf _x == "CUP_B_M1126_ICV_M2_Desert"} count vehicles;
_countStrykerMK19 = {typeOf _x == "CUP_B_M1129_MC_MK19_Desert"} count vehicles;
_countStrykerMGS = {typeOf _x == "CUP_B_M1128_MGS_Desert"} count vehicles;
_countM113 = {typeOf _x == "CUP_B_M113A3_desert_USA"} count vehicles;
_countBradley = {typeOf _x == "RHS_M2A3_BUSKIII"} count vehicles;
_countAbrams = {typeOf _x == "rhsusf_m1a2sep1tuskiid_usarmy"} count vehicles;
_countMH6 = {typeOf _x == "RHS_MELB_MH6M"} count vehicles;
_countAH6 = {typeOf _x == "RHS_MELB_AH6M"} count vehicles;
_countHuey = {typeOf _x == "RHS_UH1Y_d"} count vehicles;
_countBlackWidow = {typeOf _x == "RHS_UH60M_ESSS_d"} count vehicles;
_countKnightHawk = {typeOf _x == "CFP_B_USMC_MH_60S_Knighthawk_ESSS_x2_DES_01"} count vehicles;
_countCobra = {typeOf _x == "CFP_B_USMC_AH_1Z_DES_01"} count vehicles;
_countApache = {typeOf _x == "RHS_AH64D"} count vehicles;
_countWarhog = {typeOf _x == "CUP_B_A10_DYN_USA"} count vehicles;
_countFalcon = {typeOf _x == "FIR_F16C_900830"} count vehicles;
_countHornet = {typeOf _x == "FIR_F18C_VMFA314"} count vehicles;
_countHornet2 = {typeOf _x == "FIR_F18D_VMFAAW224_02"} count vehicles;
_countEagle = {typeOf _x == "FIR_F15E_WA_17WPS"} count vehicles;
_countHarrier = {typeOf _x == "CFP_B_USMC_AV_8B_Harrier_II_DES_01"} count vehicles;
_countLightning = {typeOf _x == "CFP_B_USMC_F35B_Lightning_II_DES_01"} count vehicles;
_countTractor = {typeOf _x == "CUP_B_TowingTractor_USA"} count vehicles;
_countSpooky = {typeOf _x == "USAF_AC130U"} count vehicles;
_countAAA = {typeOf _x == "CFP_B_USARMY_M163_DES_01"} count vehicles;
_countWestVehicles = (_countRzr + _countHumvee + _countMrap + _countTruck + _countCh53 
+ _countStrykerM2 + _countStrykerMK19 +  _countStrykerMGS + _countM113 + _countBradley + _countAbrams
+ _countMH6 + _countAH6 + _countHuey + _countBlackWidow + _countKnightHawk + _countCobra + _countApache
+ _countWarhog + _countFalcon + _countHornet + _countEagle + _countHarrier + _countLightning + _countTractor
+ _countSpooky + _countAAA);
_countWestVehicles;
//use in spawn menu or whatever, 5 is max vehicle number,you can change it to fit your scenario 
_maxveh = call KIB_fnc_maxVeh;
if (_maxveh < 5) then {
//code for vehicle spawn here   
} else { hint "Vehicle limit reached!"};

If someone knows better way please share. Tested and works on dedicated.   

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

×