So i trying to make a team restricted system but the issue is how can i check if the player enters the vehicle without have to checking each team car because most the tutorials i see they want you to check every single vehicle hence leading to me doing unecessary work.. Now how can i check is the player enter a scar they will be kicked if thats not there team without have to keep on repeating codes
PHP код:
new scar[20];
//the vehicles
scar[0] = CreateVehicle(470, 2159.5352, -2279.8655, 13.1922, 222.9741, 141, 141, 100);
scar[1] = CreateVehicle(470, 2166.4790, -2273.0449, 13.1922, 224.5838, 141, 141, 100);
scar[2] = CreateVehicle(470, 2174.0854, -2265.6936, 13.1922, 224.5838, 141, 141, 100);
scar[3] = CreateVehicle(470, 2237.4893, -2247.7917, 13.2978, 45.3764, 141, 141, 100);
scar[4] = CreateVehicle(470, 2229.9790, -2255.5784, 13.2978, 45.3764, 141, 141, 100);
scar[5] = CreateVehicle(470, 2222.5234, -2263.2002, 13.2978, 45.3764, 141, 141, 100);
scar[6] = CreateVehicle(470, 2215.3928, -2270.1643, 13.2978, 45.3764, 141, 141, 100);
scar[7] = CreateVehicle(470, 2207.9883, -2277.5627, 13.2978, 45.3764, 141, 141, 100);
scar[8] = CreateVehicle(490, 2196.7639, -2291.2129, 13.6616, 15.1807, 141, 141, 100);
scar[9] = CreateVehicle(490, 2193.0151, -2295.0708, 13.6616, 15.1807, 141, 141, 100);
scar[10] = CreateVehicle(447, 2176.6189, -2317.9644, 13.6553, 316.7903, 141, 141, 100);
scar[11] = CreateVehicle(447, 2161.3711, -2322.8254, 13.6553, 316.7903, 141, 141, 100);
scar[12] = CreateVehicle(490, 2189.3809, -2298.6301, 13.6616, 15.1807, 141, 141, 100);
scar[13] = CreateVehicle(427, 2209.8640, -2214.1687, 13.5594, 222.1982, 141, 141, 100);
scar[14] = CreateVehicle(427, 2203.3384, -2220.5500, 13.5594, 222.7510, 141, 141, 100);
scar[15] = CreateVehicle(497, 2173.8083, -2331.8704, 13.7229, 316.2585,141,141, 100); // solmav 1
scar[16] = CreateVehicle(497, 2245.7532, -2235.8982, 13.7237, 46.3665,141,141, 100); // solmav 2
scar[17] = CreateVehicle(599, 2185.7170, -2302.8308, 13.7379, 14.6924,141,141, 100); // solran 1
scar[18] = CreateVehicle(599, 2182.4343, -2306.8252, 13.7396, 8.7646,141,141, 100); // solran 2
scar[19] = CreateVehicle(599, 2193.9944, -2310.3535, 14.3117, 133.8432,141,141, 100); // solran 3
scar[20] = CreateVehicle(599, 2153.3682, -2289.0161, 13.5583, 222.1449,141,141, 100); // solran 4
You can use SetVehicleParamsForPlayer for all forbidden vehicles when the player chooses team to lock the vehicle, instead of everytime the player tries to enter a vehicle.
Other than that, to my knowledge; the only way to really do this without checking all of the vehicles is to distinguish unique features that the team vehicles have. This will really depend on how your gamemode is running.
For instance, if only team one can use vehicle model ID 400, then you could use GetVehicleModel to detect whether they are entering a forbidden vehicle and eject them.
Alternatively, you could also possibly use SetVehicleParamsEx to assign a unique feature then use GetVehicleParamsEx to check what team the vehicle belongs to. [For example, the alarm parameter could be used for team one, whislt the objective parameter could be used for team two] I wouldn't really recommend this though as it could cause conflict if you are using these functions for other purposes.
now since you have already have that scar[MAX_SCAR] if that's how that variable is made, I'll go with my idea of how it's made
this can be improved with much more security if you want so that not even a hacker can move this cars