FSXTim Posted May 18, 2012 Posted May 18, 2012 Error(Line7): Attempt to perform arithmetic on a boolean value function repair1_Button (state) local lp = getLocalPlayer() if state == "left" then if source == GUIEditor_Button[1] then if getElementData ( lp, "Money" ) >= 50 then takePlayerMoney ( 50 ) setElementData ( lp, "Repair", getElementData ( lp, "Repair" ) + 1 ) outputChatBox ("Du hast Dir ein Auto Repair gekauft!", 0, 255, 0 ) else outputChatBox ( "Du hast nicht genug Geld - Ein Auto Repair kostet 50$", 255, 0, 0 ) end end end end addEventHandler("onClientGUIClick", getRootElement(), repair1_Button) Can anybody help me, please? Greets
TAPL Posted May 18, 2012 Posted May 18, 2012 function repair1_Button (state) local lp = getLocalPlayer() if state == "left" then if source == GUIEditor_Button[1] then if tonumber(getElementData(lp, "Money")) >= 50 then takePlayerMoney ( 50 ) setElementData(lp, "Repair", tonumber(getElementData(lp,"Repair") or 0) + 1) outputChatBox ("Du hast Dir ein Auto Repair gekauft!", 0, 255, 0 ) else outputChatBox ( "Du hast nicht genug Geld - Ein Auto Repair kostet 50$", 255, 0, 0 ) end end end end addEventHandler("onClientGUIClick", getRootElement(), repair1_Button)
Stanley Sathler Posted May 18, 2012 Posted May 18, 2012 The function "getElementData()" returns false if the requested data doesn't exist. Maybe is it. Software Engineer & Entrepreneur • Running Lustrel and VilarikA • Highly engaged on open source community
FSXTim Posted May 18, 2012 Author Posted May 18, 2012 No Error now, thanks! But still having a problem: I bought a 'Repair' but there is still '0' in the database @ 'Repair'! Does anybody has an idea? Greets
Stanley Sathler Posted May 18, 2012 Posted May 18, 2012 I don't know much about "setElementData()" and "getElementData()", but maybe you should use setElementData() to store "1" (or other value), no? Example: setElementData(lp, "Repair", 1) I should be wrong, but I'm trying help. Software Engineer & Entrepreneur • Running Lustrel and VilarikA • Highly engaged on open source community
FSXTim Posted May 18, 2012 Author Posted May 18, 2012 Yea, thanks for your answer! But I have to tell you this is wrong, because what is, when the player buys 2 Repair items? Then the script set it alsways to '1', but the player bought 2 items, you know? Greets
Stanley Sathler Posted May 18, 2012 Posted May 18, 2012 Oh yes, I understood. So I'm sorry, I can't help you. ): Maybe in another time. Software Engineer & Entrepreneur • Running Lustrel and VilarikA • Highly engaged on open source community
Jaysds1 Posted May 19, 2012 Posted May 19, 2012 I'm not sure if this is solved but, Did you set the element data before? If you didn't, then i suggest setting it before trying that line of code(line 7) My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
FSXTim Posted May 19, 2012 Author Posted May 19, 2012 I'm not sure if this is solved but,Did you set the element data before? If you didn't, then i suggest setting it before trying that line of code(line 7) Thanks for your answer. I didn't set the element before. Maybe you can have a look here: viewtopic.php?f=91&t=43447
Anderl Posted May 19, 2012 Posted May 19, 2012 I suggest you to use MySQL instead and insert each item in the table. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
FSXTim Posted May 19, 2012 Author Posted May 19, 2012 I suggest you to use MySQL instead and insert each item in the table. Thanks for your answer, but what do you exactly mean? Greets
Anderl Posted May 19, 2012 Posted May 19, 2012 You should use MySQL database system and create a table for bought items and when a player buys a item, insert player name, item bought, ... And when you want to get all bought items just search in the table all rows where player name is the name you want. Understand? "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
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