Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------SERVER SIDE----------------
- function createSituation ()
- victims = createPed(60,-2954,-216,0)
- setElementAlpha(victims, 0)
- end
- addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createSituation)
- function sendToClient ( victims, thePlayer)
- triggerClientEvent("receiveData", root, thePlayer, victims)
- end
- function start (thePlayer)
- sendToClient(victims, thePlayer)
- end
- addCommandHandler("startTesting", start)
- -------------CLIENT SIDE---------------------
- function receiveData (thePlayer, victims)
- if thePlayer == localPlayer then
- setElementAlpha(victims, 255)
- local colShapes = createColCuboid(0, 0, 0,8,8,8)
- attachElements(colShapes, victims, -4, -4, -1.5)
- addEventHandler("onClientColShapeHit", colShapes, rescue)
- end
- end
- addEvent("receiveData", true)
- addEventHandler("receiveData", root, receiveData)
- function rescue(hitElement)
- local ped = getElementAttachedTo(source)
- if hitElement and isElement(hitElement) and getElementType(hitElement) == "vehicle" then
- local thePlayer = getVehicleOccupant(hitElement, 0)
- attachElements(ped, hitElement, 0, -2, 1, 0, 0, 0)
- timer = setTimer(checkVehicle, 1000, 0, hitElement, ped)
- if isElement(source) then destroyElement(source)end
- end
- end
- function checkVehicle(vehicle, ped)
- if vehicle and ped then
- local dmg = getElementHealth(vehicle)
- if dmg and dmg < 500 then
- detachElements(ped, vehicle)
- triggerEvent("rescuedLost", ped)
- killTimer(timer)
- end
- end
- end
- function rescuedLost ()
- local colShape = createColCuboid(0, 0, 0,8,8,8)
- attachElements(colShape, source, -4, -4, 0)
- addEventHandler("onClientColShapeHit", colShape, rescue)
- end
- addEvent("rescuedLost", false)
- addEventHandler("rescuedLost", root, rescuedLost)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement