crismar Posted April 15, 2014 Share Posted April 15, 2014 I've seen in some scripts some sort of: setElementData(thePlayer, "Thingy", +1) Tried that but didn't get it to work, is it possible or I just have a bad memory ? At the moment I'm using an additional variable to store the oldValue with getElementData then do setElementData(thePlayer, "Thingy", oldValue + 1) Ideas ? Link to comment
Karuzo Posted April 15, 2014 Share Posted April 15, 2014 setElementData(thePlayer, "Thingy", +1) I'm not sure but that won't make any sense since you just don't have a variable to add the 1. So you should do it like you said with the oldValue+1 . Link to comment
Saml1er Posted April 15, 2014 Share Posted April 15, 2014 local oldValue = tonumber (getElementData(thePlayer, "Thingy") ) if type (oldValue) == "number" then setElementData(thePlayer, "Thingy", oldValue + 1 ) end Link to comment
Vinctus Posted April 15, 2014 Share Posted April 15, 2014 local oldValue = tonumber (getElementData(thePlayer, "Thingy") ) if type (oldValue) == "number" then setElementData(thePlayer, "Thingy", oldValue + 1 ) end I don't see the point for if oldValue == "number" as you just made it a number on line before, also this works just fine aswell: local oldValue = getElementData(thePlayer, "Thingy") or 0 setElementData(thePlayer, "Thingy", tonumber(oldValue) + 1 ) Link to comment
iPrestege Posted April 15, 2014 Share Posted April 15, 2014 local oldValue = tonumber (getElementData(thePlayer, "Thingy") ) if type (oldValue) == "number" then setElementData(thePlayer, "Thingy", oldValue + 1 ) end I don't see the point for if oldValue == "number" as you just made it a number on line before, also this works just fine aswell: local oldValue = getElementData(thePlayer, "Thingy") or 0 setElementData(thePlayer, "Thingy", tonumber(oldValue) + 1 ) Actually it is to check if the data was a number or not. Link to comment
Vinctus Posted April 15, 2014 Share Posted April 15, 2014 local oldValue = tonumber (getElementData(thePlayer, "Thingy") ) if type (oldValue) == "number" then setElementData(thePlayer, "Thingy", oldValue + 1 ) end I don't see the point for if oldValue == "number" as you just made it a number on line before, also this works just fine aswell: local oldValue = getElementData(thePlayer, "Thingy") or 0 setElementData(thePlayer, "Thingy", tonumber(oldValue) + 1 ) Actually it is to check if the data was a number or not. Yes, I realized, but what I was saying was: local oldValue = tonumber (getElementData(thePlayer, "Thingy") ) <-- You make it a number here with tonumber() if type (oldValue) == "number" then <-- yet you check if it's a number if you just made it a number 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