Ben_Sherman Posted December 30, 2015 Posted December 30, 2015 Hello, I'm trying to create colshape that detects cars within it, however since /showcol and SetDevelopeMode(true) doesn't do anything for me I can only guess the colshape is correct placed as I took it from getElementPosition of myself. However everytime I run the colshape function it returns back 0 objects within which makes the function return back as nil. Can't figure it out what the problem is, I've tried vehicles I've tried players. I'ver tried it all and I some how can't get a return back value. local tempCol = { [1] = createColCuboid ( 1367.1826171875, -1659.076171875, 13.3828125, 23, 12.5, 10), } function getVehicleWithinColShap() local cars = getElementsWithinColShape(tempCol[1], "vehicle") outputDebugString(tostring(#cars)) for i, veh in pairs(cars) do return veh end end function testCommand(player, cmd) local found = getVehicleWithinColShap() if not found then outputChatBox(" ERROR ", player, 255, 255, 255, false ) end end addCommandHandler("test", testCommand)
Addlibs Posted December 30, 2015 Posted December 30, 2015 /showcol and setDevelopeMode(true) doesn't do anything for meI have no idea why that might be other than that you may have missed out a minus or something in the position. Try teleporting to the exact position of the colshape (i.e. [OOP] Player("your nickname").position = tempCol[1].position, preferably on a command handler)
Ben_Sherman Posted December 30, 2015 Author Posted December 30, 2015 /showcol and setDevelopeMode(true) doesn't do anything for meI have no idea why that might be other than that you may have missed out a minus or something in the position. Try teleporting to the exact position of the colshape (i.e. [OOP] Player("your nickname").position = tempCol[1].position, preferably on a command handler) I've verified the position of the colshape however still not working, I've even tried getElementsWithinColShape for players within that colshape and it still returns 0
Revolt Posted December 30, 2015 Posted December 30, 2015 (edited) local tempCol = { [1] = createColCuboid ( 1367.1826171875, -1659.076171875, 13.3828125, 23, 12.5, 10), } function getVehicleWithinColShap() local cars = getElementsWithinColShape(tempCol[1], "vehicle") outputDebugString(tostring(#cars)) for i, veh in ipairs(cars) do -- it should be ipairs, not pairs return veh -- however, you are returning only the first vehicle, since return actually stops the function execution end end function testCommand(player, cmd) local found = getVehicleWithinColShap() if not found then outputChatBox(" ERROR ", player, 255, 255, 255, false ) end end addCommandHandler("test", testCommand) Edited December 30, 2015 by Guest
Ben_Sherman Posted December 30, 2015 Author Posted December 30, 2015 Thank you all for all the help I could get, after more debugging I returned results however it had to be in the exact coordinates the colshape where created in or it wouldn't work. I then switched to createColPolygon and from there it worked perfect. So I have no clue what the real problem was however it got solved with createColPolygon
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