Mann56 Posted March 5, 2016 Share Posted March 5, 2016 Hey guys, i was working on a performance modshop where i encountered an issue when i try to get money of the item Here for example , i have a vehicle with mass 800 kg, i then set the mass value to 801, then it outputs 20$ in money, which is perfect but when i type 802 after typing 801, instead of showing 40$ it shows 80$(it does 20$ (previous money) + 20 +40 ) and i dont know why it happens... Any help? local mass_label = guiCreateLabel(sx*50,sy*150,sx*400,sy*25,"Mass",false,performanceWindow) local mass_button = guiCreateButton(sx*300,sy*150,sx*100,sy*25,car_handling["mass"],false,performanceWindow) local massprice_label = guiCreateLabel(sx*430,sy*150,sx*100,sy*25,"20$ / 1 kg",false,performanceWindow) addEventHandler("onClientGUIClick",mass_button,function(button,state) if button == "left" and state == "up" then guiSetVisible(mass_button,false) local mass_edit = guiCreateEdit(sx*300,sy*150,sx*100,sy*25,car_handling["mass"],false,performanceWindow) addEventHandler("onClientKey",root,function(button,release) if button == "enter" and tostring(release) == "false" then mass_money = 0 guiSetVisible(mass_edit,false) guiSetVisible(mass_button,true) local mass_value = guiGetText(mass_edit) guiSetText(mass_button,mass_value) mass_money = (mass_value - car_handling["mass"])*20 if mass_money < 0 then mass_money = 0 - mass_money end outputChatBox(mass_money) moneyToTake = mass_money + moneyToTake guiSetText(checkoutMoney_label,moneyToTake) end end) end end) Link to comment
Captain Cody Posted March 5, 2016 Share Posted March 5, 2016 You could have it check if there was any previous money, and if so set that to 0 Link to comment
Mann56 Posted March 6, 2016 Author Share Posted March 6, 2016 You could have it check if there was any previous money, and if so set that to 0 I tried that but did not work.... I've already set mass_money to 0 in the function starting so it'd every time start with a zero value still it's not working. Link to comment
Mann56 Posted March 6, 2016 Author Share Posted March 6, 2016 I tried many times but still is not working..... This time, i tried like suppose my car's mass is X kg, i typed X + 3 kg and it showed 60 , thats correct but just after it, i typed X + @ and it showed $120 instead of $ 40 ( dunno why but it does 20 + 60 + 40, using the outputChatBox, i have used, i could detect this) Any help? Link to comment
Captain Cody Posted March 6, 2016 Share Posted March 6, 2016 Keep track of how many parts you buy 'With lua' then have it mulitply that by the cost then subtract that, then multiply the new value by the cost. 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