giving ammo to a gun based off a random array chosen weapon

Im running IFa3 on my server and ive got the AI groups being created with mod weapons, unfortunately they spawned in with no ammo. Looking through the A3 Wiki i found the 'if' statements and based off the SetAmmo command 'example 3' (as below) i had a go at creating the bottom code
Code: [Select]
if (local vehicle player) then {
vehicle player setAmmo [currentWeapon vehicle player, 5];
} else {
hint "Vehicle must be local to this machine for 'setAmmo' to work";
};

I grabbed the code and tried to modify it so it grabs the current weapon and gives the appropriate ammo class.
What im wanting to know is, how does my attempt look? and will it necessarily work? as its my first attempt at actually writing code..its the "if (currentWeapon _soldier = LIB_P38) then " part and below
Code: [Select]
// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
// @file Name: createRandomSoldierC.sqf

if (!isServer) exitWith {};

private ["_soldierTypes", "_weaponTypes", "_group", "_position", "_soldier"];

_soldierTypes = ["LIB_US_rifleman", "LIB_US_FC_rifleman", "LIB_US_smgunner", "LIB_SOV_rifleman", "LIB_SOV_LC_rifleman","LIB_SOV_scout_smgunner", "LIB_GER_rifleman", "LIB_GER_ober_rifleman", "LIB_GER_mgunner"];
_weaponTypes = ["LIB_P38","LIB_MP40","LIB_K98","LIB_G43","LIB_TT33","LIB_M9130","LIB_M1895","LIB_PPSh41_m","lib_f1","LIB_M1A1_Thompson","LIB_M1_Carbine","LIB_M1_Garand","LIB_Colt_M1911","LIB_US_Mk_2"];
_group = _this select 0;
_position = _this select 1;
_soldier = _group createUnit [_soldierTypes call BIS_fnc_selectRandom, _position, [], 0, "NONE"];
[_soldier, _weaponTypes call BIS_fnc_selectRandom, 3] call BIS_fnc_addWeapon;

//if (currentWeapon _soldier = LIB_P38) then setAmmo [LIB_8Rnd_9x19 _solder, 10];

if (currentWeapon _soldier = LIB_P38) then
{
_solder setAmmo [LIB_8Rnd_9x19 _solder, 5];
}
else if (currentWeapon _soldier = LIB_MP40) then
{
_solder setAmmo [LIB_32rnd_9x19 _solder, 5];
{
else if (currentWeapon _soldier = LIB_K98) then
{
_solder setAmmo [LIB_5Rnd_792x57 _solder, 5];
};
/* // Unsure about this & disabled
switch (_condition) do
{
case 1: {if (currentWeapon _soldier = LIB_P38) then setAmmo [LIB_8Rnd_9x19 _solder, 10]};
case 2: {if (currentWeapon _soldier = LIB_MP40) then setAmmo [LIB_32rnd_9x19 _solder, 10]};
}
*/
_soldier call setMissionSkill;

_soldier addEventHandler ["Killed", server_playerDied];

_soldier

Re: giving ammo to a gun based off a random array chosen weapon

« Reply #1 posted: Jul 22, 2021, 04:12 PM »
Solved this problem?

Re: giving ammo to a gun based off a random array chosen weapon

« Reply #2 posted: Jul 22, 2021, 11:27 PM »
Solved this problem?
yes just lastnight before crashing to bed