developa Posted July 14, 2017 Share Posted July 14, 2017 Hello, I have something wrong with pennies. At about three million groschen bugs and jumps at twenty, instead of as much as I want, it means showing in turn: 30, 50, 80. Help! Code: function takeMoney(player, price) if player and price then local cash = tonumber(getElementData(player, "player:money")) if cash >= tonumber(price) then setElementData(player, "player:money", tonumber(getElementData(player, "player:money") or 0)-price) return true else return false end end end function giveCash(player, price) if player and price then setElementData(player, "player:money", tonumber(getElementData(player, "player:money") or 0)+price) end end addEvent("giveCash", true) addEventHandler("giveCash", root, function(value) if value then giveCash(source, value) end end) addEvent("takeCash", true) addEventHandler("takeCash", root, function(price) if price then takeMoney(source, price) end end) Link to comment
Ayush Rathore Posted July 14, 2017 Share Posted July 14, 2017 18 minutes ago, developa said: Hello, I have something wrong with pennies. At about three million groschen bugs and jumps at twenty, instead of as much as I want, it means showing in turn: 30, 50, 80. Help! Code: function takeMoney(player, price) if player and price then local cash = tonumber(getElementData(player, "player:money")) if cash >= tonumber(price) then setElementData(player, "player:money", tonumber(getElementData(player, "player:money") or 0)-price) return true else return false end end end function giveCash(player, price) if player and price then setElementData(player, "player:money", tonumber(getElementData(player, "player:money") or 0)+price) end end addEvent("giveCash", true) addEventHandler("giveCash", root, function(value) if value then giveCash(source, value) end end) addEvent("takeCash", true) addEventHandler("takeCash", root, function(price) if price then takeMoney(source, price) end end) Try this btw seeing your code you might get an error function takeMoney(player, price) local cash = getElementData(player, "player:money") if cash then cash = tonumber(cash) if cash >= tonumber(price) then setElementData(player, "player:money", cash-price) return true else return false end else setElementData(player,"player:money",0) return false end end function giveCash(player, price) local cash = getElementData(player, "player:money") if cash then setElementData(player, "player:money", cash+price) return true else setElementData(player, "player:money", 0) return false end end addEvent("giveCash", true) addEventHandler("giveCash", root, function(value) if client and value then giveCash(client, value) end end) addEvent("takeCash", true) addEventHandler("takeCash", root, function(price) if client and price then takeMoney(client, price) end end) Link to comment
Simple0x47 Posted July 14, 2017 Share Posted July 14, 2017 4 hours ago, developa said: Hello, I have something wrong with pennies. At about three million groschen bugs and jumps at twenty, instead of as much as I want, it means showing in turn: 30, 50, 80. Help! Code: function takeMoney(player, price) if player and price then local cash = tonumber(getElementData(player, "player:money")) if cash >= tonumber(price) then setElementData(player, "player:money", tonumber(getElementData(player, "player:money") or 0)-price) return true else return false end end end function giveCash(player, price) if player and price then setElementData(player, "player:money", tonumber(getElementData(player, "player:money") or 0)+price) end end addEvent("giveCash", true) addEventHandler("giveCash", root, function(value) if value then giveCash(source, value) end end) addEvent("takeCash", true) addEventHandler("takeCash", root, function(price) if price then takeMoney(source, price) end end) If you want to show up cents then you should make a new money HUD which would show your "player:money" elementData's value. Link to comment
developa Posted July 14, 2017 Author Share Posted July 14, 2017 I will add that these cents only bump over a million, if we have less than a million all good show. What could be wrong is that over a million cents only get bumped? 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