local SKOCZNIA_ID=1
local screenWidth, screenHeight = guiGetScreenSize ( )
--local wyskok=createColSphere(1909.54590, -520.04132, 20.05126,2)
local wyskok=createColSphere(1918.07,-664.78,104.43,2)
local skok_start={x=0,y=0,z=0}
local player = getLocalPlayer()
function obliczDlugoscSkoku()
local x,y,z=getElementPosition(player)
local odleglosc= getDistanceBetweenPoints2D(x,y, skok_start.x,skok_start.y)
local odlegloscx = string.format("%0.2f", odleglosc)
dxDrawText(odlegloscx.." m", 0,0, screenWidth*19/20, screenHeight*12/13, tocolor(15,15,155), 2, "pricedown", "right", "bottom")
local veh=getPedOccupiedVehicle(player)
if (not veh or isVehicleOnGround(veh) or isElementInWater(veh) or isElementInWater(player)) then
if (isVehicleOnGround(veh) or isElementInWater(veh) or isElementInWater(player)) then
triggerServerEvent("wykonanySkok", player, odlegloscx, SKOCZNIA_ID)
end
removeEventHandler ( "onClientRender", root, obliczDlugoscSkoku )
end
end
addEventHandler("onClientColShapeHit",wyskok,function(hitElement,matchingDimension)
if (hitElement~=player) then return end
if (not matchingDimension or getElementDimension(hitElement)~=getElementDimension(source)) then return end
if (not isPedInVehicle(player)) then return end
local veh=getPedOccupiedVehicle(player)
if (getVehicleController(veh)~=player) then
outputChatBox(_("Musisz byc kierowca!"))
return
end
if (getElementModel(veh)~=468) then
outputChatBox(_("Skakac nalezy tylko sanchezem!"))
return
end
skok_start.x,skok_start.y,skok_start.z=getElementPosition(player)
addEventHandler ( "onClientRender", root, obliczDlugoscSkoku )
end)
local strefaspadania=createColSphere(1924.71,-502.62,20.37, 3)
setElementDimension(strefaspadania, 0)
setElementInterior(strefaspadania, 0)
addEventHandler ( "onClientColShapeHit", strefaspadania, function(hitElement, matchingDimension)
if (hitElement ~= localPlayer) then return end
if (not matchingDimension or getElementInterior(hitElement) ~= getElementInterior(source)) then return end
if isPedInVehicle(hitElement) then
local pojazd = getPedOccupiedVehicle(hitElement)
if (getElementModel(pojazd) ~= 468) then return end
if (getVehicleController(pojazd) ~= hitElement) then return end
setElementFrozen(pojazd, true)
setElementPosition(pojazd, 1918.33, -707.86, 130.46)
outputChatBox(_("Wracasz na start."))
setTimer(warpMeIntoVehicle, 200, 1, hitElement, pojazd)
else
setElementRotation(hitElement, 0, 0, 0)
setElementPosition(hitElement, 1918.33, -707.86, 130.46)
outputChatBox(_("Wracasz na start."))
end
end)
function warpMeIntoVehicle(plr, veh)
triggerServerEvent("warpMeIntoVehicle", plr, veh)
end