s2sk Posted July 10, 2018 Share Posted July 10, 2018 I MAKE SO setElementData(source, "countCheckpoitBusRoad", 0) -- somewhere in the code local countCheckpoint = getElementData(player, "countCheckpoitBusRoad") + 1 -- callback hit marker -- AND HERE ERROR setElementData(player, "countCheckpoitBusRoad", countCheckpoint) AND HAVE "ERROR: attempt to perform arithmetic on a boolean value 'countCheckpoint '" WHY??? MY SYSTEM-BUS WORK, BUT IN CONSOLE MORE ERROR Link to comment
Rockyz Posted July 10, 2018 Share Posted July 10, 2018 (edited) local countCheckpoint = (getElementData(player, "countCheckpoitBusRoad") or 0) +1 Edited July 10, 2018 by #,+( _xiRoc[K]; > Link to comment
Z4Zy Posted July 10, 2018 Share Posted July 10, 2018 setElementData(source, "countCheckpoitBusRoad", 0) -- somewhere in the code local countCheckpoint = getElementData(player, "countCheckpoitBusRoad") -- this is a local variable setElementData(player, "countCheckpoitBusRoad", countCheckpoint + 1) -- set element's data to the current value + 1 Link to comment
Discord Moderators Pirulax Posted July 10, 2018 Discord Moderators Share Posted July 10, 2018 (edited) I dont know if some1 have noticed it, but it should be countCheckpointBusRoad setElementData(player, "countCheckpoitBusRoad", 0) -- somewhere in the code local countCheckpoint = getElementData(player, "countCheckpoitBusRoad") -- Why do u store it in elementData, if only the same resource uses it? setElementData(player, "countCheckpoitBusRoad", countCheckpoint + 1) -- set element's data to the current value + 1 It should be working. I suppose that the element on which you set the elementData was the problem(changed source to player at line 1) Edited July 10, 2018 by Pirulax Link to comment
s2sk Posted July 10, 2018 Author Share Posted July 10, 2018 OK, I did as you said. you know what now? got error which was not destroyElement(getElementData(player, "elementCheckpointBus")) local marker = createMarker(busRoad[roadName][countCheckpoint][1], busRoad[roadName][countCheckpoint][2], busRoad[roadName][countCheckpoint][3], "checkpoint", 5.0, 59, 144, 244, 200, player) setMarkerTarget(marker, busRoad[roadName][countCheckpoint + 1][1], busRoad[roadName][countCheckpoint + 1][2], busRoad[roadName][countCheckpoint + 1][3]) setElementData(player, "elementCheckpointBus", marker) "ERROR: Bad argument @ 'destroyElement' [Expected element at argument 1, got bolean]" though an error, but the marker destroy normally thx developer mta for wonderful scripting lang and very wonderful api Link to comment
Addlibs Posted July 10, 2018 Share Posted July 10, 2018 (edited) 33 minutes ago, s2sk said: thx developer mta for wonderful scripting lang and very wonderful api If you think this is a problem of this scripting language or the API, I honestly don't know how you want to have any success in writing code. Literally any weak-typed language will give you these runtime errors when you try to add an integer to a boolean, or when you attempt to destroyElement a false/nil. The error message LITERALLY tells you the problems. Quote "ERROR: attempt to perform arithmetic on a boolean value 'countCheckpoint '" You're attempting to perform arithmetic (addition, subtraction, etc) on a BOOLEAN, most likely a false value (that's what getElementData returns when there is not data set) local countCheckpoint = getElementData(player, "countCheckpoitBusRoad") -- you could also add "or 0" afterwards to make it default to a 0 when it's false/nil if (countCheckpoint) then countCheckpoint = countCheckpoint + 1 -- attempt arithmetic ONLY WHEN YOU KNOW IT'S NOT false/nil to avoid errors end Quote "ERROR: Bad argument @ 'destroyElement' [Expected element at argument 1, got bolean]" You're attempting to use destroyElement to destroy a BOOLEAN, most likely a false value (that's what getElementData returns when there is no data set). The function name even tells you that the function's purpose is to destroy an ELEMENT, not a BOOLEAN. local elem = getElementData(player, "elementCheckpointBus") if (isElement(elem)) then destroyElement(elem) -- attempt to destroy it ONLY IF YOU KNOW IT'S AN ELEMENT to avoid errors end Edited July 10, 2018 by MrTasty Link to comment
s2sk Posted July 10, 2018 Author Share Posted July 10, 2018 (edited) 15 minutes ago, MrTasty said: If you think this is a problem of this scripting language or the API, I honestly don't know how you want to have any success in writing code. Literally any weak-typed language will give you these runtime errors when you try to add an integer to a boolean, or when you attempt to destroyElement a false/nil. The error message LITERALLY tells you the problems. You're attempting to perform arithmetic (addition, subtraction, etc) on a BOOLEAN, most likely a false value (that's what getElementData returns when there is not data set) local countCheckpoint = getElementData(player, "countCheckpoitBusRoad") -- you could also add "or 0" afterwards to make it default to a 0 when it's false/nil if (countCheckpoint) then countCheckpoint = countCheckpoint + 1 -- attempt arithmetic ONLY WHEN YOU KNOW IT'S NOT false/nil to avoid errors end You're attempting to use destroyElement to destroy a BOOLEAN, most likely a false value (that's what getElementData returns when there is no data set). The function name even tells you that the function's purpose is to destroy an ELEMENT, not a BOOLEAN. local elem = getElementData(player, "elementCheckpointBus") if (isElement(elem)) then destroyElement(elem) -- attempt to destroy it ONLY IF YOU KNOW IT'S AN ELEMENT to avoid errors end can you tell me, ragul, how does this help if everything goes perfectly without her? Edited July 10, 2018 by s2sk Link to comment
Addlibs Posted July 10, 2018 Share Posted July 10, 2018 Just now, s2sk said: everything goes perfectly without her? But you just said you're getting errors. That means it doesn't work "perfectly". Quote MY SYSTEM-BUS WORK, BUT IN CONSOLE MORE ERROR When an API error returns an error, it does not stop the execution of the code, it simply fails. That call fails, it does nothing, and the code continues on. This does not mean it works perfectly. It continues - not perfectly, but at least it works. Link to comment
s2sk Posted July 10, 2018 Author Share Posted July 10, 2018 3 minutes ago, MrTasty said: But you just said you're getting errors. That means it doesn't work "perfectly". When an API error returns an error, it does not stop the execution of the code, it simply fails. That call fails, it does nothing, and the code continues on. This does not mean it works perfectly. It continues - not perfectly, but at least it works. That means what developer mta stupid, created MP with ideal sync and anticheat and make f*k sh*t under name LUA Link to comment
Addlibs Posted July 10, 2018 Share Posted July 10, 2018 I'd like to point out that MTA didn't invent Lua. Lua is its own independent language used for a plethora of applications, including MTA. It seems to be that the only thing you're complaining about is that the MTA API is outputting errors into the console to let you know that you write bad code, and you're getting mad at MTA and Lua for it. It's your own fault. I can imagine you dereferencing a null pointer and complaining that you get a memory access violation but you willfully refuse to check whether the pointer is null before attempt to dereference because "it's not my fault the language is bad wah wah," or complaining that math is broken because you can't divide by 0. If you don't like it, you should just go back to PAWN and the only software that uses it - SAMP. 1 1 Link to comment
Moderators IIYAMA Posted July 10, 2018 Moderators Share Posted July 10, 2018 (edited) 3 hours ago, s2sk said: That means what developer mta stupid, created MP with ideal sync and anticheat and make f*k sh*t under name LUA There are a lot of languages that crash if you make mistakes like that. But no, lua gives you and error and keeps working even though the execution of the function stops. It is a very forgiving language, you just have to learn the meaning behind the errors and warnings. > Google < Please be patient. It takes at least a year or two to learn everything before you start making less mistakes in your code. Edited July 10, 2018 by IIYAMA Link to comment
Zorono Posted July 25, 2020 Share Posted July 25, 2020 (edited) really i don't like Lua... and i am begging to move from SAMP but this language is getting me disappointed... please make some kind of `Porting Pawn Language` Edit: thanks all, i just found https://github.com/multitheftauto/amx Edited July 25, 2020 by Zorono found https://github.com/multitheftauto/amx Link to comment
Moderators IIYAMA Posted July 25, 2020 Moderators Share Posted July 25, 2020 No need to bring this not useful 'Lua is :~'(users are :~) topic up from 2 years ago. LOCKED 2 Link to comment
Recommended Posts