Jump to content

getElementType problem.


Maccer.

Recommended Posts

if(getElementType(arrElementIndex[eCount]) == "vehicle") then

setVehicleFrozen(arrElementIndex[eCount], false)

end

Does anyone know why this returns a bad argument warning, but still executes perfectly? Does getElementType hate tables or something? <_>

If your arrElementIndex[eCount] contains a table than you will fail. Though, if it's an MTA element you should be fine (without any error/warning messages).

Learn to debug and find out what arrElementIndex[eCount] is before you call getElementType.

https://wiki.multitheftauto.com/wiki/Debugging

Link to comment

I think the problem here (and also the reason for this code) is that your table value may or may not contain an element.

(rather than may contain a vehicle or other element, but would always have an element there)

So it throws an error when the value does not return an element, as getElementType expects an element, but executes fine when it does contain your vehicle element you are looking for.

You can safely ignore this warning, or if you want to eliminate any errors (like I tend to do :P ) alter to if isElement and getElementType.

Link to comment
if(getElementType(arrElementIndex[eCount]) == "vehicle") then

setVehicleFrozen(arrElementIndex[eCount], false)

end

Does anyone know why this returns a bad argument warning, but still executes perfectly? Does getElementType hate tables or something? <_>

If your arrElementIndex[eCount] contains a table than you will fail. Though, if it's an MTA element you should be fine (without any error/warning messages).

Learn to debug and find out what arrElementIndex[eCount] is before you call getElementType.

https://wiki.multitheftauto.com/wiki/Debugging

I debug all the time, how do you think I got these warnings? It is an element btw.

I think the problem here (and also the reason for this code) is that your table value may or may not contain an element.

(rather than may contain a vehicle or other element, but would always have an element there)

So it throws an error when the value does not return an element, as getElementType expects an element, but executes fine when it does contain your vehicle element you are looking for.

You can safely ignore this warning, or if you want to eliminate any errors (like I tend to do :P ) alter to if isElement and getElementType.

Danke, kind sir. I still get loads of troubles with getElementType.

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