isa_Khamdan Posted October 4, 2013 Share Posted October 4, 2013 Hello , I have this function that destroy the vehicle if it's speed is 0 but after destroying it in debugscript it show warning WARNING: test1\SafeZone.lua:16: Bad argument @ 'getElementType' [Expected element at argument 1] So how can I fix it? Link to comment
isa_Khamdan Posted October 4, 2013 Author Share Posted October 4, 2013 show your full code. sorry forgot to post the code function Destroy( element ) local Speed = getElementSpeed( element ) if getElementType ( element ) == "vehicle" then if Speed == 0 then destroyElement( element ) end end end Link to comment
TAPL Posted October 4, 2013 Share Posted October 4, 2013 if isElement(element) and getElementType ( element ) == "vehicle" then Link to comment
isa_Khamdan Posted October 4, 2013 Author Share Posted October 4, 2013 if isElement(element) and getElementType ( element ) == "vehicle" then Thanks it works but I have little problem with this code it doesn't work and there are no errors in debug function Destroy2( element ) if ( isElement(element) and getElementType (element) == "vehicle" ) then local x,y,z = getElementRotation ( element ) outputChatBox ( "Target player rotation: " .. z ) if z == (z < 90) or z == (z > 270) then destroyElement( element ) end end end Link to comment
isa_Khamdan Posted October 4, 2013 Author Share Posted October 4, 2013 Does it output the line 7? Yeah Link to comment
TAPL Posted October 4, 2013 Share Posted October 4, 2013 Then your problem from line 9. Why you need to do it like this? if z == (z < 90) or z == (z > 270) then Try if (z < 90) or (z > 270) then Because compare < or > will return true/false and z will be a number you can't compare it with bool, Link to comment
isa_Khamdan Posted October 4, 2013 Author Share Posted October 4, 2013 Then your problem from line 9.Why you need to do it like this? if z == (z < 90) or z == (z > 270) then Try if (z < 90) or (z > 270) then Because compare < or > will return true/false and z will be a number you can't compare it with bool, It works perfectly now and thanks to you else I have one more question how can I compare a number with a number between two numbers like 90 to 270? Link to comment
TAPL Posted October 4, 2013 Share Posted October 4, 2013 if (z >= 90) and (z <= 270) then 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