FSXTim Posted May 18, 2012 Share 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 Link to comment
TAPL Posted May 18, 2012 Share 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) Link to comment
Stanley Sathler Posted May 18, 2012 Share Posted May 18, 2012 The function "getElementData()" returns false if the requested data doesn't exist. Maybe is it. Link to comment
FSXTim Posted May 18, 2012 Author Share 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 Link to comment
Stanley Sathler Posted May 18, 2012 Share 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. Link to comment
FSXTim Posted May 18, 2012 Author Share 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 Link to comment
Stanley Sathler Posted May 18, 2012 Share Posted May 18, 2012 Oh yes, I understood. So I'm sorry, I can't help you. ): Maybe in another time. Link to comment
Jaysds1 Posted May 19, 2012 Share 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) Link to comment
FSXTim Posted May 19, 2012 Author Share 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 Link to comment
Anderl Posted May 19, 2012 Share Posted May 19, 2012 I suggest you to use MySQL instead and insert each item in the table. Link to comment
FSXTim Posted May 19, 2012 Author Share 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 Link to comment
Anderl Posted May 19, 2012 Share 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? Link to comment
FSXTim Posted May 19, 2012 Author Share Posted May 19, 2012 I already have a table with all the items ... 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