Maccer. Posted December 21, 2009 Posted December 21, 2009 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? <_>
50p Posted December 21, 2009 Posted December 21, 2009 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
subenji99 Posted December 21, 2009 Posted December 21, 2009 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 ) alter to if isElement and getElementType.
Maccer. Posted December 21, 2009 Author Posted December 21, 2009 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 ) alter to if isElement and getElementType. Danke, kind sir. I still get loads of troubles with getElementType.
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