Jaysds1 Posted November 26, 2011 Share Posted November 26, 2011 Hi, I was thinking, instead of using isVehicleOnGround or isPedOnGround, why don't we make isElementOnGround and remove these function, plus it could check if an object is on the ground... What about it guyz/girlz? Link to comment
qaisjp Posted November 26, 2011 Share Posted November 26, 2011 Hi,I was thinking, instead of using isVehicleOnGround or isPedOnGround, why don't we make isElementOnGround and remove these function, plus it could check if an object is on the ground... What about it guyz/girlz? veh's and ped's are the main two things that use phys engine. rest doesn't. just compare the Z coordinate. Link to comment
diegofkda Posted November 26, 2011 Share Posted November 26, 2011 Hi,I was thinking, instead of using isVehicleOnGround or isPedOnGround, why don't we make isElementOnGround and remove these function, plus it could check if an object is on the ground... What about it guyz/girlz? Would be a good idea for me. Link to comment
arezu Posted November 29, 2011 Share Posted November 29, 2011 isVehicleOnGround doesn't work correctly anyways... Link to comment
Jaysds1 Posted November 29, 2011 Author Share Posted November 29, 2011 How are you using it? Link to comment
AGENT_STEELMEAT Posted November 29, 2011 Share Posted November 29, 2011 --Returns true if the given element is on the ground, false otherwise. --Note: this may return incorrect values if the element is not streamed in. function isElementOnGround(element) if not isEntity(element) then error("Invalid arguments to isElementOnGround (expected entity at argument 1)!") return false end local oZ = getElementDistanceFromCentreOfMassToBaseOfModel(element) local x, y, z = getElementPosition(element) if x and y and z then --Check if for some reason the position is not available (this shouldn't happen) local ground = getGroundPosition(x, y) return (z-oZ == ground and true) or false else return false end end --Returns true if the given value is an entity, false otherwise. local validTypes = { "ped" = true, "player" = true, "vehicle"= true,"object" = true, "vehicle" = true, "pickup" = true, "marker" = true, "blip" = true, "radararea" = true} function isEntity(element) if not isElement(element) then return false end local elementType = getElementType(element) if validType[elementType] then return true else return false end end Clientside only, though it would be pretty easy to implement serverside. Link to comment
Recommended Posts