Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function VehicleDamageDetector:VehicleCollision(hitElement, force, bodypart, colX, colY, colZ, norX, norY, norZ, hitElementForce, model)
- local vehicle = source;
- local x, y, z = getElementPosition(vehicle);
- local lastDis = math.huge;
- local curComponent = false;
- for part, _ in pairs(getVehicleComponents(vehicle)) do
- if(self.allowedComponents[part]) then
- local cx, cy, cz = getVehicleComponentPosition(vehicle, part);
- if(cx and cy and cz) then
- local x2, y2, z2 = self.getPositionFromElementOffset(vehicle, cx, cy, cz);
- local curDis = getDistanceBetweenPoints3D(colX, colY, colZ, x2, y2, z2);
- if(curDis < lastDis) then
- lastDis = curDis;
- curComponent = part;
- --outputChatBox(part)
- end
- end
- end
- end
- if(curComponent) then
- triggerEvent("onClientVehicleDamageCollision", vehicle, curComponent, lastDis, force);
- end
- outputChatBox(force * getVehicleHandling(source).collisionDamageMultiplier * 0.01)
- --setTimer(destroyElement, 1000, 1, createMarker(colX, colY, colZ, "corona", force * getVehicleHandling(source).collisionDamageMultiplier * 0.01, 0, 9, 231))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement