local resourceRoot = getResourceRootElement(getThisResource())
local screenWidth, screenHeight = guiGetScreenSize ()
vehicle=nil
najwyzsza=0
dop="n/a"
rejstrator=false
moznamierzyc=true
function seter()
moznamierzyc=true
tekst="Oczekuje na pomiar..."
end
function isPlayerInTeam( thePlayer, teamName )
local pTeam = getPlayerTeam( thePlayer )
if ( pTeam ) and ( fTeam ) then
if ( pTeam == fTeam ) then
return true
end
end
end
addEventHandler("onClientResourceStart",resourceRoot,
function ()
txd = engineLoadTXD ( "files/tec9.txd" )
engineImportTXD ( txd, 372 )
dff = engineLoadDFF ( "files/tec9.dff", 372 )
engineReplaceModel ( dff, 372 )
end)
function targetingActivated ( target )
local wep=getPedWeapon(getLocalPlayer())
if wep==32 then
if isPlayerInTeam( getLocalPlayer(), "Policja" ) then
if getPedControlState ( getLocalPlayer(), "aim_weapon" ) then
if isPedDucked ( getLocalPlayer() ) then
sx, sy, sz = getElementVelocity ( getLocalPlayer() )
if math.floor((sx^2 + sy^2 + sz^2)^(0.5) * 180)<3 then
if target then
if getElementType(target)=="vehicle" then
if vehicle~=target then najwyzsza=0 end
vehicle=target
rejstrator=true
end
end
end
end
end
end
end
end
addEventHandler ( "onClientPlayerTarget", getRootElement(), targetingActivated )
function najwyszapr()
if najwyzsza>0 then
mierzony=getVehicleController(vehicle)
if mierzony then
triggerServerEvent("onPokazChatMierzenie", getLocalPlayer(), "*Policjant zmierzy? ci pr?dko??: "..najwyzsza.."", mierzony)
if (dop~="n/a") and (tonumber(dop))+10<najwyzsza then
ileprzekroczyl=najwyzsza-dop
kwota=(math.floor(ileprzekroczyl*10)/2)
score=0
triggerServerEvent("onWystawMandat_Suszarka", getLocalPlayer(), getElementData(mierzony,"ID-Player"),"Radar policyjny",getPlayerName(getLocalPlayer()),getElementData(getLocalPlayer(),"ID-Player") or 0,"Pr?dko?? "..najwyzsza.."/"..dop.."kmh",kwota,score)
triggerServerEvent("onPokazChatMierzenie", getLocalPlayer(), "*Przekroczy?e? dopuszaln? pr?dko?? i otrzyma?e? mandat "..najwyzsza.."/"..dop.."kmh od ["..getPlayerName(getLocalPlayer()).."]", mierzony)
outputChatBox("Przekroczona pr?dko??: "..najwyzsza.."/"..dop.."kmh ["..getPlayerName(mierzony).."]")
moznamierzyc=false
tekst="Czekaj, Synchronizacja"
setTimer(seter,4000,1)
end
outputChatBox("*Najwy?sza zarejstrowana pr?dko?? gracza ["..getPlayerName(mierzony).."]: "..najwyzsza)
else
outputChatBox("*Najwy?sza zarejstrowana pr?dko??: "..najwyzsza)
end
najwyzsza=0
vehicle=nil
rejstrator=false
end
end
function createText ( )
if getPedControlState ( getLocalPlayer(), "aim_weapon" ) and isPedDucked ( getLocalPlayer() ) then
sx, sy, sz = getElementVelocity ( getLocalPlayer() )
if math.floor((sx^2 + sy^2 + sz^2)^(0.5) * 180)<1 then
if vehicle then
--if ( isElementOnScreen ( vehicle ) ) then
if getPedTarget(getLocalPlayer()) == vehicle then
speedx, speedy, speedz = getElementVelocity ( vehicle )
actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)
predkosc = math.floor(actualspeed * 180)
if predkosc>najwyzsza then najwyzsza=predkosc end
dxDrawText ( predkosc.."km/h", screenWidth/2, screenHeight/2, screenWidth/2, screenHeight/2, tocolor ( 0, 0, 0, 255 ), 1.01, "pricedown" )
dxDrawText ( predkosc.."km/h", screenWidth/2, screenHeight/2, screenWidth/2, screenHeight/2, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" )
end
end
end
else
if rejstrator then najwyszapr() end
end
end
local screenW, screenH = guiGetScreenSize()
tekst="Oczekuje na pomiar..."
local screenW, screenH = guiGetScreenSize()
function render_pda()
dxDrawImage(screenW - 307, (screenH - 236), 307, 236, "files/pda.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawText("", 1141, 867, 1141, 867, tocolor(255, 255, 255, 255), 1, "default", "left", "top", false, false, false, false, false)
dxDrawText(najwyzsza.." / "..dop.."", screenW - 213 - 45, (screenH - 30) -70, (screenW - 213 - 45) + 213, ( (screenH - 30) -70) + 30, tocolor(0, 0, 0, 255), 1.3, "default-bold", "center", "center", false, false, false, false, false)
dxDrawText("Najwy?sza pr?dko??[kmh]:", screenW - 211 - 45, (screenH - 19) -95, (screenW - 211 - 45) + 211, ( (screenH - 19) -95) + 19, tocolor(0, 0, 0, 255), 1, "default", "left", "top", false, false, false, false, false)
dxDrawText("Max dop. pr?dko??[kmh]: "..dop, screenW - 211 - 45, (screenH - 19) -160, (screenW - 211 - 45) + 211, ( (screenH - 19) -160) + 19, tocolor(0, 0, 0, 255), 1, "default", "left", "top", false, false, false, false, false)
dxDrawText("Stan urz?dzenia:", screenW - 211 - 45, (screenH - 19) -140, (screenW - 211 - 45) + 211, ( (screenH - 19) -140) + 19, tocolor(0, 0, 0, 255), 1, "default", "left", "top", false, false, false, false, false)
dxDrawText(tekst, screenW - 211 - 45, (screenH - 19) -120, (screenW - 211 - 45) + 211, ( (screenH - 19) -120) + 19, tocolor(0, 0, 0, 255), 1.3, "default-bold", "center", "center", false, false, false, false, false)
dxDrawText("Po??czenie: WiFI Radar Policja", screenW - 285 - 10, (screenH - 24) -200, (screenW - 285 - 10) + 285, ( (screenH - 24) -200) + 24, tocolor(0, 0, 0, 255), 1, "default-bold", "center", "center", false, false, false, false, false)
end
function HandleTheRendering ( )
local wep=getPedWeapon(getLocalPlayer())
if wep==32 then
if isPlayerInTeam( getLocalPlayer(), "Policja" ) then
--dxDrawText("Radar: #FF0000"..dop.."#0011FFkm/h\n"..tekst, (screenW - 516) / 2, 73, ((screenW - 516) / 2) + 516, ( 73) + 73, tocolor(0, 17, 255, 255), 2, "bankgothic", "center", "center", false, false, true, true, false)
render_pda()
end
if getPedControlState ( getLocalPlayer(), "aim_weapon" ) then
if not isPedDucked ( getLocalPlayer() ) then
setControlState("aim_weapon",false)
outputChatBox("Aby mierzy? predkosc musisz kuca?",255,0,0)
end
if not moznamierzyc then
setControlState("aim_weapon",false)
outputChatBox("Odczekaj 2 sekundy od ostatniego mierzenia",255,0,0)
end
if not isPlayerInTeam( getLocalPlayer(), "Policja" ) then
outputChatBox("Radar dost?pny tylko dla pracownik?w Policji!",255,0,0)
setControlState("aim_weapon",false)
end
end
end
end
function disableTec ( prevSlot, newSlot )
if getPedWeapon(getLocalPlayer(),newSlot) == 32 then
toggleControl ( "fire", false )
toggleControl ( "playerlist", false )
toggleControl ( "action", false )
addEventHandler ( "onClientRender", root, HandleTheRendering )
addEventHandler ( "onClientRender", root, createText )
else
toggleControl ( "fire", true )
toggleControl ( "playerlist", true )
toggleControl ( "action", true )
removeEventHandler ( "onClientRender", root, HandleTheRendering )
removeEventHandler ( "onClientRender", root, createText )
end
end
addEventHandler ( "onClientPlayerWeaponSwitch", getRootElement(), disableTec )
function setDopPredkosc(cmd,ile)
if tonumber(ile)>49 and tonumber(ile)<=300 then
dop=math.floor(tonumber(ile))
else
outputChatBox("Ustaw poprawn? warto??!",255,0,0)
end
end
addCommandHandler("predkosc",setDopPredkosc)