Jump to content

getElementData


Drakath

Recommended Posts

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
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
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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...