ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client functions
  3. setElementCollidableWith

Function

setElementCollidableWith

ClientElementsIdentical to MTA:SA

Turns collision between two elements on or off, only for this player and both ways. Handy for a ghost mode: your car passes through other players' cars but still hits walls, barrels and the rest of the map.

Syntax

bool setElementCollidableWith(element theElement, element withElement, bool enabled)

Arguments

theElementelement
The first element.
withElementelement
The second element.
enabledbool
false turns the pair's collision off, true restores it.

Returns

true on success.

Example

Ghost mode at the start of a race.

local mine = getPedOccupiedVehicle(localPlayer)
for _, v in ipairs(getElementsByType("vehicle", root, true)) do
    if v ~= mine then setElementCollidableWith(mine, v, false) end
end

Notes

How it works. The game has no "collide with this one element only", so a vehicle driven by someone else stops colliding on your screen entirely (synchronisation gives its position anyway). Your own car and character keep full collision. Only the player whose script called it sees the effect.

See also