local peds = { }
function camera ( )
for ped,veh in pairs(peds)do
local x, y, z = getElementPosition(veh)
setCameraMatrix(x+8, y+10, z+4, x, y, z)
end
end
function cameraStarts(ped)
setPedControlState(ped,"accelerate",true)
setTimer(function() setPedControlState(ped,"accelerate",false) end,600,1)
pVeh = getPedOccupiedVehicle(ped)
if not peds[ped] then
peds[ped] = pVeh
end
addEventHandler("onClientRender",root,camera)
addEventHandler("onClientRender",getRootElement(),stunt)
end
addEvent( "onCameraStart", true )
addEventHandler( "onCameraStart",root, cameraStarts )
function stunt ( )
local x, y = guiGetScreenSize ( )
for _, veh in pairs ( peds ) do
if ( veh ) then
local x, y, z = getElementPosition ( veh )
local px, py, pz = x + 5, y + 10, z + 2
local distance = getDistanceBetweenPoints3D ( x, y, z, px, py, pz )
if ( distance <= 150 ) then
local sx, sy = getScreenFromWorldPosition ( x, y, z + 0.55, 0.06 )
if ( sx ) then
local scale = 1 / ( 0.3 * ( distance / 150 ) )
dxDrawRectangle ( sx - 100, sy - 105, 200, 70, tocolor ( 0, 0, 0, 200 ) )
dxDrawText ( "#000000Fabioxps", sx, sy - 70, sx, sy - 30, tocolor ( 255, 255, 255, 255 ), math.min ( 0.4 * ( 20 / distance ) * 1.4, 4 ), "default-bold", "center", "bottom", false, false, false, true )
end
end
end
end
end