Advertisement
Guest User

Untitled

a guest
Oct 14th, 2012
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. -------------SERVER SIDE----------------
  2. function createSituation ()
  3.         victims = createPed(60,-2954,-216,0)
  4.         setElementAlpha(victims, 0)
  5. end
  6. addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createSituation)
  7.  
  8. function sendToClient ( victims, thePlayer)
  9.     triggerClientEvent("receiveData", root, thePlayer, victims)
  10. end
  11.  
  12. function start (thePlayer)
  13. sendToClient(victims, thePlayer)
  14. end
  15. addCommandHandler("startTesting", start)
  16.  
  17.  
  18.  
  19.  
  20. -------------CLIENT SIDE---------------------
  21. function receiveData (thePlayer, victims)
  22.     if thePlayer == localPlayer then
  23.         setElementAlpha(victims, 255)
  24.         local colShapes = createColCuboid(0, 0, 0,8,8,8)
  25.         attachElements(colShapes, victims, -4, -4, -1.5)
  26.         addEventHandler("onClientColShapeHit", colShapes, rescue)
  27.     end
  28. end
  29. addEvent("receiveData", true)
  30. addEventHandler("receiveData", root, receiveData)
  31.  
  32. function rescue(hitElement)
  33.     local ped = getElementAttachedTo(source)
  34.     if hitElement and isElement(hitElement) and getElementType(hitElement) == "vehicle" then
  35.             local thePlayer = getVehicleOccupant(hitElement, 0)
  36.             attachElements(ped, hitElement, 0, -2, 1, 0, 0, 0)
  37.             timer = setTimer(checkVehicle, 1000, 0, hitElement, ped)
  38.             if isElement(source) then destroyElement(source)end
  39.     end
  40. end
  41.  
  42. function checkVehicle(vehicle, ped)
  43.     if vehicle and ped then
  44.         local dmg = getElementHealth(vehicle)
  45.         if dmg and dmg < 500 then
  46.             detachElements(ped, vehicle)
  47.             triggerEvent("rescuedLost", ped)
  48.             killTimer(timer)
  49.         end
  50.     end
  51. end
  52.  
  53. function rescuedLost ()
  54.         local colShape = createColCuboid(0, 0, 0,8,8,8)
  55.         attachElements(colShape, source, -4, -4, 0)
  56.         addEventHandler("onClientColShapeHit", colShape, rescue)
  57. end
  58. addEvent("rescuedLost", false)
  59. addEventHandler("rescuedLost", root, rescuedLost)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement