Hugos Posted January 4, 2020 Share Posted January 4, 2020 Hi everyone! I created an array in which I pointed out street names. For example, Los Santos array: local location_ls = {"Vinewood," Marina, "Mulholland,"...} I need to perform one function when the player is in Los Santos. How can this be done? Link to comment
Moderators Patrick Posted January 4, 2020 Moderators Share Posted January 4, 2020 https://wiki.multitheftauto.com/wiki/GetZoneName local x, y, z = getElementPosition(player) local zoneName = getZoneName(x, y, z, true) -- only the city's name if zoneName == "Los Santos" then ... end 1 Link to comment
Hugos Posted January 4, 2020 Author Share Posted January 4, 2020 1 minute ago, stPatrick said: https://wiki.multitheftauto.com/wiki/GetZoneName local x, y, z = getElementPosition(player) local zoneName = getZoneName(x, y, z, true) -- only the city's name if zoneName == "Los Santos" then ... end So this code will work if the player is in areas that are specified by a single array? Link to comment
Moderators Patrick Posted January 4, 2020 Moderators Share Posted January 4, 2020 1 minute ago, Hugos said: So this code will work if the player is in areas that are specified by a single array? No, it's just a pattern. You need to be able to do it based on that. 1 Link to comment
Moderators Patrick Posted January 4, 2020 Moderators Share Posted January 4, 2020 Just now, Hugos said: Ok. Thanks you! Something like this local location_ls = {"Vinewood", "Marina", "Mulholland"} function isPlayerInSpecifiedZone(player) local x, y, z = getElementPosition(player) local zoneName = getZoneName(x, y, z) for _, v in ipairs(location_ls) do if v == zoneName then return true end end return false end 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now