Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2018-08-02, 14:53


BoomEq







Wiek: 35
Na forum: 3663 dni
Posty: 101
Nick w MP: BoomEqqq

Piwa: 20

Respekt: 70

Witam, posiadam skrypt na policyjna kamer? kt?ra pokazuje ile kto? km/h jedzie przed nami, nick kierowcy itd. gdy jedziemy za nim w radiowozie. Jest ustawione w s_vehicles.lua elementdata na pojazdy:
    setElementData(vehicle,"vehicle:police", true)
. A dalej tego gui nie pokazuje. Oto server:


function SpeedCam_Render_ON( thePlayer, matchingDimension )
if getElementType ( thePlayer ) == "player" then 
local SpeedName = getElementData(source,"Speed")
setElementData(thePlayer,"Speed:ON",SpeedName)
end
    end

 

function SpeedCam_Render_OFF( thePlayer, matchingDimension )
if getElementType ( thePlayer ) == "player" then 
removeElementData(thePlayer,"Speed:ON")
end
    end

function ToggleSpeedCamera(player)
local veh = getPedOccupiedVehicle ( player )
local Speed = getElementData(veh,"Speed")
local model = getElementModel(veh)
if getElementData(veh,"vehicle:police") then
if Speed == true then
triggerClientEvent ( player, "Speed:Cam", player,"off" )
setElementData(veh,"Speed",false)
local el=getAttachedElements(veh)
for i,v in ipairs(el) do
if getElementType(v)=="colshape" then
destroyElement(v)
end
    end
elseif Speed == false then
    local x, y, z = getElementPosition(veh)
    local radiusLevel = 6
    local radius = createColSphere(x, y, z, radiusLevel)
    local ID = getElementData(veh,"dbid")
    attachElements ( radius,veh, 0, 5+radiusLevel, 0 )
    setElementData(radius,"Speed",ID)
    setElementData(veh,"Speed",true)
    addEventHandler ( "onColShapeHit", radius ,SpeedCam_Render_ON )
    addEventHandler ( "onColShapeLeave", radius, SpeedCam_Render_OFF )    
    triggerClientEvent ( player, "SpeedCam", player,"on" )
end
    end
        end

 
 
function enterVehicle ( player, seat, jacked ) 
local model = getElementModel(source)
if getElementData(source,"vehicle:police") and (seat == 0 or seat == 1) then
    local x, y, z = getElementPosition(source)
    local radiusLevel = 6
    local radius = createColSphere(x, y, z, radiusLevel)
    if seat == 0 then
    local PoliceNames = string.gsub(getPlayerName(player),"_"," ")
    setElementData(source,"SpeedCurrise:Police:Name",PoliceNames)
    end

    local ID = getElementData(source,"dbid")
    attachElements ( radius,source, 0, 5+radiusLevel, 0 )
    setElementData(radius,"Speed",ID)
    setElementData(source,"Speed",true)
    addEventHandler ( "onColShapeHit", radius ,SpeedCam_Render_ON )
    addEventHandler ( "onColShapeLeave", radius, SpeedCam_Render_OFF )        
triggerClientEvent ( player, "SpeedCam", player,"on" )    
end    
end
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle )

function exitVehicle ( thePlayer, seat, jacked ) 
local model = getElementModel(source)
if getElementData(source,"vehicle:police") and (seat == 0 or seat == 1) then
triggerClientEvent ( thePlayer, "SpeedCam", thePlayer,"off" )    
end    
end
addEventHandler ( "onVehicleExit", getRootElement(), exitVehicle ) 




Client:

local sw,sh = guiGetScreenSize()
local sx,sy = guiGetScreenSize()
screenW, screenH = guiGetScreenSize()
local font = dxCreateFont('files/myriadproregular.ttf', 13)
local pojazdNamierzany = nil
local predkoscPojazdu=0
Policevehicle_data = {}
local dxfont0_tak= dxCreateFont("font.ttf",20)
    
function RenderCamerAS(status)
    if status == 'on' then
        addEventHandler('onClientRender', getRootElement(), RenderCameraPlayerSpeed)
    elseif status == 'off' then
        removeEventHandler('onClientRender', getRootElement(), RenderCameraPlayerSpeed)
    end
end
addEvent( 'SpeedCam', true )
addEventHandler( 'SpeedCam', localPlayer, RenderCamerAS )


function RenderCameraPlayerSpeed()
    --if not(SpeedMathVehicle) then
    local PoliceVehicle = getPedOccupiedVehicle(localPlayer)
    if not PoliceVehicle then return end

    local vehID = getElementData(PoliceVehicle, 'dbid')
    for i, colshape in pairs(getElementsByType('colshape', root, true)) do
        local ColShapeID = getElementData(colshape,'Speed') or false
        if ColShapeID == vehID then
            local vehicles = getElementsWithinColShape ( colshape, 'vehicle' ) 
            for theKey,veh in pairs(vehicles) do 
                if not(veh == PoliceVehicle) then
                    local vx, vy, vz = getElementVelocity(veh)
                    local speed=((vx^2+vy^2+vz^2)^(0.5))*180
                                        local predkosc1 = math.ceil(((vx^2+vy^2+vz^2)^0.5*1.8*92))
                    predkoscPojazdu=math.floor(speed)
                    if pojazdNamierzany and getVehicleName(pojazdNamierzany) == veh then
                        pojazdNamierzany = pojazdNamierzany
                    else
                        pojazdNamierzany = veh
                    end
                end
            end        
        end
    end
    if not pojazdNamierzany then return end

    local contentX = 250
    local contentY = sy/2
    local topX = contentX+320
    local topY = contentY+270

            
    local vehicle_model = getElementData(PoliceVehicle,'SpeedCurrise:Model') or 'Nieznany'
    local vehicle_plateText = getElementData(PoliceVehicle,'SpeedCurrise:Register') or 'Nieznany'
    local vehicle_speed = getElementData(PoliceVehicle,'SpeedCurrise:Speed') or '0'
    local predkosc1 = getElementData(PoliceVehicle,'predkosc1') or '0'
    local police_name = getElementData(PoliceVehicle,'SpeedCurrise:Police:Name') or ' '
    local police_plateText = getVehiclePlateText(PoliceVehicle)

    local time=getRealTime()
    local year, month, day, hour, minute=time.year+1900, time.month+1, time.monthday, time.hour, time.minute
    local curData=('%04d/%02d/%02d %02d:%02d'):format(year, month, day, hour, minute)
    local police_updateData = getElementData(PoliceVehicle,'SpeedCurrise:Police:Data') or curData            

    dxDrawImage(topX + 100,topY + -100,340,340,'files/bg.png',0,0,0,tocolor(255,255,255,255),false)
    dxDrawText(vehicle_speed ..'', topX + 156, topY + 35, 500, 500,tocolor(240,150,0,255),1.2,dxfont0_tak,'left','top',false,false,true,true)
        dxDrawText(predkosc1, screenW * 0.3642, screenH * 0.7200, screenW * 1.000, screenH * 0.9000, tocolor(255, 255, 255, 255), 1.0, dxfont0_tak, "center", "center", true, true, true, true, true)            
    if predkoscPojazdu==0 or predkoscPojazdu>0 then
        local time=getRealTime()
        local year, month, day, hour, minute=time.year+1900, time.month+1, time.monthday, time.hour, time.minute
        if pojazdNamierzany then
            setElementData(PoliceVehicle, 'SpeedCurrise:Model', getVehicleName(pojazdNamierzany))
            setElementData(PoliceVehicle, 'SpeedCurrise:Register', getVehiclePlateText(pojazdNamierzany) or 'Nieznany')
            setElementData(PoliceVehicle, 'SpeedCurrise:Speed', predkoscPojazdu)
            setElementData(PoliceVehicle, 'predkosc1', predkoscPojazdu)
            setElementData(PoliceVehicle, 'SpeedCurrise:Police:Speed', predkoscPojazdu)
            setElementData(PoliceVehicle, 'SpeedCurrise:Police:Register', getVehiclePlateText(PoliceVehicle))
            setElementData(PoliceVehicle, 'SpeedCurrise:Police:Data', ('%04d/%02d/%02d %02d:%02d'):format(year, month, day, hour, minute))
        end
    end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-08-02, 15:51


_jvneczek







Wiek: 22
Na forum: 4467 dni
Posty: 1509
Nick w MP: _jvneczek

Piwa: 3960

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

Gdy wsiadasz do pojazdu lub pr?bujesz uruchomi? kamere to pokazuj? si? jakie? b??dy?

Podpis

Support Team: 04.10.2020 - 01.09.2020
Test Moderator: 03.05.2021 - 01.09.2021
Moderator: 01.09.2021 - 23.10.2021

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-08-02, 22:44


BoomEq







Wiek: 35
Na forum: 3663 dni
Posty: 101
Nick w MP: BoomEqqq

Piwa: 20

Respekt: 70

PolskiZiomal, Nic nie pokazuje w db3

Postaw piwo autorowi tego posta
 

 
Tagi: camera :: police
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Camera police Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku