Advertisement
Noneatme

Untitled

Jun 30th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | None | 0 0
  1. function VehicleDamageDetector:VehicleCollision(hitElement, force, bodypart, colX, colY, colZ, norX, norY, norZ, hitElementForce, model)
  2.     local vehicle = source;
  3.  
  4.     local x, y, z = getElementPosition(vehicle);
  5.    
  6.    
  7.     local lastDis = math.huge;
  8.     local curComponent = false;
  9.    
  10.     for part, _ in pairs(getVehicleComponents(vehicle)) do
  11.         if(self.allowedComponents[part]) then
  12.             local cx, cy, cz = getVehicleComponentPosition(vehicle, part);
  13.            
  14.             if(cx and cy and cz) then
  15.                 local x2, y2, z2 = self.getPositionFromElementOffset(vehicle, cx, cy, cz);
  16.                
  17.                 local curDis = getDistanceBetweenPoints3D(colX, colY, colZ, x2, y2, z2);
  18.                
  19.  
  20.                 if(curDis < lastDis) then
  21.                     lastDis = curDis;
  22.                     curComponent = part;
  23.                    
  24.                     --outputChatBox(part)
  25.                 end
  26.             end
  27.         end
  28.     end
  29.    
  30.     if(curComponent) then
  31.         triggerEvent("onClientVehicleDamageCollision", vehicle, curComponent, lastDis, force);
  32.     end
  33.    
  34.     outputChatBox(force * getVehicleHandling(source).collisionDamageMultiplier * 0.01)
  35.     --setTimer(destroyElement, 1000, 1, createMarker(colX, colY, colZ, "corona", force * getVehicleHandling(source).collisionDamageMultiplier * 0.01, 0, 9, 231))
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement