darkenpra Posted April 9, 2022 Share Posted April 9, 2022 addEventHandler("onClientElementDataChange", localPlayer, function (dataName, oldValue) if source == localPlayer then elseif dataName == "Hunger" then settings.currentHunger = getElementData(localPlayer, "Hunger") elseif dataName == "Panic" then settings.currentPanic = getElementData(localPlayer, "Panic") elseif dataName == "Thirsty" then settings.currentThirst = getElementData(localPlayer, "Thirsty") -- elseif dataName == "Level Element Data" then -- renderData.currentLevel = getElementData(localPlayer, "Level Element Data") elseif dataName == "money" then settings.currentMoney = getElementData(localPlayer, "money") elseif dataName == "RedMoney" then settings.currentRedMoney = getElementData(localPlayer, "RedMoney") end end end ) and local function updatePlayerStats() settings.isLoggedIn = getElementData(localPlayer, "username") settings.currentMoney = getElementData(localPlayer, "money") or 0 settings.currentRedMoney = getElementData(localPlayer, "RedMoney") or 0 settings.currentHunger = getElementData(localPlayer, "Hunger") or 0 settings.currentThirst = getElementData(localPlayer, "Thirsty") or 0 settings.currentPanic = getElementData(localPlayer, "Panic") or 0 settings.currentHealth = math_ceil(getElementHealth(localPlayer)) end setTimer(updatePlayerStats, 1000, 0) whice one is more than optimize? Link to comment
Moderators IIYAMA Posted April 10, 2022 Moderators Share Posted April 10, 2022 14 hours ago, darkenpra said: whice one is more than optimize? onClientElementDataChange, that is if you do not mis use elementdata. For example setting element data every frame. If the event onClientElementDataChange is triggered more than ~5x each second (9 func calls x 1s vs ~2 func calls each update, 9 / 2 = ~5). The timer will be more optimised than the event. (9x with different element data key) But in general the timer has a slower update timing, which should also taken in consideration. 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