nearest-postal
nearest-postal copied to clipboard
feat(sv.lua): Added functionality to capture coords and create new postals.
Added the functionality to allow players to add postals using the command /plog <postal>. If the developer is using a map that is not included with nearest-postal, they will need to create a blank JSON file and update the postalFile variable in fxmanifest.lua with the new file name prior to using this functionality.
When using the /plog command, the player will not need to add the full three-digit postal. They will only need to type (as an example) /plog 1 and the resource will pad the postal to save as 001. It does this by converting the postal input to an integer, checking if it is between 1 and 99, converting back to a string and padding with leading zeroes.
This does create a dependency on ESX only if the player wishes to use this functionality, otherwise if the player is using an alternate or no framework this functionality will not be enabled. I've added a config option to config.lua which will check to see if es_extended (the name for the ESX core resource) has started and wrapped the new code in an if config.useEsx then statement. It will also only allow players with group.admin permissions to use the command.
Why is ESX a dependency in this? Why not just use RegisterCommand and use an ace for /plog?
Also, why did you chose to pad to 3 for /plog? There are tons of postal maps out there and not many use 3 digit codes exclusively.