- Documentation
- Server functions
- testSphereAgainstWorld
Function
testSphereAgainstWorld
Checks whether a sphere at the given point overlaps any element (vehicle, ped, object) according to the server's simplified model (elements as spheres, no map buildings). Useful e.g. to check that a spot is free before creating a car.
Syntax
bool, element testSphereAgainstWorld(float x, float y, float z, float radius [, element ignoredElement = nil, bool checkBuildings = true, bool checkVehicles = false, bool checkPeds = false, bool checkObjects = true])Arguments
xfloat- Sphere centre X.Different type in MTA:SA: unknown vehicle
yfloat- Centre Y.Different type in MTA:SA: unknown ped
zfloat- Centre Z.Different type in MTA:SA: object etc.
radiusfloat- Sphere radius in metres.Not in MTA:SA
ignoredElementelement, optional = nil- An ignored element.Not in MTA:SA
checkBuildingsbool, optional = true- Include objects (together with
checkObjects).Not in MTA:SA checkVehiclesbool, optional = false- Include vehicles.Not in MTA:SA
checkPedsbool, optional = false- Include peds.Not in MTA:SA
checkObjectsbool, optional = true- Include objects.Not in MTA:SA
Differences from MTA:SA
- Arguments in a different colour differ from MTA:SA.
In MTA:SA
testSphereAgainstWorld(unknown vehicle, unknown ped, object etc.)Returns
true and the first overlapping element, or false.
Example
local function spawnCarIfFree(model, x, y, z)
if testSphereAgainstWorld(x, y, z, 3, nil, true, true, true, true) then return false end
return createVehicle(model, x, y, z)
end