Default resources - Contributing

From Multi Theft Auto: Wiki
Revision as of 10:37, 2 July 2024 by Fernando187 (talk | contribs)
Jump to navigation Jump to search

Work in Progress - Welcome to the mtasa-resources project! We appreciate your interest in contributing to the development and improvement of the Default Lua resources that come with the Multi Theft Auto (MTA) multiplayer mod. To ensure high-quality code and a smooth collaboration process, please adhere to the following coding guidelines and contributing rules.

Coding Guidelines

General Principles

Indentation and Formatting

Ensure your code editor (e.g. Visual Studio Code) applies the rules established by the project's .editorconfig file.

Script Security

Follow the Script security principles established for MTA:SA scripts to ensure the safety and integrity of your code.

Performance Considerations

  • Avoid unnecessary computations within loops.
  • Cache results of expensive operations whenever possible.
  • Use local variables to improve performance.

Early Return

To improve code readability, prefer using early returns to handle error conditions or special cases at the beginning of functions. This helps to avoid deep nesting and makes the main logic easier to follow.

-- Bad example
function exampleFunction(value)
    if value > 0 then
        -- Some logic here
        if value < 100 then
            -- More logic here
            if value ~= 50 then
                -- Main logic here
            end
        end
    end
end

-- Good example
function exampleFunction(value)
    if value <= 0 then return end
    if value >= 100 then return end
    if value == 50 then return end
    
    -- Main logic here
end

Error Handling

TODO

Consistent Naming Conventions

TODO

Use of Constants

TODO

Contributing Rules

Submitting Issues

  • Check the existing issues before submitting a new one to avoid duplicates.
  • Provide a clear and descriptive title and detailed information about the issue.
  • Include steps to reproduce the issue, if applicable.

Submitting Pull Requests

  • Fork the repository and create a new branch for your feature or bug fix.
  • Ensure your code follows the coding guidelines outlined above.
  • Commit small, atomic changes with clear commit messages.
  • Include a clear and descriptive title and description of your changes.
  • Reference any related issues in your pull request description.
  • Ensure your code does not introduce new issues or break existing functionality.
  • Be responsive to feedback and make necessary changes requested during the review process.

Review Process

  • All pull requests will be reviewed by project maintainers.
  • Feedback and requests for changes will be provided through the pull request comments.
  • Once approved, your pull request will be merged into the main branch.