---Reworked for support ticket 0013924 -- Original code looked like it was meant to run in an event. -- Or author thought UNITX was available in SA's for whatever reason, maybe it was at some point in past? -- Reworked to be compatiable with at least CMO 112x.x forward. and to account for possible fuel type change. -- Should also work on relatively recent cmano builds spring 2019+. local function RefuelAllTanksByClassStringMatch(theSide,MatchingString) local s = VP_GetSide({side=theSide}) --get the side if(s~=nil) then -- sanity check we have valid side object. --Now get all ships, though with B1147.2 foward you could do this far more specifically and shorten the search. --But we'll leave it the old school way so it works on older builds as well for now. local shiplist = s:unitsBy('Ship'); local fuel; local u; for k,v in ipairs(shiplist) do --loop through all ships. u = ScenEdit_GetUnit({guid=v.guid}); -- get the unit. if ((u ~= nil) and u.type ~= 'Group') then --()make sure nil check goes first. --now we do the original code. if string.match(u.classname,MatchingString) then --test the string match. fuel = u.fuel; for i,j in pairs(fuel) do -- run through them all avoid error on a gas type change in db. fuel[i].current = fuel[i].max; u.fuel = fuel print(string.format('MDK Refueling Script Used: refueled %s',tostring(u.name))); end end end u=nil; fuel = nil; --release the old data before next iteration to ensure nil checking state. end else ScenEdit_MsgBox('The script could not obtain the side object with string ' .. tostring(theSide) .. '\r\nPlease pass this error on to the author.',1); ScenEdit_SetSpecialAction({ActionNameOrID="Refuel MDK",IsActive=true}); -- don't charge the user. end end RefuelAllTanksByClassStringMatch("WP","MDK")