multitheftauto / mtasa-resources

This project maintains a list of up-to-date resources that come with Multi Theft Auto.
https://multitheftauto.com
MIT License
151 stars 151 forks source link

editor: Make interior world models removable #345

Closed Zangomangu closed 2 years ago

Zangomangu commented 3 years ago

Currently you can't remove interior world models in the editor.

In the below snippet from editor_main interior is always 0.

function onWorldObjectCreateOrDestroy ( )
    if ( getElementType ( source ) == "removeWorldObject" ) then
        local model = getElementData ( source, "model" )
        local lodModel = getElementData ( source, "lodModel" )
        local posX = getElementData ( source, "posX" )
        local posY = getElementData ( source, "posY" )
        local posZ = getElementData ( source, "posZ" )
        local interior = getElementData ( source, "interior" )
        local radius = getElementData ( source, "radius" )
        if ( eventName == "onElementCreate" ) then
            removeWorldModel ( model, radius, posX, posY, posZ, interior )
            removeWorldModel ( lodModel, radius, posX, posY, posZ, interior )
        else
            restoreWorldModel ( model, radius, posX, posY, posZ, interior )
            restoreWorldModel ( lodModel, radius, posX, posY, posZ, interior )
        end
    end
end

This PR saves the interior in element data like model, position, radius.

Secondly, certain duplicated models in interior 13 also appear in the outside world, like the train station in SF, so these couldnt be removed. Now -1 is used instead of 0 to apply the removal across all interiors.

Zangomangu commented 3 years ago

Updated the PR to use -1 instead of 0 when removing world models outside interiors, edited description

Zangomangu commented 3 years ago

Anyone able to test & merge?