mtasa-blue
mtasa-blue copied to clipboard
Global variable and default value for resource names
Description
This pull request creates a global variable named resourceName, which always contains the name of the current resource, and sets the current resource as the default value to the function getResourceName, so if it is not defined as an argument, it is based on that, like in case of other similar functions. Closes #2927.
Example
addEventHandler("onResourceStart", resourceRoot,
function()
local myResourceName = resourceName or getResourceName()
local myResourceMessage = string.format("Resource successfully started: %s", myResourceName)
outputChatBox(myResourceMessage)
end
)
@TracerDS Thanks for the suggestions. Although I didn't write this piece of code, I updated it according to modern standards.
@TracerDS Thanks for the suggestions. Although I didn't write this piece of code, I updated it according to modern standards.
You could also format it to use ArgumentParser, but I think it would be best for a separate PR somewhere in the future
Bump 😈
Enough code reviews and approvals have been submitted, thanks!