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

Wysłany: 2018-09-08, 09:43


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

Witam, chcia?bym aby jak si? w??czy f11 czyli mape, znika? licznik, gdy? jak w??czam mape czyli f11 to nie znika on i bardzo przeszkadza to.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-09-08, 10:08


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Wykorzystaj funkcj?:


Więcej informacji znajdziesz w Wikipedii MTA:

isPlayerMapVisible


Do kodu od licznika dopisz:

if isPlayerMapVisible() then return end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-09-08, 10:36


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

nie dzia?a, nic sie nie zmienilo

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-09-08, 10:48


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Pode?lij kod od licznika. Funkcja nie ma problem?w z dzia?aniem.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-09-08, 11:49


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50


--[[
    Developers:
        • .WhiteBlue ([email protected])

    Copyright (c2018 .WhiteBlue (szymon.lua@gmail.com)

    Note (EN): You can not copy and share this code without my permission.
    Note (PL): Nie mo?esz kopiowai udost?pniatego kodu bez mojej zgody.
]]

-- Variables
local speedometer = {}
local speedometer_textures = {}

-- Functions
local function getElementSpeed(theElementunit)
    -- Check arguments for errors
    assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")")
    local elementType getElementType(theElement)
    assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile""Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")")
    assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == or tonumber(unit) == or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)")
    -- Default to m/if no unit specified and 'ignore' argument type if the string contains a number
    unit unit == nil and or ((not tonumber(unit)) and unit or tonumber(unit))
    -- Setup our multiplier to convert the velocity to the specified unit
    local mult = (unit == or unit == "m/s") and 50 or ((unit == or unit == "km/h") and 180 or 111.84681456)
    -- Return the speed by calculating the length of the velocity vectorafter converting the velocity to the specified unit
    return (Vector3(getElementVelocity(theElement)) * mult).length
end

local function isBike(vehicle)
    if not vehicle or not isElement(vehiclethen return nil end

    if getElementModel(vehicle) == 481 or getElementModel(vehicle) == 509 or getElementModel(vehicle) == 510 then
        return true
    end

    return nil
end

addEventHandler('onClientRender'root,
    function()
        if not speedometer['toggled'then return nil end

        local vehicle getPedOccupiedVehicle(localPlayer)
        if not vehicle then return nil end

        -- Fuel
        local fuel getElementData(vehicle'vehicle:fuel') or 100
        if fuel 100 then fuel 100 end

        dxDrawImage(scale_x(1360), scale_y(870), scale_x(200), scale_x(200), speedometer_textures['fuel']['background'], 000tocolor(255255255255), false)
        dxDrawImage(scale_x(1360), scale_y(870), scale_x(200), scale_x(200), speedometer_textures['fuel']['arrow'], fuel 1.7500tocolor(255255255255), false)

        -- Speed
        local speed getElementSpeed(vehicle1)
        if speed 260 then speed 260 end

        dxDrawImage(scale_x(1480), scale_y(700), scale_x(400), scale_x(400), speedometer_textures['speed']['background'], 000tocolor(255255255255), false)
        
        -- Mileage
        local mileage getElementData(vehicle'vehicle:mileage') or 99999999
        dxDrawText(string.format('%08d'mileage), scale_x(1645), scale_y(940), 00tocolor(255255255255), 1speedometer['font'], 'left''top'falsefalsefalse)

        dxDrawImage(scale_x(1480), scale_y(700), scale_x(400), scale_x(400), speedometer_textures['speed']['arrow'], speed 1.1100tocolor(255255255255), false)
    end
)

addEventHandler('onClientVehicleEnter'root,
    function(player)
        if player ~= localPlayer then return nil end

        if not isBike(sourcethen
            speedometer = {
                ['toggled'] = true,

                -- Font
                ['font'] = dxCreateFont(':og-files/f/roboto.ttf'scale_x(14)),
            }

            speedometer_textures = {
                ['fuel'] = {
                    ['arrow'] = dxCreateTexture('i/fuel/arrow/arrow.png''argb'true'clamp'),

                    ['background'] = dxCreateTexture('i/fuel/fuel.png''argb'true'clamp'),
                },

                ['speed'] = {
                    ['arrow'] = dxCreateTexture('i/speed/arrow/arrow.png''argb'true'clamp'),

                    ['background'] = dxCreateTexture('i/speed/speed.png''argb'true'clamp'),
                },
            }
        end
    end
)

addEventHandler('onClientVehicleExit'root,
    function(player)
        if player ~= localPlayer then return nil end

        if not isBike(sourcethen
            if speedometer['font'] and isElement(speedometer['font']) then
                destroyElement(speedometer['font'])
            end

            speedometer = {}

            for _value in ipairs(speedometer_textures) do
                if isElement(valuethen
                    destroyElement(value)
                end
            end

            speedometer_textures = {}
        end
    end
)

addEventHandler('onClientElementDestroy'root,
    function()
        if getElementType(source) ~= 'vehicle' then return nil end
        if getPedOccupiedVehicle(localPlayer) ~= source then return nil end

        if not isBike(sourcethen
            if speedometer['font'] and isElement(speedometer['font']) then
                destroyElement(speedometer['font'])
            end

            speedometer = {}

            for _value in ipairs(speedometer_textures) do
                if isElement(valuethen
                    destroyElement(value)
                end
            end

            speedometer_textures = {}
        end
    end
)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-09-08, 12:00


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Gotowy kod:



--[[
    Developers:
        • .WhiteBlue ([email protected])

    Copyright (c2018 .WhiteBlue (szymon.lua@gmail.com)

    Note (EN): You can not copy and share this code without my permission.
    Note (PL): Nie mo?esz kopiowai udost?pniatego kodu bez mojej zgody.
]]

-- Variables
local speedometer = {}
local speedometer_textures = {}

-- Functions
local function getElementSpeed(theElementunit)
    -- Check arguments for errors
    assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")")
    local elementType getElementType(theElement)
    assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile""Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")")
    assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == or tonumber(unit) == or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)")
    -- Default to m/if no unit specified and 'ignore' argument type if the string contains a number
    unit unit == nil and or ((not tonumber(unit)) and unit or tonumber(unit))
    -- Setup our multiplier to convert the velocity to the specified unit
    local mult = (unit == or unit == "m/s") and 50 or ((unit == or unit == "km/h") and 180 or 111.84681456)
    -- Return the speed by calculating the length of the velocity vectorafter converting the velocity to the specified unit
    return (Vector3(getElementVelocity(theElement)) * mult).length
end

local function isBike(vehicle)
    if not vehicle or not isElement(vehiclethen return nil end

    if getElementModel(vehicle) == 481 or getElementModel(vehicle) == 509 or getElementModel(vehicle) == 510 then
        return true
    end

    return nil
end

addEventHandler('onClientRender'root,
    function()
        if not speedometer['toggled'then return nil end

        local vehicle getPedOccupiedVehicle(localPlayer)
        if not vehicle then return nil end
        if isPlayerMapVisible() then return end
        -- Fuel
        local fuel getElementData(vehicle'vehicle:fuel') or 100
        if fuel 100 then fuel 100 end

        dxDrawImage(scale_x(1360), scale_y(870), scale_x(200), scale_x(200), speedometer_textures['fuel']['background'], 000tocolor(255255255255), false)
        dxDrawImage(scale_x(1360), scale_y(870), scale_x(200), scale_x(200), speedometer_textures['fuel']['arrow'], fuel 1.7500tocolor(255255255255), false)

        -- Speed
        local speed getElementSpeed(vehicle1)
        if speed 260 then speed 260 end

        dxDrawImage(scale_x(1480), scale_y(700), scale_x(400), scale_x(400), speedometer_textures['speed']['background'], 000tocolor(255255255255), false)
        
        -- Mileage
        local mileage getElementData(vehicle'vehicle:mileage') or 99999999
        dxDrawText(string.format('%08d'mileage), scale_x(1645), scale_y(940), 00tocolor(255255255255), 1speedometer['font'], 'left''top'falsefalsefalse)

        dxDrawImage(scale_x(1480), scale_y(700), scale_x(400), scale_x(400), speedometer_textures['speed']['arrow'], speed 1.1100tocolor(255255255255), false)
    end
)

addEventHandler('onClientVehicleEnter'root,
    function(player)
        if player ~= localPlayer then return nil end

        if not isBike(sourcethen
            speedometer = {
                ['toggled'] = true,

                -- Font
                ['font'] = dxCreateFont(':og-files/f/roboto.ttf'scale_x(14)),
            }

            speedometer_textures = {
                ['fuel'] = {
                    ['arrow'] = dxCreateTexture('i/fuel/arrow/arrow.png''argb'true'clamp'),

                    ['background'] = dxCreateTexture('i/fuel/fuel.png''argb'true'clamp'),
                },

                ['speed'] = {
                    ['arrow'] = dxCreateTexture('i/speed/arrow/arrow.png''argb'true'clamp'),

                    ['background'] = dxCreateTexture('i/speed/speed.png''argb'true'clamp'),
                },
            }
        end
    end
)

addEventHandler('onClientVehicleExit'root,
    function(player)
        if player ~= localPlayer then return nil end

        if not isBike(sourcethen
            if speedometer['font'] and isElement(speedometer['font']) then
                destroyElement(speedometer['font'])
            end

            speedometer = {}

            for _value in ipairs(speedometer_textures) do
                if isElement(valuethen
                    destroyElement(value)
                end
            end

            speedometer_textures = {}
        end
    end
)

addEventHandler('onClientElementDestroy'root,
    function()
        if getElementType(source) ~= 'vehicle' then return nil end
        if getPedOccupiedVehicle(localPlayer) ~= source then return nil end

        if not isBike(sourcethen
            if speedometer['font'] and isElement(speedometer['font']) then
                destroyElement(speedometer['font'])
            end

            speedometer = {}

            for _value in ipairs(speedometer_textures) do
                if isElement(valuethen
                    destroyElement(value)
                end
            end

            speedometer_textures = {}
        end
    end
)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-09-08, 12:42


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

dzieki dziala

Postaw piwo autorowi tego posta
 

 
Tagi: jak :: schować :: licznik
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Jak schować licznik 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