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

Wysłany: 2021-10-08, 14:13


Pro3west1







Wiek: 26
Na forum: 2665 dni
Posty: 37
Nick w MP: hjkh



Respekt: 50

Witam, nie dzia?a rejestrator dla sapd, powinien on si? pojawia? i pokazywa? pr?dko?? pojazdu z przodu itp niestety tak nie jest.

B?ed?w brak
local sx,sy=guiGetScreenSize()
local wlaczony=false

local isPolicjant=(
    function(plr)
        if getElementData(plr, "player:duty") == "SAPD" or getElementData (plr, "player:duty") == "ITD" then
            return true
        end
        return false
    end
)

function findRotation( x1, y1, x2, y2 ) 
    local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) )
    return t < 0 and t + 360 or t
end

function getElementSpeed(theElement, unit)
    assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")")
    assert(getElementType(theElement) == "player" or getElementType(theElement) == "ped" or getElementType(theElement) == "object" or getElementType(theElement) == "vehicle", "Invalid element type @ getElementSpeed (player/ped/object/vehicle expected, got " .. getElementType(theElement) .. ")")
    assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)")
    unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit))
    local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456)
    return (Vector3(getElementVelocity(theElement)) * mult).length
end

local recX,recY,recX2,recY2=sx/2-200,sy-200,400,300



local isPojazdPolicji=(
    function(veh)
        if getElementData(veh,"vehicle:police") then
            if getElementData(veh,"policja:akademia") then
                return false
            end
            return true
        end
        return false
    end
)

local dxdraw=(
    function()
        local veh=getPedOccupiedVehicle(localPlayer)
        if not veh then
            return
        end
        if not isPolicjant(localPlayer) then
            return
        end
        --if (getElementModel(veh)~=597) and (getElementModel(veh)~=596) and (getElementModel(veh)~=598) then
        --    return
        --end
        if not isPojazdPolicji(veh) then
            return
        end
        if (getPedOccupiedVehicleSeat(localPlayer)~=0) and (getPedOccupiedVehicleSeat(localPlayer)~=1) then
            return
        end
        local x,y,z=getElementPosition(veh)
        local z_poj=nil
        local tbl={}
        for i,v in ipairs(getElementsByType("vehicle")) do
            if (v~=veh) then
                local px,py,pz=getElementPosition(v)
                if (getDistanceBetweenPoints3D(x,y,z,px,py,pz)<=80) then --odleg?o?? ?apania na wideo
                    local rotBetween=findRotation(x,y,px,py)
                    local _,_,rot=getElementRotation(veh)
                    local different=(rotBetween-rot)
                    different=math.abs(different)
                    if (different<=10) then
                        table.insert(tbl,v)
                    end
                end
            end
        end
        
        if (#tbl==1) then
            z_poj=tbl[1]
        else
            if (#tbl>0) then
                z_poj=tbl[1]
                local x3,y3,z3=getElementPosition(z_poj)
                for i,v in ipairs(tbl) do
                    local x2,y2,z2=getElementPosition(v)
                    if (getDistanceBetweenPoints3D(x,y,z,x2,y2,z2)<getDistanceBetweenPoints3D(x,y,z,x3,y3,z3)) then
                        z_poj=v
                        x3,y3,z3=getElementPosition(z_poj)
                    end
                end
            end
        end
        
        tbl={}
        if not z_poj then
            dxDrawImage(sx/2-144, sy-200, 288, 190, "rejestrator.png")
        else
            dxDrawImage(sx/2-144, sy-200, 288, 190, "rejestrator.png")
        end
        
        local spd_last=0
        
        if not z_poj then
            spd_last=0
            marka=nil
            model=nil
            kierowca=nil
            driver=nil
            id_driver=nil
            dbid_poj=nil
            return
        else
            spd=getElementSpeed(z_poj, "km/h")
            spd_last=(spd_last+spd)
            spd_last=string.format("%d",spd_last)
            marka=getVehicleName(z_poj)
            model=getElementModel(z_poj)
            kierowca=getVehicleController(z_poj)
            if kierowca then
                driver=getPlayerName(kierowca):gsub("#%x%x%x%x%x%x","")
                id_driver=getElementData(kierowca,"id")
            end
            dbid_poj=getElementData(z_poj, "vehicle:id")
        end
        
        local time=getRealTime()
        time.month=time.month+1
        time.year=time.year+1900
        if (time.month<10) then
            time.month="0"..time.month
        end
        if (time.hour<10) then
            time.hour="0"..time.hour
        end
        if (time.minute<10) then
            time.minute="0"..time.minute
        end
        if (time.second<10) then
            time.second="0"..time.second
        end
        if (time.monthday<10) then
            time.monthday="0"..time.monthday
        end
        czas=string.format("%s:%s:%s | %s.%s.%sr.", time.hour, time.minute, time.second, time.monthday, time.month, time.year)
        
        exports["buttons"]:createCustomText2(string.format("#808080Marka: #ff0000%s      #808080Model: #ff0000%s\n\n#808080Kierowca: #ff0000%s (ID:%s)\n#808080Czas: #ff0000%s\n#808080Numery rejestracyjne: #ff0000%s\n#808080Pr?dko??: #ff0000%skm/h", marka or "brak", model or "brak", driver or "brak", id_driver or "0", czas, dbid_poj or "brak", spd_last or "brak"), sx+2, sy+530, 0, 0, tocolor(255, 255, 255, 255), 1, "default", "center", "center", false, false, false, true, false)       
        
    end
)

addCommandHandler("wr",
    function()
        if not getElementData(localPlayer,"player:sid") then
            return
        end
        if not isPolicjant(localPlayer) then
            return
        end
        if wlaczony then
            removeEventHandler("onClientRender", root, dxdraw)
            wlaczony=false
        else
            addEventHandler("onClientRender",root,dxdraw)
            wlaczony=true
        end
    end
)


[ Dodano: 2021-10-13, 17:42 ]
F5

Postaw piwo autorowi tego posta
 

 
Tagi: rejestartor :: nie :: działa
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

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