(When I say import loadout, I am refereing to the BIS function which puts a loadout on an entity. Not the Arsenal)
Created a script which takes the standard Arma 3 import loadout string and parses it into a format which can easily be imported into a SQL table.
It should be easily possible to export from the SQL db a loadout and parse it into a Arma 3 Import loadout, by using append and concatenate operators.
I have worked on the Export string which Arma 3 generates, but the format is weird and I am unsure if this is possible.
Output:
Code:
<?php // A sexy af script that takes Arma 3 import strings and formats them to be integrated in a mysql database. // This can be done the other way arround to facilitate loadout management. // Input String formated as Arma 3 importable loadout $str = ' class UTF_R { displayName = "00|Rifleman"; //icon = "null"; role = "AMFOR"; uniformClass = "rhs_uniform_acu_oefcp"; backpack = ""; weapons[] = { "rhs_weap_m4a1" }; linkedItems[] = { "rhsusf_iotv_ocp_Rifleman", "rhsusf_ach_helmet_ocp", "rhsusf_acc_M952V", "rhsusf_acc_compm4", "rhsusf_acc_grip2", "ItemCompass", "ItemWatch", "ItemMap" }; items[] = { "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_elasticBandage", "ACE_morphine", "ACE_morphine", "ACE_tourniquet", "ACE_tourniquet", "ACE_tourniquet", "ACE_tourniquet", "ACE_CableTie", "ACE_CableTie", "ACE_EarPlugs", "ACE_Splint", "ACE_Splint", "rhssaf_beret_green", "rhs_mag_30Rnd_556x45_M855A1_Stanag", "rhs_mag_30Rnd_556x45_M855A1_Stanag", "rhs_mag_30Rnd_556x45_M855A1_Stanag", "rhs_mag_30Rnd_556x45_M855A1_Stanag", "rhs_mag_30Rnd_556x45_M855A1_Stanag", "rhs_mag_30Rnd_556x45_M855A1_Stanag", "rhs_mag_30Rnd_556x45_M855A1_Stanag", "rhs_mag_30Rnd_556x45_M855A1_Stanag", "SmokeShell", "SmokeShell", "SmokeShell", "ACRE_PRC343" }; }; '; // Find name $findme = 'displayName = "'; $findme2 = ';'; $pos1 = stripos($str, $findme); $pos2 = stripos($str, $findme2,$pos1); $loadoutName = substr($str,($pos1 + 15 ),($pos2 - $pos1 - 16)); // Find role $findme = 'role = '; $findme2 = ';'; $pos1 = stripos($str, $findme); $pos2 = stripos($str, $findme2,$pos1); $loadoutRole = substr($str,($pos1 + 8 ),($pos2 - $pos1 - 9)); // Find uniform $findme = 'uniformClass = "'; $findme2 = ';'; $pos1 = stripos($str, $findme); $pos2 = stripos($str, $findme2,$pos1); $loadoutUniform = substr($str,($pos1 + 16 ),($pos2 - $pos1 - 17)); // Find bag $findme = 'backpack = "'; $findme2 = ';'; $pos1 = stripos($str, $findme); $pos2 = stripos($str, $findme2,$pos1); $loadoutBag = substr($str,($pos1 + 12 ),($pos2 - $pos1 - 13)); // Find weapon $findme = 'weapons[] = {'; $findme2 = ';'; $pos1 = stripos($str, $findme); $pos2 = stripos($str, $findme2,$pos1); $loadoutWeapon = substr($str,($pos1 + 18 ),($pos2 - $pos1 - 23)); // Find linkedItems $findme = 'linkedItems'; $findme2 = ';'; $pos1 = stripos($str, $findme); $pos2 = stripos($str, $findme2,$pos1); // Temp string without the " $tempStr = str_replace('"','', substr($str,($pos1 + 22 ),($pos2 - $pos1 - 23))); // preg_replace to get rid of all whitespace "like" characters $loadoutLinkedItems = preg_replace('/\s/', '', $tempStr); // Find Items $findme = 'items'; $findme2 = ';'; $pos1 = strpos($str, $findme); $pos2 = stripos($str, $findme2,$pos1); // Temp string without the " $tempStr = str_replace('"','', substr($str,($pos1 + 16 ),($pos2 - $pos1 - 17))); // preg_replace to get rid of all whitespace "like" characters $loadoutItems = preg_replace('/\s/', '', $tempStr); // Display bruh ha ha echo '<h1>String Input</h1><br>'; echo $str; echo '<h1>String Output</h1>'; echo '<br>'; echo 'Name: '. $loadoutName; echo '<br>'; echo 'Role: '. $loadoutRole; echo '<br>'; echo 'Uniform: '. $loadoutUniform; echo '<br>'; echo 'Bag: '. $loadoutBag; echo '<br>'; echo 'Weapon: '. $loadoutWeapon; echo '<br>'; echo 'Linked Items: '.$loadoutLinkedItems; echo '<br>'; echo 'Items: '.$loadoutItems; // String to Array magic by Pidu. Not optimal, but it works. For Each loop from array of values to array of values would be sexier, but ain't nobody got time for that. echo '<h1>Array Magic</h1><br>'; $arrName[0]= $loadoutName; $arrRole[0]= $loadoutRole; $arrUniform[0]= $loadoutUniform; $arrBag[0]= $loadoutBag; $arrWeapon[0]= $loadoutWeapon; $arrLinkedItems = explode(',',$loadoutLinkedItems); $arrItems = explode(',',$loadoutItems); // Even more display bruh ha ha echo '<br>'; print_r($arrName); echo '<br>'; print_r($arrRole); echo '<br>'; print_r($arrUniform); echo '<br>'; print_r($arrBag); echo '<br>'; print_r($arrWeapon); echo '<br>'; print_r($arrLinkedItems); echo '<br>'; print_r($arrItems); echo '<br>'; // Count duplicates in array and display item with quantity in a sexy array format $vals = array_count_values($arrItems); echo '<h1>Even More Array Magic! Showing Item and quantity </h1><br>'; echo '<pre>'; print_r($vals); echo '</pre>'; ?>