It's been so long I've completely lost my original train of thought (happy 100-day anniversary!) but just looking at the last line in my last post, I think there's a clue here:
Oh yeah, and another issue, you're checking global.weapon_upgrades_obtained[c], but you should check global.weapon_upgrades_obtained[c][d] because upgrade level is per-upgrade now instead of shared for the entire weapon. (You'll need to move this check into the loop over array_length(ups) as well)
I.e. if the loop fails because you don't set d, it's probably actually a symptom that you still only loop over one variable (you need to loop over all weapons, and then inside that loop, have another loop that loops over all the upgrades defined for that weapon).
(In case you're wondering about the names, I always name my first loop counter c because then I get to write "c++" for the increment statement and I find that funny. And then for subsequent inner loops I use d, e, f and so on because I ran out of programming languages and it's easier just cycling through all letters)