Drakath Posted February 1, 2014 Share Posted February 1, 2014 if getElementType(getElementData (source, "car")) == "vehicle" then WARNING: script\server.lua:47: Bad argument @ 'getElementType' [Expected element at argument 1] car=getElementData(source, "car") destroyElement(car) WARNING: script\server.lua:141: Bad argument @ 'destroyElement' [Expected element at argument 1] Why can't I use getElementData as an element? With what should I replace it in order for the script to output no errors or warnings? Link to comment
Moderators IIYAMA Posted February 1, 2014 Moderators Share Posted February 1, 2014 You can, unless it is destroyed. local car=getElementData(source, "car") if isElement(car) then -- check if it still does exist. destroyElement(car) end Link to comment
Gallardo9944 Posted February 1, 2014 Share Posted February 1, 2014 element data is a very bad way for such thing as vehicle elements. You should use tables for that. Otherwise a hacker could create a custom vehicle and set it as the element data. Or set any existing one to its element data and own it. Link to comment
Moderators IIYAMA Posted February 1, 2014 Moderators Share Posted February 1, 2014 element data is a very bad way for such thing as vehicle elements. You should use tables for that. Otherwise a hacker could create a custom vehicle and set it as the element data. Or set any existing one to its element data and own it. True, but for him it isn't important at the moment. Link to comment
Gallardo9944 Posted February 1, 2014 Share Posted February 1, 2014 element data is a very bad way for such thing as vehicle elements. You should use tables for that. Otherwise a hacker could create a custom vehicle and set it as the element data. Or set any existing one to its element data and own it. True, but for him it isn't important at the moment. It's more important than you think it is. Scripting *badly-designed* codes might become a habit and one might use this all the time. It's very easy to get a bad habit and pretty much difficult to get rid of it. So studying should go on properly, without *easier* workarounds. Link to comment
Moderators IIYAMA Posted February 1, 2014 Moderators Share Posted February 1, 2014 It's more important than you think it is. Scripting *badly-designed* codes might become a habit and one might use this all the time. It's very easy to get a bad habit and pretty much difficult to get rid of it. So studying should go on properly, without *easier* workarounds. It is important, but not everybody wants to learn lua else he would ask for the tables. 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