Page MenuHomeContribution Center

Method to parse loadout data to be viewed on website
Closed, ResolvedPublic

Description

Event Timeline

MajJames renamed this task from Method to export loadout data to Method to export loadout data to be viewed on website.Apr 13 2020, 5:19 PM
MajJames triaged this task as Unbreak Now! priority.
MajJames created this task.
MajJames renamed this task from Method to export loadout data to be viewed on website to Method to parse loadout data to be viewed on website.Apr 16 2020, 10:50 AM

Idea:
Build a bootstrap grid which ressembles the ARMA 3 Inventory
Export inventory textures with Textedit 2
Create a database with all inventory equipment images we need and give them the same UID as in the above picture.
Some PHP magic and we could dynamicly fill it.
Example of exported texture:

@CplPidu Very nice - the only issues that's blocking this right now is there appears to be no (simple) way of exporting the readable/friendly names of objects - only the classnames. Which is a lot of manual work for someone to do. Images are great, but I think that the names are also needed.

CplPidu added a comment.EditedMay 12 2020, 5:08 PM

@CaptJames
I see what you need, I think. Did a quick and dirty parse of some of the RHS USAF equipment, is this what your looking for?
Obviously quality needs improvement.

Click Me

I believe there could be a way to get the ingame inventory names out of the editor. Need to check that when I am home.

@CplPidu I get denied access on that link.

What I do have is a list of all classnames of items used in our loadouts, so if there was a way for example of getting those out of the game, then that would be handy. Since getting all names would be more work than needed, since we maybe use 2% of the total classnames in the game/mods.

List of used classnames would be helpful

I could provide one, I mean if it helps here is the dump from the loadouts database table

CplPidu added a comment.EditedMay 13 2020, 7:39 AM

@CaptJames
unfortunately, that CSV is a format I am not ready to deal with at this early in the day.
I however exported all equipment classes in the core, optional and approved mod sets and created a csv.
I find it amazing, eventhough I haven't tested it on completness.
Much useful information like mass, carry capacity, ammo used, etc... was able to be exported with the classname name combo. YAY!


Fields
name - IngameName
type - Item category != Slot
class name- Class name used in editor
mass - Mass of item (might equal weight)
capacity - Carrying capacity
armor (Neck/Arms/Chest/Diaphragm/Abdomen/Body)' - Hitpoints added to base hitpoints of "slot"
passthrough (Neck/Arms/Chest/Diaphragm/Abdomen/Body) - Damage reduction coefficent
mags/caliber - Compatibale mags in array

P.S.
There is a semi consitent error with À characters appearing in some of the names.
Unclear why. Once I understand why it does it and what it should be it should be easy to be batch replaced.

Added Checklist for future reference about the export process.

@CaptJames
Please advise if you would rather have armor and passthrough values in separate fields for each slot rather than an array.

@CplPidu Incredible work - I've been trying to get something like this for ages.
FYI, can't seem to get it into a logicial spreadsheet format which is what I need to get it into the database.

Also I think we only need to run RHS and ACE, since we don't specify radios in TFAR, and having less mods will mean we only have the classnames we need.

@CaptJames
Going to send you an xls file over discord.
I checked for completeness
91% of our items are correctly referenced.

There is still an issue with backpacks, TFAR and cTab.
TFAR you said we don't need.
cTab, is probably an oversight on my part as my modlist was probably to old
Going to adapt the script for backpacks

Amazing!
I will start playing with getting this into the website now.

@CaptJames

I got what you intended yesterday to work.
Be warned, I started learning php / mysql this morning, so this might be very spaghettish.

<?php
    
	// Setup connection to mySQL db. Which is the .xls I sent you yesterday.
	$mysqli = new mysqli("localhost", "root", "1234", "arsenal");
	
	// Error handler if connection to db fails
	if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
	}



	//Array of ARMA 3 classnames to be searched and their name displayed on the page
	$ids = array("launch_NLAW_F","launch_Titan_base","srifle_EBR_F","ACE_bloodIV","launch_Titan_short_F"); 
	
	//Count the number of elements in the array
	$count = count($ids);
	//Display number of elements in the array for debugging:
	//echo $count, "<br>";
	
	//Create the appropriate number of placeholders for the prepared statment bellow
	$placeholders = implode(',', array_fill(0, $count, '?'));
	//Display placeholders for debugging
	//echo $placeholders, "<br>";
	
	//Fill placholders with s for the strings the prepared statement is going to expect
	$bindStr = str_repeat('s', $count);
	//Display bindStr for debuging purposes. Expectation: a number of s's corresponding with the number of elements in our ids array
	//echo $bindStr, "<br>";

	//Prepare the statement to be executed and set parameter placholders
	$stmt = $mysqli -> prepare("SELECT name FROM tarsenal WHERE classname IN ($placeholders)");
	//Set Parameter placeholders to s's and tell the statment to replace them with the values in our ids array
	$stmt -> bind_param($bindStr, ...$ids);
	//Execute the statement
	$stmt -> execute();
	//Bind the results to $name
	$stmt -> bind_result($name);
	
	//Create a while loop which displays each fetched row. Essentially this is a while loop which runs while the statment is fetching. 
        //Ergo a while loop which runs from 0 to count of $ids
	while ($stmt->fetch()) {
     
        // $name changes on every iteration to reflect the current row
        echo $name, "<br>";
	} // End of while
	
	//Close the statement
	$stmt->close();

?>

Output as follows:

Maybe that gives you some inspiration, if you haven't found another solution yet.

If more output fields are wished, three lines must be changed.
Here an example for name, type and mass:

$stmt = $mysqli -> prepare("SELECT name, type, mass FROM tarsenal WHERE classname IN ($placeholders)");
$stmt -> bind_result($name, $type, $mass);
echo $name,"-",$type, "-", $mass, "<br>";

Output looks like this:

How did you wrap the array items with quotes? thats the thing I'm stuck on at the moment

I entered them manually in this format.
https://www.php.net/manual/en/function.fgetcsv.php
Might do the trick.
@captjames

CplPidu added a comment.EditedMay 14 2020, 4:59 PM

That might be even better:
https://www.php.net/manual/en/function.str-getcsv.php
Essentially the way I think about it:
You essentially have a CSV and want to convert that into an array.

CplPidu added a comment.EditedMay 15 2020, 2:36 PM

@CaptJames

I made code which will take a comma seperated string, removes all whitespaces and

Converts them to an array

OR

Or wraps your individual items with "".

Limitation: Individual items cannot contain spaces.

<?php
 	
	echo '<br><h3>Initial String</h3>'; // Formating
	// Initial String
	$str = "rhs_weap_m4a1_grip2, rhsusf_acc_M952V, rhsusf_acc_compm4, rhs_mag_30Rnd_556x45_M855A1_Stanag, rhsusf_acc_grip2, rhsusf_weap_glock17g4, rhsusf_mag_17Rnd_9x19_JHP, rhs_uniform_FROG01_d, ACE_elasticBandage, ACE_morphine, ACE_tourniquet, ACE_CableTie, ACE_EarPlugs, ACE_splint, ACE_personalAidKit, rhsusf_spc_Rifleman, SmokeShell, rhsusf_mag_17Rnd_9x19_JHP, rhs_mag_30Rnd_556x45_M855A1_PMAG, rhs_mag_30Rnd_556x45_M855A1_PMAG_Tracer_Red, rhs_mag_m67, rhs_mag_an_m8hc, rhsusf_assault_eagleaiii_coy, rhsusf_200rnd_556x45_mixed_box, rhsusf_mich_helmet_marpatd, ItemMap, itemRadio, ItemCompass, ItemWatch";
	// Debugging Test
	echo $str;
	
	echo '<br><h3>Whitespaces removed</h3>';// Formating
	
	// Remove all whitespace
	$stripped = str_replace(' ', '', $str);
	// Debugging Test
	echo $stripped;
	
	
	echo '<br><h3>Real array with index</h3>';// Formating
	// Convert String to Array	
	$array = explode(',',$stripped);
	// Output
	echo '<pre>'; print_r($array); echo '</pre>';

	echo '<br><h3>This is still a string</h3>';// Formating
	// Second method, which keeps the type as string
	//Create sting $newstring which holds a "	
	$newstring = '"';
	// use the append operator to reaplace all , with ","
    $newstring .= str_replace(',','","',$stripped);
	// use the append operator to add " at the end of the string
	$newstring .='"';
	// Show your work
	echo $newstring;
	
?>

MajJames closed this task as Resolved.Jul 13 2020, 12:57 PM
MajJames moved this task from Next to Done on the Mission Making (J3) board.