Maris Posted December 12, 2018 Share Posted December 12, 2018 For example: local bd; local function fnEveryTenMinutes() if not bd then bd = getPlayer():getBodyDamage(); end ..... end Events.EveryTenMinutes.Add(fnEveryTenMinutes); I think it should reduce overhead on api calls. Link to comment Share on other sites More sharing options...
Leond Posted January 23, 2019 Share Posted January 23, 2019 (edited) Storing data outside of the function is fine. However, you will not have the most up to date information so make sure you don't use it for something that needs to have the most up to date information. Also, the code example you wrote there will only every get the body damage once. The reason for this is the `if not bd then`. This will only set it on the first pass then ignore setting the value for any other call of that function. This is assuming you don't have another section in the function that sets the value of bd. Edited January 23, 2019 by Leond Link to comment Share on other sites More sharing options...
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